This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Built-in Functions / Numerical Computation / Equation Solving /

Further Examples: Solve

Polynomial equations in one variable

These are standard formulas for the solutions of normalized quadratic and cubic equations.

In[1]:=

Out[1]=

In[2]:=

Out[2]=

Here are two simple equations of higher degree with solutions in terms of powers. They can be rewritten in terms of trigonometric functions that sometimes automatically reduce to radicals.

In[3]:=

Out[3]=

In[4]:=

Out[4]=

In[5]:=

Out[5]=

In[6]:=

Out[6]=

For some equations, Mathematica produces the result in terms of Root objects (or algebraic numbers). The first argument of Root is an irreducible polynomial expressed as a pure function and the second argument identifies the choice of root.

In[7]:=

Out[7]=

We can get a numerical result by applying N.

In[8]:=

Out[8]=

This pulls all of the rules for x out of the result.

In[9]:=

Out[9]=

Polynomial equations in more than one variable

Here we solve for x and y.

In[10]:=

In[11]:=

Out[11]=

In this case we eliminate y first and then solve for x.

In[12]:=

Out[12]=

In[13]:=

Here we solve two simultaneous algebraic equations. The spurious potential solution is rejected.

In[14]:=

Out[14]=

Here are three simultaneous algebraic equations; y and z must be paired up correctly with x.

In[15]:=

Out[15]=

Here Solve returns an empty list, indicating no solution. Every potential solution forces an equation in the parameter z alone, so there are no generic solutions.

In[16]:=

Out[16]=

We can get solutions by solving for z as well as x and y.

In[17]:=

Out[17]=

We eliminate e, s, and t to get d in terms of the remaining variables.

In[18]:=

Out[18]=

Verification is not done by default for polynomial systems. The purported solutions to this system are nowhere near correct.

In[19]:=

Out[19]=

When there is numeric instability, setting VerifySolutions to True will take longer but will make the result more reliable.

In[20]:=

Out[20]=

In[21]:=

Radical equations

In radical equations, Solve discards parasite solutions.

In[22]:=

Out[22]=

In[23]:=

Out[23]=

In[24]:=

Out[24]=

To see all candidate solutions, including parasites, set VerifySolutions to False.

In[25]:=

Out[25]=

If you can be sure that zero denominators will not affect the solution set, clearing them often makes Solve faster.

In[26]:=

Out[26]=

In[27]:=

Out[27]=

In[28]:= expr =.

Suppressing messages

The equations that follow in the rest of this notebook come from various papers and from questions submitted by users.

Solve generates warning messages for many non-polynomial equations.

In[29]:=

Out[29]=

To improve readability, we will now suppress warning messages about inverse functions. These messages will be turned back on at the end of this set of examples.

In[30]:=

Equations involving trigonometric or hyperbolic functions, or their inverses

In[31]:=

Out[31]=

In[32]:=

Out[32]=

In[33]:=

Out[33]=

In[34]:=

Out[34]=

Equations involving exponentials and logarithms

In[35]:=

Out[35]=

In[36]:=

Out[36]=

In[37]:=

Out[37]=

In[38]:=

Out[38]=

In[39]:=

Out[39]=

In[40]:=

Out[40]=

In[41]:=

Out[41]=

In[42]:=

Out[42]=

In[43]:=

Out[43]=

In[44]:=

Out[44]=

In[45]:=

Out[45]=

In[46]:=

Out[46]=

Equations or solutions that involve ProductLog

In[47]:=

Out[47]=

In[48]:=

Out[48]=

In[49]:=

Out[49]=

In[50]:=

Out[50]=

This last example comes from a typo in a quadratic.

In[51]:=

Out[51]=

Getting infinite solution sets for some equations

To each inverse of a trig or hyperbolic function Generalize adds n times the period of the corresponding trig or hyperbolic function. The second argument, n, indicates any integer.

In[52]:=

In[53]:=

In[54]:=

Log and ProductLog are treated similarly.

In[55]:=

In[56]:=

Anything else is left alone.

In[57]:=

GeneralizedSolve tries to give an infinite solution set indexed by n for an equation or set of equations in the variables vars.

In[58]:=

This gives the generalized solution set for the equation.

In[59]:=

Out[59]=

This checks the results.

In[60]:=

Out[60]=

GeneralizedSolve fails when an inverse trigonometric function evaluates.

In[61]:=

Out[61]=

This is in contrast to the case when the inverse trig function remains unevaluated.

In[62]:=

Out[62]=

GeneralizedSolve can also give spurious solutions.

In[63]:=

In[64]:=

Out[64]=

Here the solutions for x are wrong when n is .

In[65]:=

Out[65]=

In[66]:=

When Solve gives a wrong answer

Here is a function.

In[67]:=

There are purported solutions.

In[68]:=

In[69]:=

Out[69]=

If Solve cannot determine that parametrized solutions are always incorrect, it will not remove them. The first solution is generally incorrect.

In[70]:=

Out[70]=

Using TrigToExp gives the right answers by converting ff to an equivalent exponential form.

In[71]:=

Out[71]=

In[72]:=

There are correct solutions.

In[73]:=

Out[73]=

In[74]:=

Out[74]=

In[75]:=

Turning messages back on

We will now turn the inverse function warning messages back on that were turned off earlier in this set of examples.

In[76]:=