Parametric and Polar Curves

Math 151-03 (Pelsmajer)
Adam Rumpf
April 17, 2014

The point of this lab is to show you a tool that can help you as you study parametric and polar equations and curves.

Directions:
Read through this workbook, evaluating the Mathematica code as you go.  Do the exercises.  Ask questions as needed!
As before, you will need to write up your investigations in the form of a lab report.

First do this:

Look at the top of the window for a message “This file contains potentially unsafe dynamic content.”  (Don’t worry, it’s okay.)  Next to it there will be a button labeled “Enable Dynamics”.

Click the button “Enable Dynamics” before continuing.

Plots and Animation

A parametric curve is given by two functions of t, one for the x-coordinate, and one for the y-coordinate.  For example:

x[t_]:=Cos[t]+0.2*Sin[30*t]
y[t_]:=Sin [t]+0.1*Cos[30*t]

You also need to choose a domain for t.  

Then you can graph it, like this:

ParametricPlot[{x[t],y[t]},{t,0,3*Pi/2}]

To make an animation which shows how the curve is drawn as t increases, we draw the part of the curve from t=0 to t=b, then manipulate b (the last t-value) which determines how far the curve goes before it ends.  

To do that, we need the Manipulate command, which we’ve seen before.  It takes two arguments:  the first argument is the parametric plot with t from 0 to b, and the second argument is the range of b-values.

Run the following code now.  Move the slider to change b.

Manipulate[ParametricPlot[{x[t],y[t]},{t,0,b}],{b,0.001,3*Pi/2}]

We can stop the axes from changing by fixing them in the plot command itself, using the PlotRange command.  We will make the x-range [-1.3,1.3] and the y-range [-1.1,1.1] like this:

Manipulate[ParametricPlot[{x[t],y[t]},{t,0,b},PlotRange-> {{-1.3,1.3},{-1.1,1.1}}],{b,0.001,3*Pi/2}]

Fancier Examples

You can also do all that for multiple curves at once, by replacing {x[t],y[t]} by a list of parametric equations: { {x1[t],y1[t]} , {x2[t],y2[t]} , etc. } .

For example:

x2[t_]:=Cos[t]
y2[t_]:=Sin[t]

ParametricPlot[{{x[t],y[t]},{x2[t],y2[t]} },{t,0,3*Pi/2}]

Manipulate[ParametricPlot[{{x[t],y[t]},{x2[t],y2[t]} },{t,0,b},PlotRange-> {{-1.3,1.3},{-1.1,1.1}}],{b,0.001,3*Pi/2}]

One nice example which uses this is the cycloid, which is generated by tracking one point along a circle that is rolling along a flat surface. The parametric equations for a circle that is moving look like this:
	x(θ,t)=-r sin(θ)+  r s t
	y(θ,t)=r cos(θ)+r
Where t is time, s is speed, and θ is the parameter for the curve. Let's say we've got a circle of radius 1 and moving at a constant speed of 1. The animation of the circle rolling looks like this:

Manipulate[ParametricPlot[{-Sin[theta]+t,Cos[theta]+1},{theta,0,2 Pi}, PlotRange-> {{-1,4*Pi+1.01},{0,2}}],{t,0.001,4 Pi}]

We've also got the cycloid curve itself:
	x(t)=r s t-r sin(s t)
	y(t)=r(1-cos (s t))

Manipulate[ParametricPlot[{u - Sin[u],1- Cos[u]},{u,0,t}, PlotRange-> {{-1,4*Pi+1.01},{0,2}}],{t,0.001,4  Pi}]

Finally, we have the point on the circle:

Manipulate[ListPlot[{{t - Sin[t],1-Cos[t]}},PlotRange-> {{-Pi/2,4*Pi+1.01},{0,2}}],{t,0.001,4 Pi}]

All three at once would look like this:

