| > |
Plotting with Maple
Maple has a powerful set of graphing tools. The two with commands below load in the graphing commands we need. The restart clears the memory. We shall start each section with these three commands. (Change the colons to semi-colons and notice the effect.) Ignore the warning statements.
| > | restart; |
| > | with(plots): |
Warning, the name changecoords has been redefined
| > | with(plottools): |
Warning, the assigned name arrow now has a global binding
We can define a function f(x) as follows:
| > | f := x -> x*sin(x); |
| > | f(2); |
That was not too information. To get the result in floating point format we use the evalf command:
| > | evalf(f(2)); |
Now we do a simple plot of f(x).
| > | plot(f(x),x=-3*Pi..3*Pi,y=-5..10, color=black,thickness=2); |
![[Plot]](images/plotting_4.gif)
Graphs can be overlayed. Here is the function y=x sin x together with the tangent line at (pi,0).
| > | plot([f(x),Pi^2-Pi*x],x=-10..10,y=-10..10,discont=true,color=[red,blue],thickness=2);
|
![[Plot]](images/plotting_5.gif)
Next we do a rational function.
| > | g := x -> (x+1)/(x-3); |
| > | plot(g(x),x=-5..5,y=-10..10,color=black,thickness=2); |
![[Plot]](images/plotting_7.gif)
Maple does not understand vertical asymptotes. But it will know what do do if we give it hint! The option "discont=true" tells Maple that the function may have discontinuities. Then Maple will skip other them.
| > | plot(g(x),x=-5..5,y=-10..10,color=black,thickness=2,discont=true); |
![[Plot]](images/plotting_8.gif)
But suppose we want to draw the vertical asymptote as a dahed line? x=3 is not a function. But we can use the line command and then overlay the plots.
| > | va:=line([3,-10],[3,10],color=red, linestyle=3): |
| > | graph:=plot(g(x),x=-5..5,y=-10..10,color=black,thickness=2,discont=true): |
| > | display(graph,va); |
![[Plot]](images/plotting_9.gif)
Relations that are not functions can be plotted.
| > | implicitplot(x^2-y^3=1, x=-2..2, y=-2..2, thickness=2,color=blue); |
![[Plot]](images/plotting_10.gif)
| > |