**Using the **
**solve**** command effectively**

Let's use
*solve*
to find the roots to a simple quadratic equation. We want to use
*x*
in our equation, but we have a problem:
*x*
has been assigned the value 3:

`> `
**x;**

To clear that assignment, we could type
*x := 'x'; *
which would reset
*x*
to just "
*x*
". It's often useful to clear ALL the previous assignments of the current session. That's what the
*restart*
command does:

`> `
**restart;**

Now x is just "
*x*
":

`> `
**x;**

OK, we are ready to solve our quadratic equation:

`> `
**sol := solve( x^2 - 7*x + 6 = 0, x );**

As we've seen, Maple returns the solutions of the quadratic, arranged in a sequence. Note also that I named the output
*sol*
. It almost always pays to name the output of a command like
*solve*
, because then you can refer back to the output by name. The variable
*sol*
is a sequence of solutions, and we can pick out either solution as

`> `
**sol[1]; sol[2];**

You could check that these numbers really solve the quadratic by substituting them back into the equation:

`> `
**subs( x = sol[1], x^2 - 7*x + 6 );
subs( x = sol[2], x^2 - 7*x + 6 );**

Let's use
*solve*
to find the roots of a pair of linear equations, first defining the equations and then solving them:

`> `
**eq1 := 2*x - 4*y = 6;
eq2 := x + y = 8;
sols := solve( {eq1, eq2}, {x, y} );**

The output of the
*solve*
command here is a set (it's enclosed in curly braces {}). The set contains two elements, each of which is an equation

`> `
**sols[1]; sols[2];**

It is possible to use the entire solution in a substitution command.

`> `
**subs( sols, x+y );**

It's important to note that the
*solve*
command has not actually set
* x *
or
*y *
equal to the stated values---otherwise we'd have assignment operators,
**:=**
, instead of equal signs.

Here's another example in which the output from
*solve*
is a bit more complicated. Since I assigned values to
*x *
and
*y *
above, I have to clear their values before using them in equations again:

`> `
**restart;
sols:=solve( {x^2 + y^2 = 4, x+y=2}, {x, y} );**

In this case there are two solutions. Maple returns them as a sequence, which I named
*sols*
; each element of the sequence is a set enclosed in curly braces {}, and each set consists of two equations. For example, the first solution is

`> `
**sols[1];**