next up previous
Next: Long Command Lines Up: COMMANDS FOR MATH Previous: Solving Equations Exactly

Solving Equations Approximately

To find all solutions of the equation try

solve( 7*cos(x) + x + x^2 = 15, x );
Maple tries to find the exact solutions and fails. So we attempt to obtain the approximate solutions using the command fsolve.

First we must find out how many solutions this equation has. For large |x|, approaches , so the solutions of this equation are in a finite interval. We plot the function over a reasonably large interval.

plot( 7*cos(x) + x + x^2 - 15, x=-10..10 );
Note the -15 in the command. From the graph, using the mouse, we observe that the equation has two solutions (can be proved more rigorously), one between -5 and -4, and the other between 3 and 4. So we can obtain the two solutions using
fsolve( 7*cos(x) + x + x^2 = 15, {x}, x=-5..-4 ); 
fsolve( 7*cos(x) + x + x^2 = 15, {x}, x=3..4 );
When using fsolve it is important to choose an interval which contains only the solution one wants. The narrower the interval the better. Finally, to complete the solution of the problem we must show somehow (using pencil and paper) that has no solutions outside .

We now try to find all solutions of the system of equations and . If we try

solve( {x^2 + y^2 = 4, sin(x+y) + cos(x) = 1}, {x,y} );
then Maple is unable to find the exact solutions. However, plotting these two curves using
with(plots);    unnecessary if already done once this session
implicitplot( {x^2 + y^2 = 4, sin(x+y) + cos(x) = 1}, x=-3..3, y=-3..3 );
we note (using the mouse) that the system has two solutions one near and the other near . Note that the system will not have any solutions outside the recatngle - why? To find these solutions more accurately use
fsolve( {x^2 + y^2 = 4, sin(x+y) + cos(x) = 1}, {x,y}, x=-2..0, y=0..2 );
fsolve( {x^2 + y^2 = 4, sin(x+y) + cos(x) = 1}, {x,y}, x=0..2, y=0..2 );
Note the ranges for x and y were chosen carefully. Using the graph, they were chosen to include one solution at a time.

Finally, note that this graphical technique of obtaining the rectangle containing the solution we want fails in three and higher dimensions (i.e. solving k equations in k unknowns with ) because the graphs are hard to visualize in three dimensions and non-existent visually in higher dimensions. However, fsolve will still work. e.g.

fsolve( {x^2 + y^2 + z^2 = 4, x+y+z=0, x*sin(y*z)=-1},   hit Line Feed key
        {x,y,z}, x=-2..2, y=-2..2, z=-2..2 );
does give one solution of the system of equations, but is it the only one? How do we find others if there are any?



next up previous
Next: Long Command Lines Up: COMMANDS FOR MATH Previous: Solving Equations Exactly



Peter Monk
Tue Aug 29 14:41:29 EDT 1995