Plotting Parametric Curves
In this worksheet we will explore plotting curves in Maple. First, we cover standard plots of graphs. Then parametric plots in 2 and 3 dimensions.
Maple Worksheet: parametric_curves.mw
For the old parametric playground worksheet: parametric.mws
An interactive version of the old worksheet: parametric_improved.mw
Select "EditExecuteWorksheet" to display all plots.
Let's clear memory and load the "plots" package.
> | restart;
with(plots): |
The "plot" command allows us to create 2D plots of graphs of functions. It also allows us to plot parametric curves.
Example: A plot of where . In general, we use "x=a..b" to denote the domain "".
> | plot(sin(x),x=0..4*Pi); |
Some plot features can be accessed by right-clicking on the plot itself (or on a Mac "apple command+click"). These plot options (along with other options) can also be included in the plot command itself. Try "? plot,options" to open up the plot options help page and see what other options are available.
> | ? plot,options |
For example, let's plot sine again, but this time we'll color it green, make the plot thicker, used boxed coordinate axes, and tell Maple not to rescale.
> | plot(sin(x),x=0..4*Pi,axes=boxed,color=green,thickness=5,scaling=constrained); |
We can also plot 2D curves using "implicitplot". This allows us to plot curves such at circles and ellipses (which are not graphs of functions -- they fail the vertical line test).
Example: The circle of radius 2 centered at the origin. Notice that we must specify both horizontal and vertical ranges for the "implicitplot" command. Whereas, "plot" automatically determines the appropriate vertical range given a particular horizontal domain.
> | implicitplot(x^2+y^2=4,x=-2..2,y=-2..2); |
The "plot" command can also plot parametric curves. The syntax is 'plot([x(t),y(t),t=a..b]);" where x(t) and y(t) are the functions defining our curve (each choice of "t" yields a point "(x(t),y(t))" on the curve). "t=a..b" indicates that our parameter should stay in the interval .
Example: An ellipse and where . This is the curve defined (implicitly) by .
> | plot([3*cos(t)+1,2*sin(t)+2,t=0..2*Pi],scaling=constrained); |
Example: Plotting a Smiley Face. Carefully choosing some ellipses and circular curves, we get a (piecewise) defined smiley face. Notice that the "plot" command is told that "discont=ture" (i.e. there are discontinuities -- please don't connect these pieces).
> | x := t -> piecewise(t<=1,12*cos(2*Pi*t),t<=2,8*cos(Pi*t),t<=3,-4+cos(2*Pi*(t-2)),4+cos(2*Pi*(t-3))):
'x(t)'=x(t); y := t -> piecewise(t<=1,12*sin(2*Pi*t),t<=2,8*sin(Pi*t),t<=3,5+2*sin(2*Pi*(t-2)),5+2*sin(2*Pi*(t-3))): 'y(t)'=y(t); plot([x(t),y(t),t=0..4],x=-12..12,y=-12..12,discont=true,axes=none); |
The "animate" command allows us to show "how" the parametric curve is being drawn (we can treat the parameter more like a time coordinate).
Note: After you have executed an "animate" command, a plot (usually blank) will eventually appear, but no animation! To activate the animation, click on the plot area with your mouse. Then a little control panel (like a CD player's) should appear at the top of your window. To play the animation, click on the button with a triangle on it.
> | animate(plot,[[x(t),y(t),t=0..c],view=[-12..12,-12..12],frames=100,numpoints=100,axes=none,discont=true],c=0..4); |
Example: A polar coordinates graph for Valentine's Day. Submitted by Dwight Boddorf to the MAA's American Mathematical Monthly Volume 115 Number 2 (February 2008) page 113.
where .
Using the plot option "coordinates=polar", we can produce a standard (polar) plot. Or by using the formulas: and and replacing with the the above formula, we can produce a parametric plot. We'll do both.
> | ? plot,coords |
> | plot(abs(tan(theta))^(1/abs(tan(theta))),theta=0..Pi,coords=polar,axes=none,color=red,thickness=5); |
> | plot([abs(tan(t))^(1/abs(tan(t)))*cos(t),abs(tan(t))^(1/abs(tan(t)))*sin(t),t=0..Pi],axes=none,color=red,thickness=5); |
Animated Parametric Curves
Note: Many of these animations where originally taken from a fellow graduate student's worksheet: "Marilyn Daily's Parametric Playground".
Example: and where . This gives us a parabola.
> | x := t -> t^2 - 2*t:
'x(t)' = x(t); y := t -> t + 1: 'y(t)' = y(t); animate([x(c*t), y(c*t), t=0..4], c=0..1, view=[-2..9, -2..6], numpoints=150, frames=64); |
Example: and where . This gives us the unit circle.
> | animate([cos(c*t), sin(c*t), t=0..2*Pi], c=0..1, view=[-1.2..1.2, -1.2..1.2], scaling=constrained, numpoints=150, frames=64); |
Example: and where and .
This example is different from the others! For each choice of "a" we get a different curve. In this animation, each frame is a fully graphed parametric curve. What changes is the additional parameter "a", which moves from -2 to 2 (and back). So this is a 1-parameter collection of parametric curves. In fact, we could graph these curves altogether and get a parameterized surface!
> | animate([a+cos(t),a*sin(t)+sin(t),t=-Pi..Pi],a=-2..2,view=[-4..4,-4..4],numpoints=100,frames=100); |
Here we stack up all of the parametric curves next to each other (the red surface) and cut through with the (gray) plane . The curve where these two surfaces intersect is the parametric curve and (i.e. the curve above when .
> | mySurface := plot3d([a+cos(t),a*sin(t)+sin(t),a],t=-Pi..Pi,a=-2..2,color=red):
myPlane := plot3d([x,y,1.25],x=0..4,y=-4..4,color=grey): display(mySurface,myPlane,axes=boxed,orientation=[80,5,115],viewpoint=circleleft); |
Example: A Lissajous curve: and where .
> | x := t -> cos(5*t):
'x(t)' = x(t); y := t -> sin(4*t): 'y(t)' = y(t); animate([x(c*t),y(c*t),t=0..2*Pi], c=0..1, scaling=constrained, numpoints=150, frames=128); |
Example: The Archimedes spiral: and where .
> | x := t -> t * cos(t):
'x(t)' = x(t); y := t -> t * sin(t): 'y(t)' = y(t); animate([x(c*t), y(c*t), t=0..8*Pi], c=0..1, view=[-25..25,-25..25], scaling=constrained, numpoints=150, frames=64); |
Example: and where . This gives us a spring.
> | x := t -> t + 3*sin(t):
'x(t)' = x(t); y := t -> cos(t): 'y(t)' = y(t); animate([x(c*t), y(c*t), t=0..30], c=0..1, numpoints=150, frames=64); |
Example: and where . This gives us a "crazy string".
> | x := t -> t + sin(2*t):
'x(t)' = x(t); y := t -> t + sin(3*t): 'y(t)' = y(t); animate([x(c*t), y(c*t), t=0..20], c=0..1, numpoints=150, frames=64); |
Hypocycloids and Epicycloids
A hypocycloid is a curve which is generated by the motion of a point on a circle that rolls inside another circle. Parametric equations of a hypocycloid are of the form
and
(Try to figure out why the equations look like this!)
> | x := t -> (a-b) * cos(t) + b * cos( ((a-b)/b) * t ):
'x(t)' = x(t); y := t -> (a-b) * sin(t) - b * sin( ((a-b)/b) * t ): 'y(t)' = y(t); |
(1) |
Examples: The following are examples of hypercycloids. Note how the parameters a and b change the appearance greatly.
> | a := 11/10;
b := 1; animate([x(c*t), y(c*t), t = 0..20*Pi], c = 0..1, scaling=constrained, numpoints=150, frames=64); |
> | a := 7/2;
b := 1; animate([x(c*t), y(c*t), t = 0..4*Pi], c = 0..1, scaling=constrained, numpoints=150, frames=64); |
> | a := 1/4;
b := 1; animate([x(c*t), y(c*t), t = 0..8*Pi], c = 0..1, scaling=constrained, numpoints=200, frames=64); |
An epicycloid is a curve which is generated by the motion of a point on a circle that rolls outside another circle. Parametric equations of an epicycloid are of the form
and
> | # clear out parameters a & b.
a := 'a': b := 'b': x := t -> (a+b) * cos(t) - b * cos( ((a+b)/b) * t ): 'x(t)' = x(t); y := t -> (a+b) * sin(t) - b * sin( ((a+b)/b) * t ): 'y(t)' = y(t); |
(2) |
Examples: The following are examples of epicycloids. Note how the parameters a and b change the appearance greatly.
> | a := 10;
b := 1; animate([x(c*t), y(c*t), t = 0..2*Pi], c = 0..1, scaling=constrained, numpoints=150, frames=64); |
> | a := 7/5;
b := 1; animate([x(c*t), y(c*t), t = 0..10*Pi], c = 0..1, scaling=constrained, numpoints=300, frames=64); |
Example: A Butterfly curve.
> | x := t -> sin(t)*(exp(cos(t))-2*cos(4*t)-sin((1/12)*t)^5):
'x(t)' = x(t); y := t -> cos(t)*(exp(cos(t))-2*cos(4*t)-sin((1/12)*t)^5): 'y(t)' = y(t); animate([x(c*t),y(c*t),t=0..8*Pi], c=0..1, numpoints=500, scaling=constrained, frames=100, axes=none); |
Curves in 3-Dimensional Space
To graph parametric curves in 3-dimensional space, we use the "spacecurve" command.
Example: Let's plot the twisted cubic (that is , , and ) where .
> | spacecurve([t,t^2,t^3],t=0..2,color=blue,axes=boxed,orientation=[70,75,0],viewpoint=circleleft); |
Example: Here is an elliptical helix.
> | spacecurve([cos(t),3*sin(t),t],t=0..6*Pi,scaling=constrained,color=blue,axes=boxed,viewpoint=circleleft); |
Example: and where .
To parameterize this curve we use so then and and .
> | r := t -> [t,t^2,(t^2+1)^(3/2)]:
'r(t)' = r(t); spacecurve(r(t),t=-1..4,axes=boxed,color=blue,thickness=5,projection=0.5,orientation=[-154,75],title="The curve y=x^2 and z=(x^2+1)^(3/2)"); |