Shared16 - Parametric Equations Assignment / Parametric Equations Notes.sagewsOpen in CoCalc
This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is

### Prerequisites:

• Intro to Sage
• Graphing and Solving Equations
• Tangent Lines

# Parametric Equations

Suppose $x$ and $y$ are both functions of a variable $t$, called the "parameter." Then each value of $t$ gives a point in the x-y plane, $(x(t),y(t))$. The set of all such points as $t$ varies is called a "parametric curve," and the equations defining this curve are called "parametric equations."

## Example 1

Below is an example of a parametric curve. Notice that $y$ is not a function of $x$ (or vice versa). Graphs of functions form a really limited collection of curves, and parametric curves provide many more kinds of graphs.

%var t
x(t)=sqrt(3)*cos(2*t)-cos(10*t)*sin(20*t)
y(t)=-sqrt(2)*sin(2*t)-sin(10*t)*sin(20*t)
parametric_plot((x(t),y(t)),(t,0,pi))


Below is an animation which shows the above curve being drawn as $t$ starts at $0$ and increases to $\pi$.

%var t
x(t)=sqrt(3)*cos(2*t)-cos(10*t)*sin(20*t)
y(t)=-sqrt(2)*sin(2*t)-sin(10*t)*sin(20*t)
p=point((sqrt(3),0),xmin=-2.5,xmax=2.5,ymin=-2.5,ymax=2.5)
s=[p]
for n in [1..50]:
p+=parametric_plot((x(t),y(t)),(t,(n-1)*pi/50,n*pi/50))
s+=[p]
a=animate(s,figsize=5)
show(a,delay=20)


You can graph a parametric curve by hand using a table of values - just choose some values of $t$ and plug them into the $x$ and $y$ functions. This is usually pretty tedious.

Sage can handle parametric curves using the parametric_plot command, as in the example above.

First, declare the variable $t$. Then define $x(t)$ and $y(t)$. Finally, type parametric_plot((x(t),y(t)),(t,0,pi)). Notice that (t,0,pi) controls which values of $t$ are used. You may want to increase pi if the graph looks incomplete.

## Example 2

There is a toy called the Spirograph that lets you draw interesting curves using a collection of wheels. We can produce these pictures using Sage.

In the interact below, experiment with different values of $a$ and $b$. If the curve looks incomplete, then increase tmax.

For example, try $a=21,\ a=\frac{1}{2},\ a=\sqrt{2}$ (increase tmax to 100*pi for this one).

@interact
def _(a=5,b=2,tmax=10*pi):
%var t
x(t)=(a-b)*cos(t)+b*cos((a-b)/b*t)
y(t)=(a-b)*sin(t)-b*sin((a-b)/b*t)
show(parametric_plot((x(t),y(t)),(t,0,tmax)))

Interact: please open in CoCalc

## Tangents to Parametric Curves

We would like to do calculus with parametric curves, such as finding the slope of the curve.

## Example 3

Consider the parametric curve below, which has equations $x(t)=2\sin(2t)$ and $y(t)=2\sin(t)$.

Although $y$ is not a function of $x$, it looks like the curve should have tangent lines. How do we find the slope of the tangent line?

%var t
x(t)=2*sin(2*t)
y(t)=2*sin(t)
parametric_plot((x(t),y(t)),(t,0,2*pi))


By the Chain Rule: $\displaystyle\frac{dy}{dt}=\frac{dy}{dx}\cdot\frac{dx}{dt}$.

If $\displaystyle\frac{dx}{dt}\ne 0$, then we can solve for $\displaystyle\frac{dy}{dx}$ to get $\frac{dy}{dx}=\frac{\frac{dy}{dt}}{\frac{dx}{dt}}$

In other words, the slope of the curve in the x-y plane is given by $\displaystyle\frac{y\,'(t)}{x'(t)}$.

Notice that this slope is given as a function of $t$. So if we want the slope of the curve at a particular point $(x,y)$, then we need to find a value of $t$ that gives us this point.

