Equations in One Variable

The main equations that (RefLink[Solve, paclet:ref/Solve]) and related Wolfram Language functions deal with are polynomial equations.

It is easy to solve a linear equation in x:

Solve[a x+b==c,x]

One can also solve quadratic equations just by applying a simple formula:

Solve[x^2+a x+2==0,x]

The Wolfram Language can also find exact solutions to cubic equations. Here is the first solution to a comparatively simple cubic equation:

Solve[x^3+34 x+1==0,x][[1]]

For cubic and quartic equations the results are often complicated, but for all equations with degrees up to four the Wolfram Language is always able to give explicit formulas for the solutions.

An important feature of these formulas is that they involve only radicals: arithmetic combinations of square roots, cube roots and higher roots.

It is a fundamental mathematical fact, however, that for equations of degree five or higher, it is no longer possible in general to give explicit formulas for solutions in terms of radicals.

There are some specific equations for which this is still possible, but in the vast majority of cases it is not.

This constructs a degree six polynomial:

Expand[Product[x^2-2 i,{i,3}]]

For a polynomial that factors in the way this one does, it is straightforward for (RefLink[Solve, paclet:ref/Solve]) to find the roots:

Solve[%==0,x]

This constructs a polynomial of degree eight:

Expand[x^2-2/.x->x^2-3/.x->x^2-5]

The polynomial does not factor, but it can be decomposed into nested polynomials, so (RefLink[Solve, paclet:ref/Solve]) can again find explicit formulas for the roots:

Solve[%==0,x]

Implicit representation for roots.

No explicit formulas for the solution to this equation can be given in terms of radicals, so the Wolfram Language uses an implicit symbolic representation:

Solve[x^5-x+11==0,x]

This finds a numerical approximation to each root:

N[%]

If what you want in the end is a numerical solution, it is usually much faster to use (RefLink[NSolve, paclet:ref/NSolve]) from the outset:

NSolve[x^5-x+11==0,x]

(RefLink[Root, paclet:ref/Root]) objects provide an exact, though implicit, representation for the roots of a polynomial. You can work with them much as you would work with (RefLink[Sqrt, paclet:ref/Sqrt])[2] or any other expression that represents an exact numerical quantity.

Here is the (RefLink[Root, paclet:ref/Root]) object representing the first root of the polynomial discussed above:

r=Root[#^5-#+11&,1]

This is a numerical approximation to its value:

N[r]

(RefLink[Round, paclet:ref/Round]) does an exact computation to find the closest integer to the root:

Round[r]

If you substitute the root into the original polynomial, and then simplify the result, you get zero:

FullSimplify[x^5-x+11/.x->r]

This finds the product of all the roots of the original polynomial:

FullSimplify[Product[Root[11-#+#^5&,k],{k,5}]]

The complex conjugate of the third root is the second root:

Conjugate[Root[11-#+#^5&,3]]

If the only symbolic parameter that exists in an equation is the variable that you are solving for, then all the solutions to the equation will just be numbers. But if there are other symbolic parameters in the equation, then the solutions will typically be functions of these parameters.

The solution to this equation can again be represented by (RefLink[Root, paclet:ref/Root]) objects, but now each (RefLink[Root, paclet:ref/Root]) object involves the parameter a:

Solve[x^5+x+a==0,x]

When a is replaced with 1, the (RefLink[Root, paclet:ref/Root]) objects can be simplified, and some are given as explicit radicals:

Simplify[%/.a->1]

This shows the behavior of the first root as a function of a:

Plot[Root[#^5+#+a&,1],{a,-2,2}]

This finds the derivative of the first root with respect to a:

D[Root[#^5+#+a&,1],a]

If you give (RefLink[Solve, paclet:ref/Solve]) any n(^th)-degree polynomial equation, then it will always return exactly n solutions, although some of these may be represented by (RefLink[Root, paclet:ref/Root]) objects. If there are degenerate solutions, then the number of times that each particular solution appears will be equal to its multiplicity.

(RefLink[Solve, paclet:ref/Solve]) gives two identical solutions to this equation:

Solve[(x-1)^2==0,x]

Here are the first four solutions to a tenth degree equation. The solutions come in pairs:

Take[Solve[(x^5-x+11)^2==0,x],4]

The Wolfram Language also knows how to solve equations which are not explicitly in the form of polynomials.

Here is an equation involving square roots:

Solve[Sqrt[x]+Sqrt[1+x]==a,x]

And here is one involving logarithms:

Solve[Log[x]+Log[1-x]==a,x]

So long as it can reduce an equation to some kind of polynomial form, the Wolfram Language will always be able to represent its solution in terms of (RefLink[Root, paclet:ref/Root]) objects. However, with more general equations, involving, say, transcendental functions, there is no systematic way to use (RefLink[Root, paclet:ref/Root]) objects, or even necessarily to find numerical approximations.

Here is a simple transcendental equation for x:

Solve[ArcSin[x]==a,x]

There is no solution to this equation in terms of standard functions:

Solve[Cos[x]==x,x]

The Wolfram Language can nevertheless find a numerical solution even in this case:

FindRoot[Cos[x]==x,{x,0}]

Polynomial equations in one variable only ever have a finite number of solutions. But transcendental equations often have an infinite number. Typically the reason for this is that functions like (RefLink[Sin, paclet:ref/Sin]) in effect have infinitely many possible inverses. With the default option setting (RefLink[InverseFunctions, paclet:ref/InverseFunctions])->(RefLink[True, paclet:ref/True]), (RefLink[Solve, paclet:ref/Solve]) will nevertheless assume that there is a definite inverse for any such function. (RefLink[Solve, paclet:ref/Solve]) may then be able to return particular solutions in terms of this inverse function.

The Wolfram Language returns a particular solution in terms of (RefLink[ArcSin, paclet:ref/ArcSin]), but prints a warning indicating that other solutions are lost:

Solve[Sin[x]==a,x]

Here the answer comes out in terms of (RefLink[ProductLog, paclet:ref/ProductLog]):

Solve[Exp[x]+x+1==0,x]

If you ask (RefLink[Solve, paclet:ref/Solve]) to solve an equation involving an arbitrary function like f, it will by default try to construct a formal solution in terms of inverse functions.

(RefLink[Solve, paclet:ref/Solve]) by default uses a formal inverse for the function f:

Solve[f[x]==a,x]

This is the structure of the inverse function:

InputForm[%]

Inverse functions.

This returns an explicit inverse function:

InverseFunction[Tan]

The Wolfram Language can do formal operations on inverse functions:

D[InverseFunction[f][x^2],x]

While (RefLink[Solve, paclet:ref/Solve]) can only give specific solutions to an equation, (RefLink[Reduce, paclet:ref/Reduce]) can give a representation of a whole solution set. For transcendental equations, it often ends up introducing new parameters, say with values ranging over all possible integers.

This is a complete representation of the solution set:

Reduce[Sin[x]==a,x]

Here again is a representation of the general solution:

Reduce[Exp[x]+x+1==0,x]

As discussed at more length in "Equations and Inequalities over Domains", (RefLink[Reduce, paclet:ref/Reduce]) allows you to restrict the domains of variables. Sometimes this will let you generate definite solutions to transcendental equations—or show that they do not exist.

With the domain of x restricted, this yields definite solutions:

Reduce[{Sin[x]==1/2,Abs[x]<4},x]

With x constrained to be real, only one solution is possible:

Reduce[Exp[x]+x+1==0,x,Reals]

(RefLink[Reduce, paclet:ref/Reduce]) knows there can be no solution here:

Reduce[{Sin[x]==x,x>1},x]