Manipulate[Show[{ParametricPlot[{-Sin[theta]+t,Cos[theta]+1},{theta,0,2 Pi}, PlotRange-> {{-1,4*Pi+1.01},{0,2}}],
ParametricPlot[{u - Sin[u],1- Cos[u]},{u,0,t}, PlotRange-> {{-1,4*Pi+1.01},{0,2}}],
ListPlot[{{t - Sin[t],1-Cos[t]}},PlotRange-> {{-Pi/2,4*Pi+1.01},{0,2}}]}],
{t,0.001,4 Pi}]

If there are multiple parameters involved, we can show all of them with Manipulate by passing extra ranges. Let's try the cycloid with variable parameters:

Manipulate[Show[{ParametricPlot[{-r Sin[theta]+ r s t,r Cos[theta]+r},{theta,0,2 Pi}, PlotRange-> {{-r,4*r*s*Pi+r*1.01},{0,2 r}}],
ParametricPlot[{r s u - r Sin[s u],r-r Cos[s u]},{u,0,t}, PlotRange-> {{-r,4*r*s*Pi+r*1.01},{0,2 r}}],
ListPlot[{{r s t - r Sin[ s t],r-r Cos[ s t]}},PlotRange-> {{-r,4*r*s*Pi+r*1.01},{0,2 r}}]}],
{t,0.001,4 Pi},{r,0.5,5},{s,0.5,5}]

Polar Curves

A polar curve is a parametric curve which rotates around the origin according to the parameter θ and a function r(θ), which is the distance from the origin.   

r(θ) can be negative, in which case the point is located on the opposite side of the origin.

You can see this in the following demonstration by gradually moving the slider for θ.  The gray line shows the angle θ (counterclockwise from the positive x-axis). 
   Pay attention to the value of r and how that affects the curve - specifically, the position of the orange point on the gray/orange line.

"Polar Trace" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/PolarTrace/

Contributed by: Richard Mercer

As we will see in class tomorrow, a polar curve is given by the parametric equations:
	x=r(θ) cos (θ)
	y=r(θ) sin (θ)

You already know how to plot parametric equations, so you can graph polar curves now, too.  

For example, we graph the polar given given by r(θ) = 2 + 3 cos (θ), with 0 ≤ θ ≤ 2π.  
(I renamed the parameter to be t instead of θ; it doesn’t matter.)

x3[t_]:=(2+3Cos[t])Cos[t]
y3[t_]:=(2+3Cos[t])Sin[t]

ParametricPlot[{x3[t],y3[t]},{t,0,2Pi}]

However, there is also a special command, just for graphing PolarCurves, called PolarPlot, for which the first argument is simply r or r(θ).

PolarPlot[2+3Cos[t],{t,0,2Pi}]

And of course it also works with multiple curves, animations, etc.

Manipulate[PolarPlot[{2+3Cos[t],3+Cos[5t]},{t,0,b}],{b,0.05,2Pi}]

Exercises

Assignment 1: Plotting Parametric Curves

Investigate the following family of parametric curves:
   	x(t)=a cos (t)+cos(a t)
	y(t)=a sin (t)+sin(a t)
	-π≤t≤π
Your answer should include:

A plot of the curve for a=2.

A plot of the curve for a=-2.

A plot of the curve for a=3.

A statement of the curves' behavior as a gets larger and larger. Use of the Manipulate command could make this more obvious..

Assignment 2: Polar Plots

Create plots of the following polar curves:

r(θ)=1+cos((θ/2)), 0≤θ≤4π

r(θ)=1-2sin(3θ), 0≤θ≤2π

r(θ)=(e^(θ/10)), -20≤θ≤20

r(θ)=(e^(cos(θ)))-2cos (4θ) +(((sin((θ/12))))^5),0≤θ≤24π

Your answer should be the four plots.

Assignment 3: An Animated Polar Plot

Create an animation which shows the spiral r(θ)=(e^(θ/10)), -20≤θ≤20 being drawn. Your answer should be the animation.

