{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" 18 272 "" 0 1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1 0 2 2 0 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Normal" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 1 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 257 "" 0 "" {TEXT -1 17 "Lecture 8 Part a " }}} {EXCHG {PARA 258 "" 0 "" {TEXT -1 54 "Please shrink all plots before p rinting to save paper." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 320 149 "This lecture is split into two workshee ts since the large number of plots in the lecture sometimes causes a m emory problem which may lead to crashes." }{TEXT -1 1 " " }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 32 "displaying several plots at once" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 80 "There are two ways of doing this. The following il lustrates one way. We display " }{XPPEDIT 18 0 "x^3;" "6#*$)%\"xG\"\"$ \"\"\"" }{TEXT -1 2 ", " }{XPPEDIT 18 0 "diff(x^3,x);" "6#-%%diffG6$*$ )%\"xG\"\"$\"\"\"F(" }{TEXT -1 6 ", and " }{XPPEDIT 18 0 "diff(x^3,`$` (x,2));" "6#-%%diffG6$*$)%\"xG\"\"$\"\"\"-%\"$G6$F(\"\"#" }{TEXT -1 111 " in the same plot. This also shows how to color the different gr aphs and increase the thickness of the curves." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 104 "g:=x^3:\ndg:=diff(g,x):\nddg:=diff(dg,x):\npl ot([g,dg,ddg],x=-2..2, color=[red,blue,black], thickness = 3);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "We can do the same thing using the command " }{TEXT 291 7 "display" } {TEXT -1 29 " after executing the command " }{TEXT 292 11 "with(plots) " }{TEXT -1 21 " which brings in the " }{TEXT 293 5 "plots" }{TEXT -1 39 " package. We create plots for each of " }{XPPEDIT 18 0 "x^4;" "6# *$)%\"xG\"\"%\"\"\"" }{TEXT -1 3 ", " }{XPPEDIT 18 0 "diff(x^4,x);" " 6#-%%diffG6$*$)%\"xG\"\"%\"\"\"F(" }{TEXT -1 4 " , " }{XPPEDIT 18 0 " diff(x^4,`$`(x,2));" "6#-%%diffG6$*$)%\"xG\"\"%\"\"\"-%\"$G6$F(\"\"#" }{TEXT -1 6 ", and " }{XPPEDIT 18 0 "diff(x^4,`$`(x,4));" "6#-%%diffG6 $*$)%\"xG\"\"%\"\"\"-%\"$G6$F(F)" }{TEXT -1 7 ". Then " }{TEXT 323 7 " display" }{TEXT -1 48 " them on a single set of axes using the command " }{TEXT 260 7 "display" }{TEXT -1 80 ". This method is much more fle xible that the previous one as we shall see later." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "P[1]:=plot(x^4, x = -2..2, color = red): " }{TEXT -1 102 "<--Use colon here instead of semicolon. Otherwise you will gets l ots more output than you wish to see." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "P[2]:=plot(4*x^3,x=-2..2, color = blue):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 85 "P[3]:=plot(12*x^2, x=-2..2, color = black):\nP[4]:=plot(12*x, x=-2..2, color = green):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "display(\{seq(P[i],i=1..4)\}, thickness = 3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Or you may arrange the pl ots in a 2 by 2 matrix, as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "display(matrix(2,2,[seq(P[i],i=1..4)]));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 83 "If you don't like the tickmarks on the x- axis later we will see how to change them." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 29 "parametri cally defined curves" }}{EXCHG {PARA 256 "" 0 "" {TEXT -1 39 "piloting curves defined parametrically:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 80 "A curve in rectangular coordinates may often be defined by paramet ric equations:" }}{PARA 0 "" 0 "" {TEXT -1 24 "\n \+ " }{TEXT 273 44 "x=f(t), \n y=g(t), \n\n" } {TEXT 296 24 "where t goes from a to b" }{TEXT 297 3 ". \n" }}{PARA 0 "" 0 "" {TEXT -1 32 "Perhaps the best example is the " }{TEXT 324 16 " circle of radius" }{TEXT -1 7 " r = a " }{TEXT 325 22 "centered at the origin" }{TEXT -1 27 ", which is parametrized by " }}{PARA 0 "" 0 "" {TEXT -1 24 "\n " }{XPPEDIT 272 0 "x = a*cos(t), y = a*sin(t),t = 0 .. 2*Pi:" "6%/%\"xG*&%\"aG\"\"\"-%$cosG6#%\"tGF'/% \"yG*&F&F'-%$sinG6#F+F'/F+;\"\"!*&\"\"#F'%#PiGF'" }{TEXT -1 3 ": \n" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 " For example, we can plot a circle of radius r = 2 as follows:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 36 "plot([2*cos(t),2*sin(t),t=0..2*Pi]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "To make this look rounder we add t he option " }{MPLTEXT 1 0 21 "scaling = constrained" }{TEXT -1 59 " to force Maple to use the same scale on the x and y axes:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "plot([2*cos(t),2*sin(t),t=0..2*Pi], scaling = constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 119 "Next we modify the circle slightly by giving it a variable radius making i t into a spiral: Note that we use the option " }{MPLTEXT 1 0 12 "axes \+ = boxed" }{TEXT -1 237 ". We discuss other options later, but you can \+ see some options if you place the cursor on the output of the plot com mand and hold down the right mouse button. Try out the effect on the p lot of selecting different options using the mouse." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "plot([t*c os(t), t*sin(t), t=0..4*Pi], axes=boxed);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 107 "Next we plot a bunch of concentric circles of radii 1, 2 , . . . , 10. We first form the plots, then we use " }{TEXT 298 7 "dis play" }{TEXT -1 102 " to display them all a once. Notice the trick use d here to give different colors to different curves. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 192 "L0:=red,blue,green,gold, turquoise , orange, magenta, aquamarine, yellow, pink, plum, wheat:\nfor r from \+ 1 to 10 do\n P[r]:=plot([r*cos(t),r*sin(t),t=0..2*Pi], color = L0[r], thickness = 3):\nod:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "pl ots[display](\{seq(P[r],r=1..10)\}, scaling = constrained, axes=none); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Check out " }{TEXT 326 11 "?p lot,color" }{TEXT -1 29 " to see the available colors." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "?plot,color" }}}}{SECT 1 {PARA 3 " " 0 "" {TEXT -1 17 "Some plot options" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart:\nwith(plots):" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 137 "We now go through some opt ions that allow us to exert more control over the graphs. To see the f ull list of such options use the command " }{MPLTEXT 1 0 13 "?plot/opt ions" }{TEXT -1 49 ". There are many options. We examine only a few. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "?plot/options" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT 262 14 "Vertical Range" }{TEXT -1 94 " may b e controlled as in the following two examples. In our first example we plot a procedure:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "f:=x- >2*x^5-10*x+2:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "plot(f,-2 ..2,-20..20);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 73 "If you are not c areful, you may cut off part of the graphs as we do here:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "plot(f,-2..2,-5..5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "If we use " }{TEXT 303 1 "S" }{TEXT -1 47 " as a variable and write the plot limits using " }{TEXT 301 1 "S" }{TEXT -1 5 " and " }{TEXT 302 1 "T" }{TEXT -1 51 " as in the followin g example, the axes are labeled " }{TEXT 304 1 "S" }{TEXT -1 5 " and \+ " }{TEXT 305 1 "T" }{TEXT -1 27 ". Here I also control what " }{TEXT 300 9 "tickmarks" }{TEXT -1 44 " are placed on the axes by suitable op tions." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "plot(f(S),S=-2..2 ,T=-20..20, xtickmarks=[-2,-1,0,1,2], ytickmarks=[-10,0,10]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "We may also do this with " }{TEXT 319 11 "expressions" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "p:=2*s^5-10*s+2: " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "Note that this also labels th e axes:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "plot(p,s=-2..2,t =-20..20,xtickmarks=[-2,-1,0,1,2], ytickmarks=[-10,0,10] );" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 99 "Sometimes it is necessary to limit the range on the y-axis. For example, if we naively try to plot " } {TEXT 274 6 "tan(x)" }{TEXT -1 23 " we get nothing of use:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "plot(tan(x), x=-2*Pi..2*Pi);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "What we need is something like the following:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "plot(tan(x), x=-2*Pi..2*Pi, y=-10..10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "To get rid of the vertical lines at the places where " }{TEXT 299 6 "tan (x)" }{TEXT -1 44 " has a discontinuity one may use the option " } {MPLTEXT 1 0 12 "discont=true" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "plot(tan(x), x=-2*Pi..2*Pi, y=-10..10, discont=t rue);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 "Note that in the above \+ graph the scales on the two axes are different. To remedy this we may \+ use the " }{TEXT 306 7 "scaling" }{TEXT -1 29 " option: By using the o ption " }{MPLTEXT 1 0 21 "scaling = constrained" }{TEXT -1 64 " you ca n insure that Maple with use the same scale on both axes." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "plot(sin,0..2*Pi);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "plot(sin,0..2*Pi,scaling=constrained, ytickmarks=[-1,0,1]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "One can restrict the range as we d id above or one may use " }{TEXT 263 4 "view" }{TEXT -1 14 ". The opt ion " }{TEXT 264 4 "view" }{TEXT -1 179 " has the advantage of being q uicker since when it is used the graph is not recomputed. The same dat a is used to redraw the graph: Here are some examples: We also change \+ the color." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 28 "The first plot is worthless:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 56 "plot(1/(x^2-1),x=-2..2,color=black,ytickmarks=[-1,0 ,1]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 84 "As above we can improve \+ it by limiting the vertical range: But it is still not very " }}{PARA 0 "" 0 "" {TEXT -1 60 "nice since it gives vertical lines where the as ymptotes are." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "plot(1/(x^ 2-1),x=-2..2,-10..10,color=black);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "As before we can make it look better by using the option " } {TEXT 294 12 "discont=true" }{TEXT -1 12 " as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "plot(1/(x^2-1),x=-2..2,-10..10,colo r=black,discont=true);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 134 "Now le t's show how to use view: We look at the famous sin(1/x) curve graphed on the same axes with x^2. First we give the plot a name." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "P:=plot([sin(1/x),x^2],x=0..1,color=[black,red]):\ndisplay(P);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 165 "Now we can use view with displ ay to get a better look in a particular range: In this view we can app roximate the coordinate of one point where the two graphs cross. " } {TEXT 275 253 "If you click on the intersection of the two curves you will see the coordinates displayed in the upper left of the worksheet . But note that this only gives an approximation. Better methods are n eeded to get more precise coordinates of the intersection." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "display(P,view=[(.32)..(.34), -(.1) ..(.2)]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 261 6 "Style:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "The option " }{TEXT 276 5 "style" }{TEXT -1 14 " has the form " }{MPLTEXT 1 0 12 "style = line" }{TEXT -1 4 " o r " }{MPLTEXT 1 0 13 "style = point" }{TEXT -1 23 " These apply only t o a " }{TEXT 295 25 "list of two element lists" }{TEXT -1 36 " (points ). Let's give some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "plot([[0,0],[1,-1],[2,2], [1,3],[0,0]],style=line);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "We can make the lines thicker or thinner \+ by using " }{MPLTEXT 1 0 13 "thickness = i" }{TEXT -1 63 " where i sh ould be 0, 1, 2, or 3. 0 is the default thickness." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "plot([[0,0],[1,-1],[2,2], [1,3],[0,0]],st yle=line, color=blue,thickness = 3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "Here's a way to plot a discrete function such as the function \+ " }{TEXT 307 8 "ithprime" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "plot( [seq([i,ithprime(i)],i=1..5)],style= line);" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "plot([[seq([i,ithprime(i)], i=1..5)]],style=point, symbol=cross);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "plot([[seq([i,ithprime(i)],i=1..5)]],style=point, sym bol=box, color=black);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "We can \+ use " }{TEXT 308 7 "display" }{TEXT -1 33 " to put two such graphs tog ether." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 185 "p1:=plot([[seq([ i,ithprime(i)],i=1..5)]],style=point, symbol=circle, color = red):\n\n p2:=plot( [seq([i,ithprime(i)],i=1..5)],style= line,color = black):\n \ndisplay(\{p1,p2\}, thickness = 2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 17 "polar coordinates" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "To plot the curve " }{TEXT 277 6 "r = f(" }{XPPEDIT 278 0 "theta" "6#%&thetaG" }{TEXT 279 1 ")" }{TEXT -1 3 " , " }{TEXT 280 4 "for " }{XPPEDIT 281 0 "theta" "6#%&thetaG" }{TEXT 282 11 " from 0 t o " }{XPPEDIT 283 0 "2*Pi" "6#*&\"\"#\"\"\"%#PiGF%" }{TEXT -1 6 ", in \+ " }{TEXT 284 17 "polar coordinates" }{TEXT -1 7 " use \n" }{TEXT 265 1 " " }}{PARA 0 "" 0 "" {TEXT 285 18 " plot([f(" } {XPPEDIT 256 0 "theta" "6#%&thetaG" }{TEXT 266 4 ") , " }{XPPEDIT 257 0 "theta" "6#%&thetaG" }{TEXT 267 3 " , " }{XPPEDIT 258 0 "theta" "6#% &thetaG" }{TEXT 268 6 " = 0.." }{XPPEDIT 259 0 "2*Pi" "6#*&\"\"#\"\"\" %#PiGF%" }{TEXT 269 41 "], coords=polar, scaling = constrained):\n" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 13 "The variable " }{XPPEDIT 18 0 "th eta;" "6#%&thetaG" }{TEXT -1 104 " (theta) may be replaced by any vari able. We start with an example where r = 1. So we get a semi-circle:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "plot([1,theta,theta=0..Pi ],coords=polar,scaling=constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "Next we plot the four-petal rose " }{XPPEDIT 18 0 "r = cos(2*th eta);" "6#/%\"rG-%$cosG6#*&\"\"#\"\"\"%&thetaGF*" }{TEXT -1 5 " for " }{XPPEDIT 18 0 "theta;" "6#%&thetaG" }{TEXT -1 11 " from 0 to " } {XPPEDIT 18 0 "2*Pi;" "6#*&\"\"#\"\"\"%#PiGF%" }{TEXT -1 1 ":" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 93 "plot([cos(2*theta),theta, th eta=0..2*Pi],coords=polar, scaling = constrained, thickness = 3);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 12 "implicitplot" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "Plots of plane curves of the form " }{TEXT 309 10 "f(x,y) = 0" }{TEXT -1 85 " require different command s Note that above we have so far plotted either graphs of " }{TEXT 310 8 "y = f(x)" }{TEXT -1 73 " or lists of points or curves given by \+ parametric equations. The command " }{TEXT 287 12 "implicitplot" } {TEXT -1 31 " is needed to plot things like " }{XPPEDIT 18 0 "x^2+y^2 \+ = 1;" "6#/,&*$%\"xG\"\"#\"\"\"*$%\"yGF'F(F(" }{TEXT -1 11 ". We need \+ " }{TEXT 311 12 "implicitplot" }{TEXT -1 18 " from the package " } {TEXT 312 5 "plots" }{TEXT -1 10 " for this:" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plot s):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "eqn:=x^4+y^4-5*x*y + 1/5 = 0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "implicitplot(e qn, x=-3..3,y=-3..3,color=black);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 103 "There are two ways to increase the number of points plotted and t hus improve the accuracy of the graph:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "implicitplot(eqn, x=-3..3,y=-3..3,color=black, numpoi nts=10000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 129 "The default numbe r of points plotted is a 25 x 25 grid of 625 points equally spaced in the indicate range. To increase this use " }{TEXT 286 10 "grid=[n,m] " }{TEXT -1 40 " for some integers n and m, for example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "implicitplot(eqn, x=-3..3,y=-3..3, \+ color=black,grid=[100,100]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 16 "Misleading plots" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 86 "The default number of points plotted is 50. This sometimes gives a false impression of" }}{PARA 0 "" 0 "" {TEXT -1 84 "the graph. See how the following graph changes wh en we increase the number of points" }}{PARA 0 "" 0 "" {TEXT -1 46 "pl otted by adding the option numpoints= 4000. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "expr:=(1/10)*(x-24)^2 + cos(100*Pi*x);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "plot(expr,x=0..60,color=blac k);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "display(%,view=[40.. 50,20..70]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 22 "Increasing the op tion " }{TEXT 288 9 "numpoints" }{TEXT -1 27 " makes a lot of differen ce:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "plot((1/10)*(x-24)^2 + cos(2*Pi*x),x=0..60, numpoints=4000,color=black);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "display(%,view=[40..50,20..70]);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 21 "Placing text in plots" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "If you have the desire \+ and energy you can also place text in plots. Using " }{TEXT 270 18 "ti tle = \"whatever\"" }{TEXT -1 41 ",you may give a title to the plot, U sing " }{TEXT 271 27 "labels = [string1,string2]" }{TEXT -1 90 " you \+ may have labels put on the x and y axes. But the placement may not be \+ so good. Using " }{TEXT 289 8 "textplot" }{TEXT -1 100 " one may place text where one wants to. Here are some examples. Text may be enclosed by \" \" or ` `. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "plot( sin, 0..2*Pi, title = \"The graph of y = sin(x).\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 155 "p:=plot(sin(x),x=-Pi..Pi):\nb:=textplot([Pi/2,1.1, \"Local Maximum\"]):\nc:=textplot([-Pi/2,-1.1,\"Local Minimum\"]):\ndi splay(\{p,b,c\}, title = \"Graph of sin(x)\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "We may also add the options " }{TEXT 329 7 "align = " }{TEXT -1 36 " one of BELOW, RIGHT, ABOVE, LEFT or" }}{PARA 0 "" 0 " " {TEXT -1 37 "a set of these such as \{BELOW,LEFT\}. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 " delta:=.1:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 164 "t1 := textplot([Pi/2,1+delta,`Local Maxima (P i/2, 1)`],align=ABOVE):\n\nt2 := textplot([-Pi/2,-1 -delta,`Local Mini ma (-Pi/2, -1)`],align=BELOW):\n\ndisplay(\{p,t1,t2\});" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 29 "Basic three-dimensional plots" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 "First we consider the plotting of an " } {TEXT 315 8 "equation" }{TEXT -1 12 " of the form" }{TEXT 313 11 " z = f(x,y)" }{TEXT -1 58 " for x and y in a given range. First we plot t he surface " }{TEXT 314 12 "z = cos(x*y)" }{TEXT -1 150 " with x betwe en -3 and 3 and y between -3 and 3. Of course, there is nothing specia l about x, y and z. Any variables could be used instead. Note that " } {TEXT 321 6 "plot3d" }{TEXT -1 1 " " }{TEXT 330 8 "requires" }{TEXT -1 13 " loading the " }{TEXT 322 5 "plots" }{TEXT -1 20 " package unli ke the " }{TEXT 331 4 "plot" }{TEXT -1 9 " command." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart:\nwith(plots):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "plot3d(cos(x*y),x=-3..3,y=-3..3);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 226 "Note that if you click on the gra ph you can rotate it with your cursor. Also a row of options, differen t types of spheres, etc. appear on the menu. By clicking on these you \+ can see the effect on the graph. Execute the command " }{MPLTEXT 1 0 16 "?plot3d[options]" }{TEXT -1 297 " to see what some of the many add itional features you have to choose from. These options either appear \+ on the menu at the top or may be obtained by (right) clicking on the g raph on a PC. On a Mac hold down the option key while clicking the mou se. Select some of the style options and axes options." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "\nAs for ordinary plots you may use " } {TEXT 316 10 "procedures" }{TEXT -1 12 " instead of " }{TEXT 317 21 "a lgebraic expressions" }{TEXT -1 158 " as in the above example.To illus trate we convert the above expression into a procedure. Note that we c onvert it into a function of the two variables x and y." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "f:=unapply(cos(x*y),x,y);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "plot3d(f,-3..3,-3..3);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 86 "Ch anges made with the mouse can also be accomplished by adding various o ptions to the " }{TEXT 318 6 "plot3d" }{TEXT -1 36 " command itself: H ere is an example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "plot3 d(f,-3..3,-3..3,grid=[50,50],axes=box, style = patchcontour);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 145 "The range of the variable y can d epend on the variable x as in the following examples. This has the eff ect of restricting the domain to a circle." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 101 "plot3d((1-(x^2+y^2))*sin(x^2+y^2), x=-1..1,y=-sqrt (1-x^2)..sqrt(1-x^2), axes=box, style=patchnogrid);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 103 "plot3d(x*y, x=-1..1,y=-sqrt(1-x^2)..sqrt (1-x^2), axes=normal, style=patchcontour, title=\" The Saddle\");" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 3 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 9 "Continued" }}{PARA 0 " " 0 "" {TEXT -1 5 "Open " }{TEXT 332 11 "Lecture 8 b" }{TEXT -1 14 " a nd continue." }}}}{MARK "4" 0 }{VIEWOPTS 1 0 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 1 1 2 33 1 1 }