> f := x-> 2*x^3-5*x^2-2*x+5; > solve(f(x)=0,x);If you forget to type in an equation and only type in an expression without setting it equal to something, Maple automatically sets the expression to zero. In the examples below, you can see some of the solving capabilities of Maple.

> plot({x^2+2*x-1,x^2+1},x=-2..2); > solve(x^2+2*x-1=x^2+1,x);Unfortuately, many equations cannot be solved analytically. For example, even the relatively simple equation sin(x) = x/2 has no analytical solution. In this case, the only possibility is to solve it numerically. In Maple, the command to use is

> solve(sin(x)=x/2,x);This is not incorrect, as some of the zeros of a function may be imaginary and others may be real. However, it is much better to solve numerically as shown below:

> fsolve(sin(x) = x/2, x);A plot of both equations on the same graph will show that this solution is not complete. There are two other intersection points that the

> plot({sin(x),x/2},x=-2*Pi..2*Pi); > fsolve(sin(x)=x/2,x=-3..-1); > fsolve(sin(x)=x/2,x=-1..1); > fsolve(sin(x)=x/2,x=1..3);Once you have solved an equation, you may want to use the output or the solution later. In order to label the output to a solution, you need to assign a label in the same line as the

> expr2:=x^2+2*x-5; > answer:=solve(expr2=0,x); > evalf(subs(x=answer[1],expr2));Here an expression was defined first and then the solution was assigned to the label ``answer''. Note that there was more than one solution. In order to substitute tha answer that was listed first back into the expression, the

> solve({3*x+5=y,7*x+9*y=14},{x,y});As an additional example, suppose you wanted to find the equation of the parabola that went through the points (-3, 2), (19, -19), and (0, -2.397). The first step is to set up a general equation for a parabola. the idea is to find the values of a, b, and c.

> p:=y=a*x^2+b*x+c;The next step is to set up your three equations by using the three points on the parabola.

> eq1:=subs({x=-3,y=2},p); > eq1:=subs({x=19,y=-19},p); > eq1:=subs({x=0,y=-2.397},p);The next step is to solve for a, b, and c.

> solution:=solve({eq1,eq2,eq3},{a,b,c});We can get an equation for our parabola with the following substitution:

> parabola:=subs(solution,p); > with(plots):implicitplot(parabola,x=-20..80,y=-20..35);

Also, recall that not all the equations can be solved analytically. When the **solve** command yields a strange looking answer, it does not necessarily mean that there are no solutions. You may have to solve the equations numerically by using the **fsolve** command. However it does not always yield all solutions at once. If your plot indicates that you have more intersection points than what the **fsolve** command has shown, then you must solve for each solution separately using ranges of x and y to tell Maple where to look for the solutions. Suppose we want to find the intersection points of and . You would find that if you try to use the **solve** command you would get an answer involving *Root of...*. One way to get around this complex output is to solve numerically in Maple using **fsolve**.

> plot(x^2-4*x-2,3*sin(x)},x=-5..5);The plot shows that there are two intersection points. The

> fsolve({y=x^2-4*x-2,y=3*sin(x)},{x=-2..0,y=-10..10}); > fsolve({y=x^2-4*x-2,y=3*sin(x)},{x=0..5,y=-10..10});Note the ranges used for the x and y values in the second argument of the

This last example shows a similar procedure using the implicit equations. Suppose we want to know where the graph of the equation
intersects with the graph of . First a plot would be necessary to determine the number of intersection points, then the **fsolve** command can be used with ranges specific to x and y.

> with(plots): > implicitplot({x*y-y^2+2=2*x^2-1,x/y+y=x*y},x=-5..5,y=-5..5); > fsolve({x*y-y^2+2=2*x^2-1,x/y+y=x*y}, {x=-2..0, y=0..1}); > fsolve({x*y-y^2+2=2*x^2-1,x/y+y=x*y}, {x=-2..0, y=-1..0});

- For the functions

- First enter the two as functions.
- Plot the two on the same graph using an x-domain that clearly shows all the intersection points.
- Find the x-values of the intersection points assigning a label to each.
- Find the y-values of the intersection points. Check that both functions give you the same y-values for a single x-solution.
- What are your intersection points?

- The general equation of an ellipse is

Find the equation of the ellipse that pases through the two points and . Use the**implicitplot**command to plot the ellipse. (Hint, all four of the solutions that you get will give the same equation due to the squaring in the equation). What is the equation of the ellipse that you found?

2005-01-21