Professional Documents
Culture Documents
html )
This Tutorial has been designed by the Mathematics Department at Seattle Central Community College, to give you a complete hands-on introduction to the basic commands that you will need to use Maple effectively. The six sections of the tutorial will step you through each topic with many opportunities for you to practice and experiment with Maple. Note: This tutorial was developed to provide a thorough and efficient introduction to Maple for students about to enter a Calculus course. Therefore the tutorial only assumes familiarity with mathematics at the precalculus level. Each section of the tutorial has the same basic outline: Examples : a sequence of short, completely worked out examples that illustrate each new command. Exercises : short practice problems based on the material from the section. When you have worked through Sections 1-6 continue on to the Practice Problems. These problems will give you an opportunity to try out the full range of Maple commands that you have learned in the Tutorial. By the time you complete these problems you will be ready to use Maple effectively in your math class. At the end of the tutorial you will find a section entitled "Maple Quick Reference Card" . You may find it convenient to print out the contents of this section so that you can have a convenient reference to the syntax of the commands that you will learn in the tutorial. The Sections 1 - 6 of the tutorial focus on essential Maple commands. For details on the worksheet interface see the last section Notes on the Worksheet Interface.
Table of contents
Section 1: Section 2: Section 3: Section 4: Section 5: Section 6: Numerical Calculations Algebraic Calculations Graphing Solving Equations Functions: Defining, Evaluating and Graphing More on Graphing
type Pi.
Notice that an asterisk * is required to indicate multiplication. > 4*(3+Pi); Again Maple carries out the calculation but leaves the answer in exact form.
Example 6: Unlike your calculator, Maple gives you the exact answer when applying trigonometric functions. > sin(5*Pi/3); > sec(Pi/4); To get the inverse sine of a number use the arcsin( ) function: > arcsin(-1); If you ask Maple to calculate a value that is undefined it will respond with an error message: > tan(Pi/2); Example 7: in Maple type: exp(x) . To enter the natural exponential function > exp(x); And to get the number e by itself type: exp(1) . > exp(1); > Example 8: To enter the absolute value function in Maple type: abs(x). Note that Maple gives the correct, exact answer for the third line since: > abs(x); > abs(-3); > abs(exp(1)-Pi); Example 9: Maple has many special purpose commands for working with numbers. You will learn these as you need them in your math course. Here is one last example for now. If we have an integer and want to factor it into primes we can use Maple's ifactor( ) command. Feel free to experiment by changing the number. > ifactor(31722722304); > Example 10: There may be times when you want to enter more than one command on a single line. This is okay to do in Maple, just be sure to end each command with a semicolon. It also helps to put spaces between the commands. When you press [Enter] all of the expressions are executed and the results are listed, in order, in a single output field. > sin(Pi/3); cos(Pi/3); tan(Pi/3); > Example 11: To calculate and display a sequence of numbers use the seq(..) command. Here we calculate the squares of the first 100 natural numbers. > seq(k^2,k=1..100); >
Example 5: We can apply the evalf( ) command to a sequence of numbers. Below we first generate the exact square roots of the first 10 natural numbers, then apply evalf to get decimal approximations. > result:=seq(sqrt(k),k=1..10); > evalf(result); > Maple Shortcut: Quick reference to last output There will be many times when using Maple that you will string together a sequence of computations. Rather than giving a name to each result as you go along, you can use the percent sign ( % ) to refer to the last expression computed by Maple. Here are some examples of how it works. > 3/5+5/9+7/12; > evalf(%); > Pi; > evalf(%); > %+5; > For more on using the ditto symbol see Exercise 1.4 below. Exercise 1.1 Use Maple to calculate the number Answer 1.1 > 37^43; .
Exercise 1.2 to 18 digits. Calculate Answer 1.2 > m:=sqrt(34); > evalf(m,18); > Exercise 1.3 Find a numerical approximation for the expression : Answer 1.3 > answer:=(3+Pi)/(7-sqrt(13)); > evalf(answer);
Exercise 1.4 The percent sign ( %) is a handy shortcut but it can occasionally lead to some unexpected results. Here is an example. First execute each of the next three lines. You should be able to predict the result in advance. > 4+Pi; > evalf(%); > %+10; > Now go back and re-execute the last line (i.e.%+10;). Note that the output changes from to Can you explain why? Answer 1.4 The ditto symbol (%) represents the last number calculated by Maple. So after you executed the first three lines %= . The second time you executed the line %+10; Maple added 10 to . To avoid this sort of confusion assign names to each output: > a:=4+Pi; > b:=evalf(a); > b+10; >
Clearing Variables
Once you have defined a variable, Maple will remember its value during your entire working session. If you want to overwrite the variable with a new value, you can simply make a new assignment. For example each assignment below redefines the value of the variable h. (Note: to check the current value for a variable just type it followed by a semicolon.) > h; > h:=56; > h; > h:=sqrt(Pi); > h; Sometimes you will want to "clear" a variable in memory so that you can use it in a new situation. Here is an example. First we assign x the value 65. > x:=65; Now assume that we start a new problem and want to enter the general algebraic expression and assign it the name w. If we just enter this, Maple automatically substitutes the previous value for x.
> w:=x^2-4*x+7; In order to get x to be a general variable again we must first "clear" (i.e. erase from Maple's memory) our earlier value for x. This is accomplished by entering x:='x'; Note that we use single quotes here. Execute the next two lines to see how this works. > x:='x'; > w:=x^2-4*x+7; Clearing all variables at once: the restart command. The restart command will clear Maple's memory of all definitions that you have made. It is like starting a new Maple session. If you are starting a completely new problem you can use the restart command to guarantee that there are no leftover definitions from your earlier work. Before you execute the second line below, quickly predict the output. > p:=4; > p; x; h; You probably remembered that p was 4 and x had been reassigned to be the variable x, but you may not have remembered that h was assigned the value . That's why it's a good idea to use restart to remove all definitions at once. (As you work through this tutorial you will notice that we start most new sections with a restart command.) > restart; > p; x; h; >
Example 4: You can also use the subs( ) command to substitute a value into an equation. This is the sort of thing you might want to do to test whether a particular value "satisfies" the equation. In the next few lines we substitute different values into the equation . Are any of these values a solution to the equation? Note we use " := " to assign the name and just "=" for the equation itself. > eqn:=x^3-5*x^2+7*x-12=0; > subs(x=3,eqn); > subs(x=4,eqn); > subs(x=5,eqn); > Exercise 2.1 Assign the name k to the expression expression . . Then assign the name M to the
Finally have Maple calculate . Note: to get Maple to multiply the expression out use the expand( ) command. That is enter: expand(3*M+6); You will learn more about the expand command in the next subsection. Answer 2.1 > k:=x^2+4*x-3; > M:=k^2-9; > 3*M+6; > expand(3*M+6); > Exercise 2.2 Expand using the expand( ) command. Answer 2.2 > w:=(1+x)^4; > expand(w); or we can do this all in one step with: > expand((1+x)^4); > Exercise 2.3 Let . Answer 2.3 > P:=a*x^3+b*x^2+c*x+d; > subs(x=0.01,a=-1/5,b=2/5,c=0,d=13/15,P); . Find P if x = 0.01 , a = , , , and
Exercise 2.4 Use the subs( ) command to check if any of the numbers: 1,2 or 3 is a solution to the equation: Answer 2.4 > eqn:=x^3-16*x^2+51*x-36=0; > subs(x=1,eqn); > subs(x=2,eqn); > subs(x=3,eqn); > Therefore x=1 and x=3 are solutions of the equation. (In Section 5 you will learn how to solve equations using Maple.)
command to the result. Can you explain why the final result looks different than the original expression ? > H:=2*(x-2)*(2*x^2+5*x+2)*(x+4); > ans:=expand(H); > factor(ans); Example 3: Maple can factor expressions with more than one variable. Factor the expression: > h:=x^2*y+2*x*y+y; > factor(h); Example 4: If Maple can't factor an expression using rational numbers (i.e. integers and fractions) then it returns the input unchanged. > factor(3*x^2-10*x-9); Example 5: The factor command is not limited to polynomials. It can be used to factor other forms. . Factor > factor((sin(x))^2-(cos(x)^2)); Example 6: If the factor command is used with a rational expression, the numerator and denominator are each factored and common factors are cancelled to simplify the expression: > A:=(x^3-7*x^2+15*x-9)/(x^2+4*x+4); > factor(A); > B:=(x^3-7*x^2+15*x-9)/(x^2-4*x+3); > factor(B); The next example allows you to see the factored form without cancellation.
Example 7: Maple's numer( ) and denom( ) commands allow you to isolate either the numerator or denominator of a fraction. Here we use these commands to examine the factors of the numerator and denominator separately (i.e. before cancellation of common factors). > B:=(x^3-7*x^2+15*x-9)/(x^2-4*x+3); > factor(numer(B)); factor(denom(B)); Exercise 2.8 Factor the expression Answer 2.8 > factor(3*x^4-2*x^3+22*x^2-18*x-45); Exercise 2.9 Factor the expression Answer 2.9 > ww:=x^(1/2)-x^(3/2); > factor(ww); > expand(%); and then use the expand command to check the result. .
apply identities to simplify many lengthy mathematical expressions, such as trigonometric expressions. > V:=cos(x)^5 + sin(x)^4 + 2*cos(x)^2 - 2*sin(x)^2 cos(2*x); > simplify(V); Example 2: Trigonometric expressions with arguments in multiples of some angle will be simplified to trig functions in the single angle if possible: > simplify(sin(5*t)+sin(3*t)); Example 3: The simplify( ) command can be used to add rational expressions. Rewrite the sum as a single fraction.
> M:=(1/(x+1))+(x/(x-1)); > simplify(M); > Exercise 2.11: Simplify the expression
Answer 2.11 > simplify(7/(x+2)+(3*x)/(x+2)^2); Exercise 2.12 How does Maple simplify ? Whether or not this "simplified" form is of use to you will depend on what you plan to do with it. Answer 2.12 > h:=sin(3*t)-sin(7*t); > simplify(h); >
Section 3: Graphing
In this section you will learn how to plot the graph of a function defined by an expression. Other topics covered include: combining the graphs of several expressions into a single plot, plotting points, and combining different plot structures into a single picture. > restart;
> Notice that Maple scales the y-axis automatically, choosing a y-scale that shows the entire graph corresponding to the specified domain. You can override automatic y-scaling by specifying a range for y as well as x. On the next line we have limited the y-range to the interval [-20,40]. > plot(3*x^2-8,x=-5..5,y=-20..40); > If you click on a graph with the left mouse button, the graph is selected and the bottom toolbar options are changed. See the reference diagram below. Now when you click on the graph, the point coordinates of its location are shown. The 1:1 button makes the x-scale and y-scale equal. Scroll back up to the previous graph and experiment with these features. Try the other graph options as well.
Example 2: Automatic scaling is a useful feature but there are times when you may want to set the y range manually. For example automatic scaling isn't appropriate for graphs with vertical asymptotes. Compare the next two graphs. Notice how we have set the limits for y to the interval [20,20] in the second plot command. > plot(x/(x-2),x=-5..5); > plot(x/(x-2),x=-5..5,y=-20..20); Example 3: Plot the graph of to see the four x-intercepts.
First let's take a look at the plot with automatic scaling of y. > plot(x^3+1-exp(x),x=-8..8); The large negative values for y near 8 have forced the vertical scale to be too large to see the x-intercepts clearly. A better view is achieved by setting limits on the y-range. > plot(x^3+1-exp(x),x=-8..8,y=-5..15); Exercise 3.1 Plot y = sin(x) over two complete periods. Answer 3.1 > plot (sin(x),x=-2*Pi..2*Pi); Exercise 3.2 Plot over the domain [-10,10] with automatic y scaling. After observing the
graph, edit the domain and range so that you can see the x-intercepts clearly. Estimate the x-intercepts with the mouse cursor. Answer 3.2 > plot(3*x^4-6*x^2,x); Notice how large y becomes when x = -10 or x = 10; with automatic y scaling it is difficult to see how the function behaves for x between -2 and 2. In the next plot we restrict the y scale in order to better observe the behavior for small y outputs. > plot (3*x^4-6*x^2,x=-3..3,y=-5..15); The x-intercepts are about -1.4, 1.4 and 0.
Exercise 3.3 Graph the functions and together. Experiment with different
y ranges so that complete pictures of both graphs are shown. Answer 3.3 > y1:=x^2-5*x+6; > y2:=1/(x-2)^2; > plot([y1,y2],x=-3..8,y=-1..6);
Plotting points
The plot command can also plot one or more points. Example 1: Plot the point (2,3) . Note in the following line that we use two sets of square brackets. > plot([ [2,3] ],style=point); Example 2: We can control the size of the x and y ranges shown by adding these to the command as in the next line. > plot([ [2,3] ],x=-7..7,y=-7..7,style=point); Example 3: To graph more than one point list them in the plot command. Note the commas. Remember square brackets for each point and an extra pair of square brackets surround the list. > plot([ [2,3],[-2,5],[1,-4] ],x=-7..7,y=-7..7,style=point); Example 4: Changing style to "line" connects the points in the order listed. > plot([ [2,3],[-2,5],[1,-4] ],x=-7..7,y=-7..7,style=line); Example 5: Optional extensions can be used to specify point color and symbol (e.g. diamond, circle, cross is default) to indicate the points. > plot([[3,2],[-2,3],[2,1]],style=point,color=blue,symbol=circle); Exercise 3.4 Plot the following points using the color red and the diamond symbol: [1,4] , [-2,-3], [4,-5] and [-6,5] . Then connect the points with lines in a separate plot command. Answer 3.4 > plot([[1,4],[-2,-3],[4,-5],[6,5]],style=point,color=red,symbol=diamond);
> plot([[1,4],[-2,-3],[4,-5],[6,5]],style=line,color=red,symbol=diamond);
marked with circles. Answer 3.5 > pict4:=plot(x^2+x-6,x=-5..4,y=-8..8): > pict5:=plot([[0,-6],[3,0],[2,0]],style=point,symbol=circle, color=blue): > display([pict4,pict5]);
use the
solve( ) command. Note that the second argument of the command tells Maple that x is the unknown variable that we are solving for. > solve(3*x^3-4*x^2-43*x+84=0,x); Here Maple has found all three solutions and listed them for you. Example 2: Sometimes you will want to select one solution from the list of solutions and use it in another computation. You can do this by first assigning a name (we use the letter N in this
case) to the output of the solve( ) command. Then N[1] is the first number in the list, N[2] is the second number and so on. Note the square brackets. > N:=solve(x^2-5*x+3=0,x); > N[1]; Example 3: When working with the solve( ) command it is often convenient to begin by giving a name to the equation. Note we use " := " to assign the name and just "=" for the equation itself. > eqn1:=7*x^3-11*x^2-27*x-9=0; Next we solve the equation using the solve( ) command assigning the name H to the output. > H:=solve(eqn1,x); For practice let's check that each of these values satisfies the equation. This is easy to do using the subs( ) command. > subs(x=H[1],eqn1); > subs(x=H[2],eqn1); > subs(x=H[3],eqn1); Example 4: Sometimes the "exact" solutions are too cumbersome to be of much use. In the next two lines we solve the equation . > eqn1:=x^3-34*x^2+4=0; > H:=solve(eqn1,x); As you can see, reading these exact solutions is quite a challenge! Note that the I stands for . When a solution is this complicated it is more useful to look at the approximate solutions using evalf( ): . > evalf(H); A good alternative to the solve( ) command in a situation like this is the fsolve( ) command which will be discussed in the next section. The solve( ) command can also be used to find the exact solutions for non-polynomial equations. Some simple examples are listed below. However if the equations are at all complicated, for example combining exponential, polynomial and trigonometric expressions, then an exact solution will typically not be available. Again the fsolve( ) command is an alternative. Example 5: Solve the equation: > solve(5*exp(x/4)=43,x); Example 6: Sometimes Maple does not display all of the solutions. How would you use the result below to write down the entire set of solutions to the equation? > solve(sin(x)=1/2,x);
Exercise 4.1 Solve the equation Why does Maple produce only two
distinct solutions for this cubic equation? Why is one of them written twice? (HINT: Factor the left hand side of the equation.) Answer 4.1 > solve(x^3-11*x^2+7*x+147=0,x); > factor(x^3-11*x^2+7*x+147); The fact that x - 7 is a repeated factor results in the cubic equation having only two distinct roots, -3 and 7. We say that root 7 has a multiplicity of 2, meaning there are two factors of (x - 7) in the factored polynomial.
Maple returns one real solution. This time Maple has not given us the whole story. Are there any other solutions? How do we find them? A systematic procedure for finding the remaining solutions is presented in Example 3. Example 3: Find the other real solutions for the equation
The first step in finding the other solutions is to plot a graph of the left-hand side of the equation. Key Concept: Recall that the x-intercepts of correspond exactly to the solutions of the equation .
> plot(x^3+1-exp(x),x=-3..5,y=-5..15); The graph shows four x-intercepts. One of these corresponds to the solution we found in Example 2. Which one? The x=0 solution is also easy to spot. How do we find the other three? We can extend the fsolve( ) command to look for a solution in a particular interval. For example to find the negative solution we ask Maple to search on the interval since we can see from the graph that there definitely is one (and only one) solution on that interval. > fsolve(eqn,x=-1..-.2); To find the other two solutions we use fsolve( ) again, this time with search interval [1,2] and then with interval [4,5]. > fsolve(eqn,x=1..2); fsolve(eqn,x=4..5); What happens if you ask Maple to search for a solution on an interval where no solution exists ? Let's try it out. From the graph it is clear that there are no x-intercepts (and therefore no solutions) between 2 and 4. > fsolve(eqn,x=2..4); Notice that Maple simply returns the original input line unchanged when it cannot find a solution on the given interval. Are there any other solutions? For example, are there any solutions larger than 5 ? We can check this out by expanding the interval over which the graph is plotted. On the next line we expand the interval to [-3,50]. No other x-intercepts appear. The graph confirms what we should expect by looking at the terms of the expression, namely the exponential term dominates and causes the graph to go down in the long run. > plot(x^3+1-exp(x),x=-3..50,y=-10..15); Alternatively we can use the fsolve( ) command, now searching over this larger interval. > fsolve(eqn,x=5..50); As expected no solutions are found by Maple. In a similar way we can check for solutions to the left. Here we search for solutions over the interval [-50,-1] . > fsolve(eqn,x=-50..-1); None there either ! We now have a complete list of the four solutions of our original equation They are: -.8251554597 , 0 , 1.545007279 and 4.567036837 Example 4: Use fsolve( ) to find the approximate solutions of the equation :
Just as in the last example we will use a graph to help us determine the number and approximate location of the solutions. Our task is simplified if we start by converting the given equation to an equivalent one that has zero on the right-hand side. So we will solve the equivalent equation :
If we now graph the left-hand side of this equation we once again will find solutions at each of the x-intercepts. > eqn:=x^2/20-10*x-15*cos(x+15)=0; > plot(lhs(eqn),x=-10..10); From the graph it appears that there is a solution on the interval [1,2]. We now direct Maple to search for a solution on this interval. > fsolve(eqn,x=1..2); Have we found all of the solutions to this equation? In fact there is another solution! To find it start by expanding the interval over which the graph is drawn. Then use fsolve( ) to find a numerical approximation for this second solution. Exercise 4.2 Find all the solutions to the equation . Begin by looking at a
relevant graph. Answer 4.2 We begin by graphing the left-hand side of the equation. > eqn:=x^5-4*x^3+3*x^2+7*x-1=0; > plot(lhs(eqn),x=-5..5,y=-5..5); This picture indicates that there are solutions near -2 , -1.5, and 0. We next try the unrestricted fsolve command to see which solution(s) Maple finds. > fsolve(eqn,x); Since this is a polynomial equation the fsolve( ) command gives us a complete list of the real solutions. Exercise 4.3 Find all the solutions to the equation . Use the graph of one expression to
locate the solutions. Check each solution by substituting it back in the original equation. Answer 4.3 First we put the equation in "standard form" , i.e. with zero on one side. > eqn:=x^2-2-ln(x+5)=0; Now we can graph the right-hand side equation. > plot(lhs(eqn),x=-10..10); There appear to be two solutions. One near -2 and the other near 2. Use fsolve with a restricted domain to find the two solutions you've located more precisely. > soln1:=fsolve(eqn,x=-5..0); > soln2:=fsolve(eqn,x=1..3); Check by subsituting back into the original equation. > evalf(subs(x=soln1,eqn));
> evalf(subs(x=soln2,eqn)); Notice that the original equation is only "approximately" satisfied by each of our solutions. The slight discrepancy is a result of round-off error in the approximate solutions. Check that there are no additional solutions. Exercise 4.4 The graphs of and intersect twice on the interval [-5,5].
a) Graph the two equations together and estimate the intersection points using the mouse. b) Write an equation that can be solved to find the x-coordinates of the intersection points. c) Use fsolve( ) to solve this equation. d) Use the results from part c) to estimate the y-coordinates of the intersection points. e) It appears that the curves may intersect at a third point near (1,9). Use fsolve( ) and/or a relevant graph to demonstrate that there is no intersection point at that location. Answer 4.4 > y1:=10-x^2; > y2:=4*sin(2*x)+5; Here is a plot of the two equations. > plot([y1,y2],x=-5..5); Intersection points are located approximately at: (-1.8, 6.6) and ( 2.75, 2) . b) The equation to solve is y1=y2. > eqn:= y1=y2; c) We now find the two solutions using fsolve( ) > x_soln1:=fsolve(y1=y2,x=-4..0); > x_soln2:=fsolve(y1=y2,x=0..4); d) We can use the subs( ) command to find the corresponding y-coordinates. > y_soln1:=subs(x=x_soln1,y1); > y_soln2:=subs(x=x_soln2,y1); So the points of intersection are : (-1.800,6.763) and (2.773,2.311) e) Here is a closer look at what is happening near x=1. > plot([y1,y2],x=.5..1.5); Alternatively we can use fsolve( ) to confirm that there is no solution near x=1. > fsolve(y1=y2,x=.5..1.5);
Answer 4.4 > T=solve(4-v=2*T-k*g,T); > k=solve(4-v=2*T-k*g,k); > v=solve(4-v=2*T-k*g,v); Exercise 4.5 Solve the equation for y. Assign the set of solutions to a variable named S. How are the two solutions S[1] and S[2] related ? Answer 4.5 > S:=solve(x^2+y^2=25,y); > S[1]; > S[2]; The solution S[1] is the negative of solution S[2].
Check by subsitituting the solution pair in both equations in the system Answer 4.6 > eqns:={4*x+3*y=12, 5*x-7*y=35}; > ans:=solve(eqns); > subs(x=189/43,y=-80/43,eqns);
>
Once you have defined a function, Maple will remember that function during your entire working session. If you want to overwrite the function with a new definition, you simply retype the definition. For example, if you want to replace the function f(x) above with ln(cos 5x), type: > f:=x->ln(cos(5*x)); We can confirm the current value for the function f(x) : > f(x); If you want to clear the function f(x) without redefining it, type: > f:='f'; It's always a good idea to clear your functions when you start a new problem. Alternatively you can use restart to clear everything from memory.
Evaluating a Function
Once a function has been defined, you can evaluate it at various values or literal expressions using function notation. It's always a good idea to clear the function name first before entering a new function. > f:='f'; > f:=x->3*x+x^2; > f(-1); > f(2+sqrt(5)); > evalf(f(2+sqrt(5))); > f(x+4); > simplify(%); > (f(x+h)-f(x))/h; > simplify(%); If more than one function is involved, composing functions is easy to do. > g:=x->cos(x)+1; > f(g(Pi/3)); > j:=x->g(f(x)); > j(x); Exercise 5.2 Exercise 2 : Define the function then have Maple calculate
s(2),and s(t-3) and s(t) - s(3) and simplify your results. Don't forget the arrow notation! Answer 5.2 > s:= t-> (3 + t^2)/(sqrt(3*t+1)); > s(2); > s(t - 3); > simplify (%); > s(t) - s(3); > simplify(%); Notice that if you define a function, there is no need to evaluate the function using the "subs" command like you do with expressions.
Graphing a Function
The plot function works the same for functions: > h:='h'; y:='y'; x:='x';
> h:=x->x*exp(-x); > plot(h(x),x=-1..4,y=-2..1); Several functions can be graphed simultaneously just at we did for expressions. Consider the function horizontal shifts , . Below we graph this function along with the and . Can you identify each ?
> f:=x->2/(x^2+1); > plot([f(x),f(x+1),f(x-3),f(x-6)],x=-5..10,y=-1..3); Exercise 5.3 Define the function then answer the following questions.
a) Find the value of f(6.5) b) Simplify the expression f(z-4) where z is a variable c) Plot a graph of f(x) d) Find all values of x such that f(x)=0. Answer 5.3 > f:=x->2*x-abs(x^2-5); > f(6.5); > simplify(f(z-4)); > plot(f(x),x); > fsolve(f(x)=0,x=0..2); > fsolve(f(x)=0,x=3..4); Exercise 5.4 Define the functions and then do the following.
a) Plot a graph that shows both functions g(x) and h(x). Experiment with different values for domain and range. b) Estimate the coordinates of the point of intersection of these two graphs by using left mouse-button click. c) Use fsolve( ) to solve the equation g(x)=h(x). How does the solution of this equation relate to your answer to part (b). > Answer 5.4 > g:=x->5*exp(-0.5*x); > h:=x->x+1; > plot([g(x),h(x)],x=-5..5,y=-20..20); > plot([g(x),h(x)],x=1..2,y=1..4); > xval:=fsolve(g(x)=h(x),x);
The solution to g(x)=h(x) is the x-coordinate of the point of intersection of g(x) and h(x). To find the corresponding y-coordinate of the intersection point evaluate either g(x) or h(x) at this value. > g(xval); > h(xval); Exercise 5.5 Define the function , then do the following: a) Plot the graph of this function on the domain [-1,8] . b) Modify your plot from part (a) to include the horizontal line y=4. Use this new plot to estimate the number and approximate values for x such that k(x)=4. c) What single function could you graph that would give you the same information as in part (b) d) Use Maple's fsolve( ) command to approximate all solutions to the equation k(x)=4. Answer 5.5 a) > k:=x->x+3*sin(2*x); > plot(k(x),x=-1..8); b) > plot([k(x),4],x=-1..8); There appears to be three intersection points at x=3.25 ,4.825 and 5.95 . > c) We could graph k(x) - 4 and look for x-intercepts. These will correspond to x-values found in part (b). > plot(k(x)-4,x=-1..8); Here are the solutions using fsolve( ) : > fsolve(k(x)=4,x=2 .. 3.5); > fsolve(k(x)=4,x=3.5 .. 5); > fsolve(k(x)=4,x=5 .. 7); >
Parametric Equations
Maple's plot( ) command can also be used to graph curves described by parametric equations. To graph the parametric curve corresponding to the pair of parametric equations: x=f(t) and y=g(t) on the parameter interval [a,b] use the command: plot( [ f(t) , g(t) , t=a..b] , x=xmin..xmax, y=ymin..ymax); There are two things to take careful note of here. First note that there are three entries in the square brackets : the two parametric expressions for x and y and the parameter domain. Also note that the viewing window for the plot is separately specified by the x and y ranges (i.e. x=xmin..xmax, y=ymin..ymax ) . Example 1: Plot the parametric curve determined by . > plot([t^2-t,2*t-t^3,t=-2..2],x=-2..5,y=-5..5); Exercise 6.1
and
Implicit Plots
Maple can plot curves that are implicitly defined by an equation in the variables x and y. Example 1: To plot the graph of the hyperbola given by the equation: use the implicitplot(
) command. To use this command we must first load the "plots" library using the "with" command. > with(plots): Note the syntax for this command on the next line. > implicitplot(x^2/4-y^2/4=1,x=-5..5,y=-5..5); > Example 2: Graph the equation using the implicitplot( ) command.
Recall that this is the equation of an ellipse with the lengths of major and minor axes equal to 10 and 6 respectively. Our first attempt at getting the expected graph comes up short ! > implicitplot(x^2/25+y^2/9=1,x=-5..5,y=-5..5);
Why did we get a circle instead of an ellipse ? The problem here is that the x and y scales are not equal. To force equal scaling add "scaling=constrained" . > implicitplot(x^2/25+y^2/9=1,x=-5..5,y=5..5,scaling=constrained); > Exercise 6.2
Plot Options
There are many options available when you use the plot command. To see a list execute the next line to go directly to Maple's Help Page on this command. Skip this if you wish. > ?plot[options]; >
Practice Problems
Problem No. 1
Assign the name w to the number approximation for the following: and then find the exact value and a decimal and .
Problem No. 2
Factor .
Problem No. 3
Enter the function Then find the approximate value of
Problem No. 4
Find the approximate value of T in the formula when a=4.6 , b= -3.8 and c=2.9
Problem No. 5
If , find and simplify , .
Problem No. 6
When multiplied out the expression What is the coefficient of the term ? equals a fifth-degree polynomial.
Problem No. 7
Plot the expressions and . on the interval . Then plot these same expressions on the interval
Problem No. 8
Plot the function on the interval . Automatic scaling does not produce a useful picture. Specify a y-range that gives a good view of this function on this interval.
Problem No. 9
Recall that if a rational number has an infinite decimal expansion then somewhere in the expansion the digits must repeat. A familiar example is the decimal expansion of the fraction = .33333... where we have the digit 3 repeated. A bit more interesting is the = 2.3571428571428... with the repeating digits 571428. Now . Can you identify the repeating sequence.
Problem No. 10
a) Plot the following points on a graph: ( 1, 0.53) , (1.5, 0.65) , (2, 0.91) , (2.5 , 0.95) and (3, 1.10 ) b) Create a single picture that has the points above plus graphs of the functions : and .
Use your picture to decide which of these two functions most closely fits this set of points ?
Problem No. 11
Approximate all real solutions of the equation .
Problem No. 12
Approximate all real solutions of the equation .
Problem No. 13
The graphs of and intersect at one point. Use the numerical solving capabilities of Maple to approximate the coordinates of this intersection point. Start by entering an appropriate equation to solve.
Check your answer by creating a picture that shows the graphs intersecting.
Problem No. 14
Solve for r in the equation : . Be sure that you have
entered the equation correctly. In particular check that you have used an * for every mulitplication.
Numercially evaluates the given expression to n digits Expands the given expression Factors the given expression Finds numerical (approximate) solutions to equations. fsolve(x^2=cos(x)+4,x=0..5) ifactor(n) Gives prime integer factorization for a given integer lhs(eqn ) Selects the left hand side of an equation implicitplot( ) Plots implicitly defined functions implicitplot(x^2/25 +y^2/9=1 , x=-5 . . 5,y=-5 . . 5,scaling=constrained); numer( ) Selects the numerator of a fraction plot( ) Plots functions defined by an algebraic expression: plot(3*x^2-8 , x=-5 . . 5 , y = -20 . . 40 ); Plots more than one function at a time: plot( [ 3*x^2-8 , sin(x) , cos(x) ] ,x=-5 . . 5 , y=-20 .. 40 ); Plots points: Plots parametric equations : plot( [cos(t), sin(t), t=0 . . 2*Pi] , x=-2..2, y=-2..2); rationalize(expr) Rationalizes the denominator of a given expression restart Clears Maple's memory of all definitions rhs(eqn ) Selects the right hand side of an equation simplify(expr) Simplifies the given expression solve(eqn) Finds exact solutions to equations, including literal equations and linear systems. subs(x= v,expr) Substitutes the value v for x in the expression subs(x=4,3*x^2+8); with( ) Brings in additional libraries of functions. The standard constants are: Caution: Do not use "pi", capital "P" is required Pi exp(1) I The names of the standard functions are: sqrt(x)
abs(x) exp(x) ln(x) natural log log(x) common log (base 10) sin(x), cos(x), tan(x), cot(x), sec(x), csc(x) arcsin(x), arccos(x), arctan(x) >