# Solving Equations

An expression like represents an *equation* in the Wolfram Language. You will often need to *solve* equations like this, to find out for what values of they are true.

In[1]:= |

Out[1]= |

In[2]:= |

Out[2]= |

In[3]:= |

Out[3]= |

In[4]:= |

Out[4]= |

Solve[lhs==rhs,x] | solve an equation, giving a list of rules for x |

x/.solution | use the list of rules to get values for x |

expr/.solution | use the list of rules to get values for an expression |

Finding and using solutions to equations.

Solve always tries to give you explicit *formulas* for the solutions to equations. However, it is a basic mathematical result that, for sufficiently complicated equations, explicit algebraic formulas in terms of radicals cannot be given. If you have an algebraic equation in one variable, and the highest power of the variable is at most four, then the Wolfram Language can always give you formulas for the solutions. However, if the highest power is five or more, it may be mathematically impossible to give explicit algebraic formulas for all the solutions.

In[5]:= |

Out[5]= |

In[6]:= |

Out[6]= |

In[7]:= |

Out[7]= |

In[8]:= |

Out[8]= |

In addition to being able to solve purely algebraic equations, the Wolfram Language can also solve some equations involving other functions.

In[9]:= |

Out[9]= |

It is important to realize that an equation such as actually has an infinite number of possible solutions, in this case differing by multiples of . However, Solve by default returns just one solution, but prints a message telling you that other solutions may exist. You can use Reduce to get more information.

In[10]:= |

Out[10]= |

In[11]:= |

Out[11]= |

Solve can also handle equations involving symbolic functions. In such cases, it again prints a warning, then gives results in terms of formal inverse functions.

In[12]:= |

Out[12]= |

Solve[{lhs_{1}==rhs_{1},lhs_{2}==rhs_{2},…},{x,y,…}] | |

solve a set of simultaneous equations for x, y, … |

Solving sets of simultaneous equations.

You can also use the Wolfram Language to solve sets of simultaneous equations. You simply give the list of equations, and specify the list of variables to solve for.

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

In[15]:= |

Out[15]= |

The Wolfram Language can solve any set of simultaneous *linear* or polynomial equations.

When you are working with sets of equations in several variables, it is often convenient to reorganize the equations by eliminating some variables between them.

In[16]:= |

Out[16]= |

If you have several equations, there is no guarantee that there exists *any* consistent solution for a particular variable.

In[17]:= |

Out[17]= |

In[18]:= |

Out[18]= |

The general question of whether a set of equations has any consistent solution is quite a subtle one. For example, for most values of , the equations are inconsistent, so there is no possible solution for . However, if is equal to , then the equations *do* have a solution. Solve is set up to give you *generic* solutions to equations. It discards any solutions that exist only when special constraints between parameters are satisfied.

If you use Reduce instead of Solve, the Wolfram Language will however keep *all* the possible solutions to a set of equations, including those that require special conditions on parameters.

*both*

*and*should be True.

In[19]:= |

Out[19]= |

In[20]:= |

Out[20]= |

In[21]:= |

Out[21]= |

In[22]:= |

Out[22]= |

Solve[lhs==rhs,x] | solve an equation for x |

Solve[{lhs_{1}==rhs_{1},lhs_{2}==rhs_{2},…},{x,y,…}] | |

solve a set of simultaneous equations for x, y, … | |

Eliminate[{lhs_{1}==rhs_{1},lhs_{2}==rhs_{2},…},{x,…}] | |

eliminate x, … in a set of simultaneous equations | |

Reduce[{lhs_{1}==rhs_{1},lhs_{2}==rhs_{2},…},{x,y,…}] | |

give a set of simplified equations, including all possible solutions |

Functions for solving and manipulating equations.

Reduce also has powerful capabilities for handling equations specifically over real numbers or integers. "Equations and Inequalities over Domains" discusses this in more detail.

In[23]:= |

Out[23]= |

In[24]:= |

Out[24]= |

In[25]:= |

Out[25]= |