## Example 4

Find an equation for the tangent line to the curve above at $t=\frac{\pi}{6}$.

First, find the slope function. I'll call this function $m$.

%var t
x(t)=2*sin(2*t)
y(t)=2*sin(t)
m(t)=derivative(y,t)/derivative(x,t)
show(m(t))

$\displaystyle \frac{\cos\left(t\right)}{2 \, \cos\left(2 \, t\right)}$

Now let's find the slope when $t=\frac{\pi}{6}$.

show(m(pi/6))

$\displaystyle \frac{1}{2} \, \sqrt{3}$

Next, we calculate $x\left(\frac{\pi}{6}\right)$ and $y\left(\frac{\pi}{6}\right)$, then we use the point-slope form of a line: $y=y_1+m(x-x_1)$

x(pi/6)
y(pi/6)

sqrt(3) 1

Notice that the tangent line is a function of $x$, not $t$. In order to not interfere with our parametric function $x(t)$, I will use capital $X$ for the tangent line.

TL(X)=1+sqrt(3)/2*(X-sqrt(3))  #Note the capital X
show(TL(X))
parametric_plot((x(t),y(t)),(t,0,2*pi))+plot(TL(X),xmin=-2,xmax=3,color='red')+point((sqrt(3),1),size=25,color='black')

$\displaystyle \frac{1}{2} \, \sqrt{3} {\left(X - \sqrt{3}\right)} + 1$

## Intersection Points

What happens to the derivative when the curve crosses itself?

## Example 5

In the curve above, the curve intersects itself at $(0,0)$.

What values of $t$ result in $(x(t),y(t))=(0,0)$?

We need a value of $t$ that gives both $x(t)=0$ and $y(t)=0$.

First, we'll ask Sage to solve the equations.

%var t
x(t)=2*sin(2*t)
y(t)=2*sin(t)
solve(x(t)==0,t)
solve(y(t)==0,t)

[t == 0] [t == 0]

Sage tells us that $t=0$ will work. Is that the only possiblity?

No, we know there are more solutions, since $x$ and $y$ are both periodic functions. We can get Sage to give us a more complete answer by adding the optional argument to_poly_solve='force' (don't worry about what this does).

solve(x(t)==0,t,to_poly_solve='force')
solve(y(t)==0,t,to_poly_solve='force')

[t == 1/2*pi*z45] [t == pi*z50]

In the output above, the variables z45 and z50 are assumed to be any integer (that's what the "z" is for).

In other words, $x(t)=0$ when $t=\frac{z\pi}{2}$ for any integer $z$, i.e., $t=0,\ \pm\frac{\pi}{2},\ \pm\frac{2\pi}{2}=\pm\pi,\ \pm\frac{3\pi}{2},\ \pm\frac{4\pi}{2}=\pm 2\pi,$ etc.

On the other hand, $y(t)=0$ when $t=z\pi$ for any integer $z$, i.e. $t=0,\ \pm\pi,\ \pm 2\pi,\ \pm3\pi,$ etc.

The values of $t$ on both of these lists result in both $x$ and $y$ being $0$.

Look at the two lists, and see what they have in common. In this case, both lists have $t=z\pi$.

What is the slope of the curve when $t=z\pi$? Let's try a few values of $z$.

m(-2*pi); m(-1*pi); m(0*pi); m(1*pi); m(2*pi)

1/2 -1/2 1/2 -1/2 1/2

We get two different slopes: $\frac{1}{2}$ and $-\frac{1}{2}$.

Since there are two different slopes, there must be two different tangent lines.

TL1(X)=0+1/2*(X-0)  #Note the capital X
TL2(X)=0-1/2*(X-0)  #Again, capital X
parametric_plot((x(t),y(t)),(t,0,2*pi))+plot(TL1(X),xmin=-3,xmax=3,color='red')+plot(TL2(X),xmin=-3,xmax=3,color='red')+point((0,0),size=25,color='black')