> ------------------------------------------------------------ Math 1225 Laboratory Assignment #7 April 14, 1999 Treibergs Due April 28, 1999 ------------------------------------------------------------ POLAR PLOTTING Plotting graphs in polar coordinates is easily done in MAPLE. The plotting instruction "plot([r(t),theta(t),t=a..b],coords=polar,scaling=constrained);" plots the curve whose r and theta coordinates are (r(t), theta(t)) as t varies form a to b. For example, to plot the cardoid given by the polar equation r = 1 - sin( theta ), we let theta=t and let t run from 0 to 2*Pi. > plot([1-sin(t),t,t=0..2*Pi], coords=polar,scaling=constrained,title=`Cardoid`,color=red); The five leaved rose is given by the equation r = cos( 5 * theta ). > plot([cos(5*t),t,t=0..Pi],coords=polar,scaling=constrained,title=`Five Leaved Rose`); We can make both r and theta move back and forth. for example, > plot([1.5+sin(8*t),t-0.5*cos(16*t),t=0..2*Pi], coords=polar,scaling=constrained,title=`Wachamacallit`); We may wish to superimpose several plots to compare the effect of changing a parameter. For example, to compare the curves r = cos( j * theta ) when j runs from 1 to 4 we use "{seq( [ , , ], j=1..4)}" to make a set consisting of four polar plotting lists. Each plotting list consists of "[ r(t), theta(t), t=a..b ]" where the functions r(t) and theta(t) and a and b may depend on j. > plot({seq([cos(j*t),t,t=0..2*Pi],j=1..4)},coords=polar,scaling=constrained,title=`Roses`); Similarly, we may superimpose some different limacons. > plot({seq([3.5+j*cos(t),t,t=0..2*Pi],j=1..7)}, coords=polar,scaling=constrained,title=`Limacons`); The equation of the leminscate requires slightly different handling. Its equation is r^2 = cos( 2 * theta). We could use sqrt to solve for r as before, but solving for theta instead seems to work better. The complete leminscateis then four symmetric pieces superimposed. > plot({[r,arccos(r^2)/2,r=0..1],[-r,arccos(r^2)/2,r=0..1], [r,-arccos(r^2)/2,r=0..1], [-r,-arccos(r^2)/2,r=0..1]},coords=polar,scaling=constrained,title=`Leminscate`); Spirals are easily plotted. > plot([t,t,t=0..22],coords=polar,scaling=constrained,title=`Spiral of Archimedes`,color=coral); PLOTTING CONIC SECTIONS USING 'IMPLICITPLOT' The parabola, ellipse or hyperbola can be realized as the locus of points P whose distance from the directrix line L is a constant multiple of the distance from the focus point F. The constant 'ee' is called the eccentricity and the equation is 'ee*|FL| = |FP|'. If we set the directric to be the line 'x=0' and the focus to be the point 'F=(1,0)' and the general point is 'P=(x,y)' then the distance to the directrectrix |PL|=x and the distance to the focus is |PF|=sqrt((x-1)^2 + y^2). Using 'implicitplot' means we don't have to solve for y to plot the curve. We superimpompose several plots for ee=1/2,3/4,1,4/3,2. > plots[implicitplot]({seq(ee*x=sqrt((x-1)^2+y^2),ee={1/2,3/4,1,4/3,2})}, x=-1..6,y=-3..3,scaling=constrained,title=`Conic Sections`); CONVERTING BETWEEN POLAR AND RECTANGULAR COORDINATES To find the equation of the curve x^2 + x*y + y^2 = 2 to polar coordinates we may substitute the expressions for the Cartesian coordingates in terms of the polar. > eq1:= x^2 +x*y + y^2 =2 ; 2 2 eq1 := x + x y + y = 2 We can plot the equation. plots[implicitplot](eq1,x=-2..2,y=-4..2,scaling=constrained); Then we can substitute the expressions for 'x' and 'y' in polar coordinates and simplify. Then solve for 'r' as a function of 'theta'. > simplify(subs({x=r*cos(theta),y=r*sin(theta)},eq1)); 2 2 r cos(theta) sin(theta) + r = 2 > expr:=solve(%,r)[1]; 4 2 expr := sqrt(-(2 sin(theta) - 2 sin(theta) + 2) / (cos(theta) sin(theta) - 1)) / ( / 4 2 sin(theta) - sin(theta) + 1) > plot([expr,theta,theta=0..2*Pi],coords=polar,scaling=constrained); To convert from polar to cartesian is similar. For example, if we had the equation in polar coordinates > eq2:= r^2 + r*cos(theta) + cos(theta)^2 = 1; 2 2 eq2 := r + r cos(theta) + cos(theta) = 1 > subs({r=sqrt(x^2+y^2),theta=arctan(y/x)},eq2); > simplify(%,trig); > simplify((x^2+y^2)*%,sqrt,symbolic); 2 2 2 2 2 x + y + sqrt(x + y ) cos(arctan(y/x)) + cos(arctan(y/x)) = 1 2 2 2 2 sqrt(x + y ) 1 x + y + -------------- + -------- = 1 2 2 y y sqrt(1 + ----) 1 + ---- 2 2 x x 4 2 2 4 3 2 2 2 2 x + 2 x y + y + x + x y + x = x + y ROTATION OF AXES IN QUADRATIC CURVES How to find nice coordinates for quadratic equations? the idea is to translate and rotate to simplify. > restart: > eq1:=-x^2 + 14*x*y -y^2 + 11*x + y + 5 =0; 2 2 eq1 := -x + 14 x y - y + 11 x + y + 5 = 0 First we rotate the coordinate axes an angle phi to new axes (u,v). For a general phi, we plug into the quadratic equation. > phi:='phi';eq2:={x=cos(phi)*u-sin(phi)*v,y=sin(phi)*u+cos(phi)*v}; phi := phi eq2 := {x = cos(phi) u - sin(phi) v, y = sin(phi) u + cos(phi) v} > eq3:=subs(eq2,eq1); 2 eq3 := -(cos(phi) u - sin(phi) v) + 14 (cos(phi) u - sin(phi) v) (sin(phi) u + cos(phi) v) 2 - (sin(phi) u + cos(phi) v) + 11 cos(phi) u - 11 sin(phi) v + sin(phi) u + cos(phi) v + 5 = 0 Collecting u and v terms enables us to uv coefficient. We choose phi to make this coefficient zero. > eq4:=collect(eq3,{u,v}); 2 2 2 eq4 := (-sin(phi) - cos(phi) - 14 sin(phi) cos(phi)) v + 2 2 ((14 cos(phi) - 14 sin(phi) ) u - 11 sin(phi) + cos(phi)) v 2 2 2 + (-sin(phi) + 14 sin(phi) cos(phi) - cos(phi) ) u + (11 cos(phi) + sin(phi)) u + 5 = 0 The cross term vanishes if the following expression vanishes. > eq5:=-14*sin(phi)^2+14*cos(phi)^2; 2 2 eq5 := 14 cos(phi) - 14 sin(phi) It is sometimes more convenient to substitute the double angle identities. Thus > eq6:=subs({cos(phi)*sin(phi)=sin(2*phi)/2,cos(phi)^2=(1+cos(2*phi))/2,sin(phi)^2=(1-cos(2*phi))/2},eq5); eq6 := 14 cos(2 phi) The phi which makes this zero is the desired ange of rotation. > solve(eq6,phi); 1/4 Pi > assign(phi=%); Now we substitute this value of phi back into the formula for genmeral rotation by an angle phi. > simplify(eq3,trig); > eq7:=simplify(%,sqrt,symbolic); 2 -(1/2 sqrt(2) u - 1/2 sqrt(2) v) + 14 (1/2 sqrt(2) u - 1/2 sqrt(2) v) (1/2 sqrt(2) u + 1/2 sqrt(2) v) 2 - (1/2 sqrt(2) u + 1/2 sqrt(2) v) + 6 sqrt(2) u - 5 sqrt(2) v + 5 = 0 2 2 eq7 := 6 u - 8 v + 6 sqrt(2) u - 5 sqrt(2) v + 5 = 0 We also translate the coordinate axes in order to center the quadratic curve at the origin and further simplify the expression. Thus we translate so that the new origin is at the point "(a,b)" and the new variables are "(w,z)". > a:='a';;b:='b';eq8:={u=w+a,v=z+b}; a := a b := b eq8 := {u = w + a, v = z + b} eq9:=subs(eq8,eq7); 2 2 eq9 := 6 (w + a) - 8 (z + b) + 6 sqrt(2) (w + a) - 5 sqrt(2) (z + b) + 5 = 0 > simplify(%); 2 2 2 2 6 w + 12 w a + 6 a - 8 z - 16 z b - 8 b + 6 sqrt(2) w + 6 sqrt(2) a - 5 sqrt(2) z - 5 sqrt(2) b + 5 = 0 > collect(%,{w,z}); 2 2 2 -8 z + (-16 b - 5 sqrt(2)) z + 6 w + (12 a + 6 sqrt(2)) w - 8 b 2 + 6 a + 6 sqrt(2) a - 5 sqrt(2) b + 5 = 0 Now we solve for "a" ans "b" to make the "w" and "z" coefficients vanish. > eq10:=solve({12*a+6*sqrt(2),-16*b-5*sqrt(2)},{a,b}); eq10 := {b = - 5/16 sqrt(2), a = - 1/2 sqrt(2)} Finally, we substitute eq10 into eq9 to see the equations in the newest coordinates. > subs(eq10,eq9); > eq11:=simplify(%,sqrt,symbolic); 2 2 6 (w - 1/2 sqrt(2)) - 8 (z - 5/16 sqrt(2)) + 6 sqrt(2) (w - 1/2 sqrt(2)) - 5 sqrt(2) (z - 5/16 sqrt(2)) + 5 = 0 2 57 2 eq11 := 6 w + -- - 8 z = 0 16 We plot the equation in the new variables and plot the exquation and axes in the old variables. > plots[implicitplot](eq11,w=-3..3,z=-3..3,scaling=constrained,title=`Conic section in new variables`); EXTRA. We plot the conic section and the new coordinate axes in old variables. The original curve is just the plot of eq1. To plot the coordinate axes for the new variables, they correspond to the equations z=0 and w=0, whatever that may be in the old variables. Thus we substitute the changes of variable back to see first (w,z) in terms of (u,v) and then (w,z) in terms of (x,y). 2 57 2 6 w + -- - 8 z = 0 16 > subs(eq10,eq8); > subs(%,eq2); > eq12:=simplify(%,sqrt,symbolic); > eq13:=solve(%,{w,z}); {u = w - 1/2 sqrt(2), v = z - 5/16 sqrt(2)} {x = 1/2 sqrt(2) (w - 1/2 sqrt(2)) - 1/2 sqrt(2) (z - 5/16 sqrt(2)) , y = 1/2 sqrt(2) (w - 1/2 sqrt(2)) + 1/2 sqrt(2) (z - 5/16 sqrt(2))} eq12 := {x = 1/2 sqrt(2) w - 3/16 - 1/2 sqrt(2) z, 13 y = 1/2 sqrt(2) w - -- + 1/2 sqrt(2) z} 16 eq13 := {z = 1/16 (-8 x + 5 + 8 y) sqrt(2), w = 1/2 sqrt(2) (x + 1 + y)} > plots[display]({ > plots[implicitplot](eq1,x=-3..3,y=-3..3), > plots[implicitplot](subs({z=0,w=0},eq13[1]),x=-3..3,y=-3..3,color=blue), > plots[implicitplot](subs({z=0,w=0},eq13[2]),x=-3..3,y=-3..3,color=green), > plots[textplot]({[op(subs({z=0.05,w=3.0},subs(eq12 ,{x,y}))),`w`], > [op(subs({z=3.0,w=0.05},subs(eq12 ,{x,y}))),`z`]}) > },scaling=constrained, title=`Conic section in old coordinates & new coordinate axes`); PROBLEMS FOR LAB 7. 1. Plot two of the following curves. Be sure to choose the proper domain for theta. For periodic curves, you need to make sure that the curve starts to repeat itself. r= cos( 8 theta / 5) ; r= 2/(1-cos(theta)); r^2 = 9 sin( 2 * theta ) ,(Leminscate); r=1 + cos ( theta / 2 ); r = 5 - 5 * sin( theta ) ,(Cardoid); r = exp( theta / 4 ) , (Logarithmic Spiral); r theta = 1 ,(Hyperbolioc spiral). 2. Choose one of these curve families and plot several members of the family on the same plot: r = sqrt( 1 - c * sin( theta )^2 ), for the values c = 0.1,0.2,0.3,...0.9; r = (1+c*cos(theta))/(1-c*cos(theta)), for the values c = 0.1,0.2,0.3,...0.9. 3. Find the Cartesian equations of the leminscate ' r^2 + 4*cos(2*theta) = 0;' You might be able to simplify the trigonometric expressions by using "expand" , "simplify(%,trig);" and "simplify((x^2+y^2)*%,sqrt,symbolic);" 4. Find the polar equation for the curve described by the Cartesian equation " x^2 +2*x+y^2-4*y-25=0". 5. Make a rotation and translation of axes to eliminate the cross product term and the linear terms. Identify the curve. Then plot the graph in the old coordinates and in the new coordinates. 4*x^2 + 2*sqrt(3)*x*y+2*y^2+10*sqrt(3)*x+10*y-5=0. [see p. 598]