This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / The Mathematica Book / Advanced Mathematics / Manipulating Equations  /

3.4.2 Equations in One Variable

The main equations that Solve and related Mathematica functions deal with are polynomial equations.

  • It is easy to solve a linear equation inĀ x.
  • In[1]:= Solve[ a x + b == c , x ]

    Out[1]=

  • One can also solve quadratic equations just by applying a simple formula.
  • In[2]:= Solve[ x^2 + a x + 2 == 0 , x ]

    Out[2]=

  • Mathematica can also find exact solutions to cubic equations. Here is the first solution to a comparatively simple cubic equation.
  • In[3]:= Solve[ x^3 + 34 x + 1 == 0 , x ] [[1]]

    Out[3]=

    For cubic and quartic equations the results are often complicated, but for all equations with degrees up to four Mathematica 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.
  • In[4]:= Expand[ Product[x^2 - 2 i, {i, 3}] ]

    Out[4]=

  • For a polynomial that factors in the way this one does, it is straightforward for Solve to find the roots.
  • In[5]:= Solve[% == 0, x]

    Out[5]=

  • This constructs a polynomial of degree eight.
  • In[6]:= Expand[x^2 - 2 /. x -> x^2 - 3 /. x -> x^2 - 5]

    Out[6]=

  • The polynomial does not factor, but it can be decomposed into nested polynomials, so Solve can again find explicit formulas for the roots.
  • In[7]:= Solve[% == 0, x]

    Out[7]=


    Implicit representation for roots.

  • No explicit formulas for the solution to this equation can be given in terms of radicals, so Mathematica uses an implicit symbolic representation.
  • In[8]:= Solve[x^5 - x + 11 == 0, x]

    Out[8]=

  • This finds a numerical approximation to each root.
  • In[9]:= N[%]

    Out[9]=

  • If what you want in the end is a numerical solution, it is usually much faster to use NSolve from the outset.
  • In[10]:= NSolve[x^5 - x + 11 == 0, x]

    Out[10]=

    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 Sqrt[2] or any other expression that represents an exact numerical quantity.

  • Here is the Root object representing the first root of the polynomial discussed above.
  • In[11]:= r = Root[#^5 - # + 11 &, 1]

    Out[11]=

  • This is a numerical approximation to its value.
  • In[12]:= N[r]

    Out[12]=

  • Round does an exact computation to find the closest integer to the root.
  • In[13]:= Round[r]

    Out[13]=

  • If you substitute the root into the original polynomial, and then simplify the result, you get zero.
  • In[14]:= FullSimplify[ x^5 - x + 11 /. x -> r ]

    Out[14]=

  • This finds the product of all the roots of the original polynomial.
  • In[15]:= FullSimplify[
    Product[Root[11 - # + #^5 &, k], {k, 5}] ]

    Out[15]=

  • The complex conjugate of the third root is the second root.
  • In[16]:= Conjugate[ Root[11 - # + #^5 &, 3] ]

    Out[16]=

    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 Root objects, but now each Root object involves the parameter a.
  • In[17]:= Solve[x^5 + x + a == 0, x]

    Out[17]=

  • When a is replaced with 1, the Root objects can be simplified, and some are given as explicit radicals.
  • In[18]:= Simplify[ % /. a -> 1 ]

    Out[18]=

  • This shows the behavior of the first root as a function of a.
  • In[19]:= Plot[Root[#^5 + # + a &, 1], {a, -2, 2}]


  • This finds the derivative of the first root with respect to a.
  • In[20]:= D[Root[#^5 + # + a &, 1], a]

    Out[20]=










    If you give Solve any


    -degree polynomial equation, then it will always return exactly solutions, although some of these may be represented by Root


    objects. If there are degenerate solutions, then the number of times that each particular solution appears will be equal to its multiplicity.

  • Solve gives two identical solutions to this equation.
  • In[21]:= Solve[(x - 1)^2 == 0, x]

    Out[21]=

  • Here are the first four solutions to a tenth degree equation. The solutions come in pairs.
  • In[22]:= Take[Solve[(x^5 - x + 11)^2 == 0, x], 4]

    Out[22]=

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

  • Here is an equation involving square roots.
  • In[23]:= Solve[ Sqrt[x] + Sqrt[1 + x] == a, x]

    Out[23]=

  • And here is one involving logarithms.
  • In[24]:= Solve[ Log[x] + Log[1 - x] == a, x ]

    Out[24]=

    So long as an equation can be reduced to some kind of polynomial form, Mathematica will always be able to represent its solution in terms of Root objects, and will always be able to find accurate numerical approximations. However, with more general equations, involving say transcendental functions, there is no systematic way to use Root objects, or even to find numerical approximations. Section 3.9.6 discusses approaches to this problem in Mathematica.







  • This finds a numerical solution to the equation , close to


    .
  • In[25]:= FindRoot[ x Sin[x] - 1/2 == 0 , {x, 1} ]

    Out[25]=




  • Plotting a graph of


    makes it fairly clear that there are, in fact, an infinite number of solutions to the equation.
  • In[26]:= Plot[ x Sin[x] - 1/2 , {x, 0, 30} ]