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 / Built-in Functions / Algebraic Computation / Equation Solving  /
Solve

  • Solve[ eqns , vars ] attempts to solve an equation or set of equations for the variables vars.
  • Solve[ eqns , vars , elims ] attempts to solve the equations for vars, eliminating the variables elims.
  • Equations are given in the form lhs == rhs.
  • Simultaneous equations can be combined either in a list or with &&.
  • A single variable or a list of variables can be specified.
  • Solve[ eqns ] tries to solve for all variables in eqns.
  • Example: Solve[3 x + 9 == 0, x].
  • Solve gives solutions in terms of rules of the form x -> sol.
  • When there are several variables, the solution is given in terms of lists of rules: x -> , y -> , ... .
  • When there are several solutions, Solve gives a list of them.
  • When a particular root has multiplicity greater than one, Solve gives several copies of the corresponding solution.
  • Solve deals primarily with linear and polynomial equations.
  • The option InverseFunctions specifies whether Solve should use inverse functions to try and find solutions to more general equations. The default is InverseFunctions->Automatic. In this case, Solve can use inverse functions, but prints a warning message. See notes on InverseFunctions.
  • Solve gives generic solutions only. It discards solutions that are valid only when the parameters satisfy special conditions. Reduce gives the complete set of solutions.
  • Solve will not always be able to get explicit solutions to equations. It will give the explicit solutions it can, then give a symbolic representation of the remaining solutions in terms of Root objects. If there are sufficiently few symbolic parameters, you can then use N to get numerical approximations to the solutions.
  • Solve gives {} if there are no possible solutions to the equations.
  • Solve[ eqns , ... , Mode->Modular] solves equations with equality required only modulo an integer. You can specify a particular modulus to use by including the equation Modulus== p. If you do not include such an equation, Solve will attempt to solve for the possible moduli.
  • Solve uses special efficient techniques for handling sparse systems of linear equations with approximate numerical coefficients.
  • See the Mathematica book: Section 1.5.7Section 3.4.4.
  • See also Implementation NotesA.9.55.7MainBookLinkOldButtonDataA.9.55.7.
  • See also: Reduce, Eliminate, Roots, NSolve, FindRoot, LinearSolve, RowReduce, GroebnerBasis, DSolve, Root.
  • Related packages: Algebra`RootIsolation`, DiscreteMath`RSolve`, Graphics`ImplicitPlot`, Algebra`AlgebraicInequalities`.

    Further Examples

    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. Their solutions are given in terms of powers. These 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]=

    In[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 y->1 is rejected.

    In[14]:=

    Out[14]=

    Here are three simultaneous algebraic equations. This is tricky because 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; hence 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 eliminat 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]=

    It may be useful to set VerifySolutions to True when there is numeric instability. The result will take more time to produce but it will be 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 -> 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]:=

    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]:=

    InverseFunction::ifun: Warning: Inverse functions are being used. Values may be lost for multivalued inverses.

    InverseFunction::ifun: Warning: Inverse functions are being used. Values may be lost for multivalued inverses.

    Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found.

    Out[29]=

    To improve readability, we will now suppress inverse function warning messages. 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]=

    Solve cannot handle this equation directly.

    In[46]:=

    Solve::tdep: The equations appear to involve transcendental functions of the variables in an essentially non-algebraic way.

    Out[46]=

    We therfore construct a second equation that encapsulates as a variable.
    But this is not the same problem, since, for example, is not equivalent to .

    In[47]:=

    Out[47]=

    To do the original problem, we express all variables in terms of . Here is one way to do this.

    In[48]:=

    In[49]:=

    Out[49]=

    Here is another.

    In[50]:=

    Out[50]=

    In[51]:=

    Equations or solutions that involve ProductLog

    In[52]:=

    Out[52]=

    In[53]:=

    Solve::verif: Potential solution {y -> 0} cannot be verified automatically. Verification may require use of limits.

    Out[53]=

    In[54]:=

    Out[54]=

    In[55]:=

    Out[55]=

    This last example comes from a typo in a quadratic.

    In[56]:=

    Out[56]=

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

    In[57]:=