Source Code for Polar Trace Demonstration

You can skip this section.

This is only included for completeness, in case someone is really excited by the possibility of poring through the code which created the earlier demo.

Sub[expr_,var_,val_]:=
expr /. var->val;

Sub[expr_,var_,vals_?ListQ]:=
Transpose[Sub[expr,var,#]& /@ vals];

PolarTrace[f_,{var_,a_,b_},θ0_,mode_,plotrange_,places_]:=
Module[{pl,dt,mx,ln1,ln2,tx,gr,grobjs,r,θ,x0,y0},

r=Sub[f,var,θ0];
x0 = r*Cos[θ0];y0=r*Sin[θ0];
If[a<b,
pl= If[mode===dot || θ0>a,First[PolarPlot[f,Evaluate[Switch[mode,dot,{var,a,b},trace,{var,a,θ0},segment,{var,θ0-0.1,θ0+0.1}]],Axes->False,PlotStyle->ColorData["HTML","SlateBlue"]]],{}];
dt={PointSize[Medium],Style[Point[{x0,y0}],RGBColor[1,.47,0]]};
mx=Max[Select[Join[Flatten[plotrange],{r}],NumberQ]];
ln1 = Style[Line[{{0,0},mx*{Cos[θ0],Sin[θ0]}}],Gray];
grobjs = {pl,dt,ln1};
If[r<0,
ln2=Style[Line[{{0,0},-mx*{Cos[θ0],Sin[θ0]}}],Orange];
AppendTo[grobjs,ln2]
];
{r,θ,x0,y0} = NumberForm[Chop[N[#,places+1]],{places+1,places},NumberPadding->{" ","0"},ExponentFunction-> (Null&) ]& /@  {r,θ0,x0,y0};
tx = Text @ Style[Row[{"θ:",θ,"  r:",r,"  x:",x0,"  y:",y0}],10];

gr=Graphics[grobjs,Axes->True,AspectRatio->Automatic ,AxesOrigin->{Automatic,0}, ImageSize->{400,300},PlotRange->plotrange]
];

Grid[{{tx},{gr}}]
];

PolarFunctionList = 
{{Cos[θ],{{-1,1},{-1,1}},{0,2π}}->"r = cos(θ)",
{Sin[2θ],{{-1,1},{-1,1}},{0,2π}}->"r = sin(2θ)",
{Cos[3θ],{{-1,1},{-1,1}},{0,2π}}->"r = cos(3θ)",
{1-Sin[θ],{{-2,2},{-2,2}},{0,2π}}->"r = 1 - sin(θ)",
{1+2Sin[4θ],{{-3,3},{-3,3}},{0,2π}}->"r = 1 + 2 sin(4θ)",
{1+4Cos[5θ],{{-5,5},{-5,5}},{0,2π}}->"r = 1 + 4 cos(5θ)",
{Sin[θ/4],{{-1,1},{-1,1}},{0,8π}}->"r = sin(θ/4)",
{Sin[8θ/5],{{-1,1},{-1,1}},{0,10π}}->"r = sin(8θ/5)",
{Sin[θ]+Sin[5θ/2]^3,{{-2,2},{-2,2}},{0,4π}}->"r = sin(θ)+(sin^3)(5θ/2)"
};

Manipulate[PolarTrace[First[f],Prepend[Last[f],θ],θ0,mode,First[Rest[f]],places],
{{f,PolarFunctionList[[6,1]],"function"},PolarFunctionList,BaseStyle->{FontSize->9}},
{mode,{trace,dot,segment}},
{places,Range[2,6],ControlType->PopupMenu,BaseStyle->{FontSize->9}},
{{θ0,0,"θ"},First[Last[f]],Last[Last[f]]},
SaveDefinitions->True ,AutorunSequencing->{4}]

"Polar Trace" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/PolarTrace/

Contributed by: Richard Mercer