**The difference between **
**solve**** and **
**fsolve**

You've seen the
*solve*
command in action, and it's a very powerful tool for solving equations.
*Solve*
works very much like you would if asked to solve an equation by hand---it uses algebraic manipulation, the quadratic formula, trig identities, etc. to manipulate equations. But there are many equations which cannot be solved by any amount of algebraic manipulation. We say that such equations have no "closed-form" solutions. A simple example is the equation
. A plot clearly suggests that this equation has a root somewhere between
and
, but you'll never get the solution by algebraic tricks (try!). In this case we have to settle for a numerical approximation to the solution. This is what the
*fsolve*
command does. To illustrate the process and how it differs from algebraic manipulation, consider finding the root of

graphically. We'd start with a plot:

`> `
**plot( x - cos(x), x = 0..1 );**

There's a root somewhere around . To estimate it more accurately zoom in on that point:

`> `
**plot( x - cos(x), x = 0.7 .. 0.8 );
**

The root is at about
*x = 0.74*
. We could now plot on a tighter interval around 0.74 to obtain an even more accurate estimate, and so on, and so on, zooming in to estimate the root to any desired degree of accuracy. This is very much like what the
*fsolve*
command does, although of course it doesn't work graphically. It iteratively refines an estimate of the root, until some preset accuracy is achieved.

There is another twist to the
*fsolve*
command: In general it can find
__only one root at a time__
. Why? It turns out that finding all the roots of a general function is an absurdly hard problem. To keep the
*fsolve*
command reasonably fast and simple, it was written to locate only one root at a time. Here is an example. Consider solving
. Here is a plot:

`> `
**plot( x/5 - cos(x), x = -5..5 );**

There are clearly 3 roots in this interval. If we try to find them using
*fsolve*
:

`> `
**fsolve( x/5 - cos(x) = 0, x );**

we only get one root! What if that isn't the solution we're interested in---how can we make Maple find the others? There is a way to tell the
*fsolve*
command to restrict its search to a certain interval. For example, if we really want to find the root near
, we could tell
*fsolve*
to restrict its attention to the interval from
to
. It's easy to see from the plot that there are no other solutions in that interval. The command is

`> `
**fsolve( x/5 - cos(x) = 0, x = -3..-1 );**

SELF TEST: Use
*fsolve*
to find the third root of
in the interval from -5 to 5. (Try it now!)

There is one exceptional case in which
*fsolve*
will locate all of the roots of an equation, and that is when the equation is of the form "polynomial = 0". For example, consider finding the roots of a sixth degree polynomial:

`> `
**fsolve( x^6 - 21*x^5 + 175*x^4 - 735*x^3 + 1624*x^2 - 1760*x + 730 = 0, x);**

In this case Maple locates both of the real roots to the polynomial (there are also four complex roots). It turns out that numerically approximating all real roots to a polynomial is only a moderately hard problem, and
*fsolve*
handles it. By the way,
*fsolve*
can approximate ALL roots to a polynomial, including the complex ones, as follows:

`> `
**fsolve( x^6 -21*x^5 + 175*x^4 - 735*x^3 + 1624*x^2 - 1760*x + 730 = 0, x, complex ); **