Mathematica 9 is now available
Previous section-----Next section

3.4.6 Eliminating Variables

When you write down a set of simultaneous equations in Mathematica, you are specifying a collection of constraints between variables. When you use Solve, you are finding values for some of the variables in terms of others, subject to the constraints represented by the equations.

Solve[eqns, vars, elims] find solutions for vars, eliminating the variables elims
Eliminate[eqns, elims] rearrange equations to eliminate the variables elims

Eliminating variables.
Here are two equations involving x, y and the "parameters" a and b.

In[1]:=  eqn = {x + y Equal 6a + 3b, y Equal 9a + 2 x}

Out[1]=

If you solve for both x and y, you get results in terms of a and b.

In[2]:=  Solve[eqn, {x, y}]

Out[2]=

Similarly, if you solve for x and a, you get results in terms of y and b.

In[3]:=  Solve[eqn, {x, a}]

Out[3]=

If you only want to solve for x, however, you have to specify whether you want to eliminate y or a or b. This eliminates y, and so gives the result in terms of a and b.

In[4]:=  Solve[eqn, x, y]

Out[4]=

If you eliminate a, then you get a result in terms of y and b.

In[5]:=  Solve[eqn, x, a]

Out[5]=

In some cases, you may want to construct explicitly equations in which variables have been eliminated. You can do this using Eliminate.

This combines the two equations in the list eqn, by eliminating the variable a.

In[6]:=  Eliminate[eqn, a]

Out[6]=

This is what you get if you eliminate y instead of a.

In[7]:=  Eliminate[eqn, y]

Out[7]=

As a more sophisticated example of Eliminate, consider the problem of writing  in terms of the "symmetric polynomials"  and  .

To solve the problem, we simply have to write f in terms of a and b, eliminating the original variables x and y.

In[8]:=  Eliminate[ {f Equal x^5 + y^5, a Equal x + y, b Equal x y},
{x, y} ]

Out[8]=

In dealing with sets of equations, it is common to consider some of the objects that appear as true "variables", and others as "parameters". In some cases, you may need to know for what values of parameters a particular relation between the variables is always satisfied.

SolveAlways[eqns, vars] solve for the values of parameters for which the eqns are satisfied for all values of the vars

Solving for parameters that make relations always true.
This finds the values of parameters that make the equation hold for all x.

In[9]:=  SolveAlways[a + b x + c x^2 Equal (1 + x)^2, x]

Out[9]=

This equates two series.

In[10]:=  Series[a Cos[x] + b Cos[2x] + Cos[3x], {x, 0, 3}] Equal
Series[Cosh[x], {x, 0, 3}]

Out[10]=

This finds values of the undetermined coefficients.

In[11]:=  SolveAlways[%, x]

Out[11]=



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.