Solve

Solve[expr, vars]
attempts to solve the system expr of equations or inequalities for the variables vars.

Solve[expr, vars, dom]
solves over the domain dom. Common choices of dom are Reals, Integers, and Complexes.

Details and OptionsDetails and Options

  • The system expr can be any logical combination of:
  • lhs==rhsequations
    lhs!=rhsinequations
    or inequalities
    exprdomdomain specifications
    ForAll[x,cond,expr]universal quantifiers
    Exists[x,cond,expr]existential quantifiers
  • Solve[{expr1, expr2, ...}, vars] is equivalent to Solve[expr1&&expr2&&..., vars].
  • A single variable or a list of variables can be specified.
  • Solve gives solutions in terms of rules of the form .
  • When there are several variables, the solution is given in terms of lists of rules: .
  • When there are several solutions, Solve gives a list of them.
  • When a single variable is specified and a particular root of an equation has multiplicity greater than one, Solve gives several copies of the corresponding solution.
  • Solve[expr, vars] assumes by default that quantities appearing algebraically in inequalities are real, while all other quantities are complex.
  • Solve[expr, vars, dom] restricts all variables and parameters to belong to the domain dom.
  • If dom is Reals, or a subset such as Integers or Rationals, then all constants and function values are also restricted to be real.
  • Solve[expr&&varsReals, vars, Complexes] solves for real values of variables, but function values are allowed to be complex.
  • Solve[expr, vars, Integers] solves Diophantine equations over the integers.
  • Algebraic variables in expr free of the and of each other are treated as independent parameters.
  • Solve deals primarily with linear and polynomial equations.
  • When expr involves only polynomial equations and inequalities over real or complex domains, then Solve can always in principle solve directly for all the .
  • When expr involves transcendental conditions or integer domains, Solve will often introduce additional parameters in its results.
  • Solve can give explicit representations for solutions to all linear equations and inequalities over the integers, and can solve a large fraction of Diophantine equations described in the literature.
  • When expr involves only polynomial conditions over real or complex domains, Solve[expr, vars] will always be able to eliminate quantifiers.
  • The following options can be given:
  • CubicsFalsewhether to use explicit radicals to solve all cubics
    GeneratedParametersChow to name parameters that are generated
    InverseFunctionsAutomaticwhether to use symbolic inverse functions
    MaxExtraConditions0how many extra equational conditions on continuous parameters to allow
    MethodAutomaticwhat method should be used
    Modulus0modulus to assume for integers
    QuarticsFalsewhether to use explicit radicals to solve all quartics
    VerifySolutionsAutomaticwhether to verify solutions obtained using non-equivalent transformations
    WorkingPrecisionInfinityprecision to be used in computations
  • Solve gives generic solutions only. Solutions that are valid only when continuous parameters satisfy equations are removed. Other solutions that are only conditionally valid are expressed as ConditionalExpression objects.
  • Conditions included in ConditionalExpression solutions may involve inequalities, Element statements, equations and inequations on non-continuous parameters, and equations with full-dimensional solutions. Inequations and NotElement conditions on continuous parameters and variables are dropped.
  • With MaxExtraConditions->Automatic, only solutions that require the minimal number of equational conditions on continuous parameters are included.
  • With MaxExtraConditions->All, solutions that require arbitrary conditions on parameters are given and all conditions are included.
  • With MaxExtraConditions->k, only solutions that require at most k equational conditions on continuous parameters are included.
  • Solve uses non-equivalent transformations to find solutions of transcendental equations and hence it may not find some solutions and may not establish exact conditions on the validity of the solutions found.
  • With Method->Reduce, Solve uses only equivalent transformations and finds all solutions.
  • Solve gives if there are no possible solutions to the equations.
  • Solve gives if the set of solutions is full-dimensional.
  • Solve[eqns, ..., Modulus->m] solves equations over the integers modulo m. With Modulus->Automatic, Solve will attempt to find the largest modulus for which the equations have solutions.
  • Solve uses special efficient techniques for handling sparse systems of linear equations with approximate numerical coefficients.

ExamplesExamplesopen allclose all

Basic Examples (6)Basic Examples (6)

Solve a quadratic equation:

In[1]:=
Click for copyable input
Out[1]=

Solve simultaneous equations in and :

In[1]:=
Click for copyable input
Out[1]=

Solutions are given as lists of replacements:

In[1]:=
Click for copyable input
Out[1]=

Replace by solutions:

In[2]:=
Click for copyable input
Out[2]=

Replace combinations of and by solutions, and simplify the results:

In[3]:=
Click for copyable input
Out[3]=

Plot the real parts of the solutions for as a function of the parameter :

In[4]:=
Click for copyable input
Out[4]=

Pick out the third solution:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Solve an equation over the reals:

In[1]:=
Click for copyable input
Out[1]=

Replace by solutions and simplify the results:

In[2]:=
Click for copyable input
Out[2]=

Solve an equation over the positive integers:

In[1]:=
Click for copyable input
Out[1]=

List the first 10 solutions:

In[2]:=
Click for copyable input
Out[2]=
New in 1 | Last modified in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »