Chapter 1
20 min read
Section 10 of 353

Parametric Representations

Mathematical Functions - The Building Blocks

Learning Objectives

By the end of this section you will be able to:

  1. Read any parametric pair (x(t),y(t))(x(t), y(t)) as the position of a moving particle and trace its path by hand.
  2. Switch between parametric form and Cartesian form y=f(x)y = f(x) when (and only when) it is possible — and explain why some curves cannot be written as a single graph.
  3. Compute the velocity vector r(t)=(x(t),y(t))r'(t) = (x'(t), y'(t)) and the scalar speed r(t)|r'(t)| for any parametric curve.
  4. Recognise classic curves on sight — line, circle, ellipse, Lissajous, astroid, cycloid, helix — and know what each one parametrises.
  5. Derive the cycloid from the geometric story of a rolling wheel and explain why its cusps correspond to r(t)=0r'(t) = \mathbf{0}.
  6. Implement parametric curves in NumPy and verify the analytic derivative numerically with PyTorch autograd.

Why Single-Equation Curves Aren't Enough

Every function you have met so far has the same shape: y=f(x)y = f(x). For each xx there is exactly one yy. The graph is a curve, but it is a very special kind of curve — the vertical-line test always passes.

The trouble: most real curves fail the vertical-line test. A circle has two yy-values above almost every xx. A loop has many. A spaceship's flight path can cross itself five times. None of these can be written as a single y=f(x)y = f(x).

We need a different kind of description. Instead of asking "given xx, what is yy?" we will ask "at time tt, where is the particle?"

The shift in mindset

A parametric curve is a moving point. The variable tt is like a clock. As the clock ticks from t=0t = 0 to t=Tt = T, the point traces the curve. The curve is the trail the point leaves behind.

This single change of perspective unlocks every curve you can imagine — circles, ellipses, spirals, knots, the cardioid your physics professor scribbled on the board, the path of a bouncing pendulum, the orbit of Mars. It is also exactly how computer graphics, robotics, and animation engines all represent curves internally.


Definition: Two Clocks, One Pen

A parametric representation of a curve in the plane is a pair of functions

x=x(t),y=y(t),t[a,b].x = x(t), \qquad y = y(t), \qquad t \in [a, b].

We package the two outputs into one vector-valued function

r(t)=(x(t), y(t))r(t) = \bigl(x(t),\ y(t)\bigr)

and read it as: "at time tt, the particle is at position r(t)r(t)." The variable tt is called the parameter. It does not have to be time — it can be an angle, an arc length, anything that monotonically labels positions along the curve — but the time intuition almost never fails you.

The two-clocks analogy

Imagine a pen tied to two ropes. One rope is yanked left-right by clock x(t)x(t); the other is yanked up-down by clock y(t)y(t). The pen draws whatever curve the two clocks together dictate. Different clocks → different curves. Same clocks, different speed → same curve, different traversal.

The smallest possible example: a line

Start at point (1,2)(1, 2) and walk at velocity (3,1)(3, -1). Where are you after time tt?

r(t)=(1+3t, 2t)r(t) = (1 + 3t,\ 2 - t)

At t=0t = 0 you are at (1,2)(1, 2). At t=1t = 1 you are at (4,1)(4, 1). At t=2t = 2 you are at (7,0)(7, 0). The pen traces a straight line. That is a parametric line — and notice you got both an equation and a velocity for free, instead of just y=13x+73y = -\tfrac{1}{3}x + \tfrac{7}{3}.


Reading a Parametric Curve

To read any parametric pair, build a small table. Pick a handful of tt values, compute both coordinates, plot the points, connect them. That is it. The table is the curve.

Example: a circle

Take

r(t)=(cost, sint),t[0,2π].r(t) = (\cos t,\ \sin t), \qquad t \in [0, 2\pi].

Build the table:

tcos tsin t(x, y)
01.0000.000(1.0, 0.0)
π/4 ≈ 0.7850.7070.707(0.71, 0.71)
π/2 ≈ 1.5710.0001.000(0.0, 1.0)
π ≈ 3.142−1.0000.000(−1.0, 0.0)
3π/2 ≈ 4.7120.000−1.000(0.0, −1.0)
2π ≈ 6.2831.0000.000(1.0, 0.0)

Six points trace a hexagon-shaped circle. Six hundred points trace a circle indistinguishable from one drawn with a compass. That is what NumPy's linspace does for you.

The orientation is built in

The table gives you not just the curve but a direction of travel: starting at (1,0)(1, 0), moving up and to the left through (0,1)(0, 1), then down through (1,0)(-1, 0) — counter-clockwise. A Cartesian equation like x2+y2=1x^2 + y^2 = 1 has no orientation. The parametric form does.

Interactive 2D Explorer

Push the play button and watch the pen draw. Drag the tt slider yourself if you want to stop the pen mid-stroke and read the coordinates. Change the curve in the row of buttons, tweak a,b,k,ϕa, b, k, \phi, and see how the shape responds.

Interactive 2D Parametric Explorer

x=Rcost,y=Rsintx = R\cos t,\\ y = R\sin t
t = 0.800(x, y) = (1.39, 1.43)r′(t) = (-1.43, 1.39)speed = 2.000

Cyan dashed = full curve · Cyan solid = trail traced so far · Amber dot = current point · Purple arrow = velocity r(t)=(x(t),y(t))r'(t) = (x'(t),\, y'(t)).

A few things to try, in order:

  1. Pick Circle. Confirm the speed reads r(t)=R|r'(t)| = R (the radius itself). Slide aa and watch both the size and the speed change in lock-step.
  2. Pick Ellipse. Now aba \neq b and the speed is no longer constant — slow at the long ends, fast at the short ends. The particle does not move uniformly even though tt does.
  3. Pick Lissajous. Try k=1k = 1, ϕ=0\phi = 0 — you get a line. Try k=1,ϕ=π/2k = 1, \phi = \pi/2 — you get a circle. Try k=3k = 3 — you get a knot.
  4. Pick Astroid. Look at the four sharp points. The velocity r(t)r'(t) vanishes there — the pen stops for an instant before changing direction. This is the same phenomenon that creates the cusps in the cycloid below.

Eliminating the Parameter

Sometimes we can squeeze the parameter out and recover a familiar Cartesian equation relating xx and yy directly. Two clean tactics:

Tactic 1 — solve for tt, then substitute

For the parametric line

x=1+3t,y=2t,x = 1 + 3t, \qquad y = 2 - t,

solve the first equation: t=(x1)/3t = (x - 1)/3. Substitute into the second:

y=2x13=13x+73.y = 2 - \tfrac{x - 1}{3} = -\tfrac{1}{3}x + \tfrac{7}{3}.

We recovered the Cartesian equation of the line. Notice we lost the velocity information — the Cartesian form tells us where the curve lives but not how it is being traced.

Tactic 2 — use a trig identity

For the parametric circle

x=Rcost,y=Rsint,x = R\cos t, \qquad y = R\sin t,

the Pythagorean identity cos2t+sin2t=1\cos^2 t + \sin^2 t = 1 hands us the answer directly:

(xR)2+(yR)2=1x2+y2=R2.\left(\tfrac{x}{R}\right)^2 + \left(\tfrac{y}{R}\right)^2 = 1 \quad \Longrightarrow \quad x^2 + y^2 = R^2.

Square the coordinates, divide by R2R^2, add. The parameter annihilates itself.

When you CANNOT eliminate t

Many beautiful parametric curves have no single-equation form. The cycloid below, for example, satisfies a Cartesian relation only implicitly and ugly. The Lissajous figures, the helix in 3D, the path of a robotic arm — they live naturally as parametric objects and forcing them into y=f(x)y = f(x) form throws information away. The parametric form is the fundamental one. The Cartesian form is the accident.

The Velocity Vector r(t)r'(t)

Here is where calculus walks in. The particle is at r(t)r(t) at time tt and at r(t+h)r(t + h) a moment later. The average velocity over hh seconds is

r(t+h)r(t)h=(x(t+h)x(t)h, y(t+h)y(t)h).\frac{r(t + h) - r(t)}{h} = \left(\frac{x(t+h)-x(t)}{h},\ \frac{y(t+h)-y(t)}{h}\right).

Take h0h \to 0 on both components independently. The result is the velocity vector:

r(t)=(x(t), y(t)).r'(t) = \bigl(x'(t),\ y'(t)\bigr).

That is the entire calculus of parametric curves in one line. Differentiate each coordinate separately. The vector you get has two properties:

  • Direction: it is tangent to the curve at r(t)r(t) — the instantaneous heading of the particle.
  • Magnitude: r(t)=x(t)2+y(t)2|r'(t)| = \sqrt{x'(t)^2 + y'(t)^2} is the speed — how fast the particle is sweeping along its trail.

Worked check: circle of radius R

Take r(t)=(Rcost,Rsint)r(t) = (R\cos t, R\sin t). Differentiate each component:

r(t)=(Rsint, Rcost).r'(t) = (-R\sin t,\ R\cos t).

The magnitude:

r(t)=R2sin2t+R2cos2t=R2(sin2t+cos2t)=R.|r'(t)| = \sqrt{R^2 \sin^2 t + R^2 \cos^2 t} = \sqrt{R^2(\sin^2 t + \cos^2 t)} = R.

Constant. The particle sweeps the circle at uniform speed RR. Slide the radius slider in the explorer above and watch the "speed" readout track it exactly.

The velocity vector is always perpendicular to the radius vector at the same point. Check: r(t)r(t)=R2costsint+R2sintcost=0r(t) \cdot r'(t) = -R^2 \cos t \sin t + R^2 \sin t \cos t = 0. That is why an orbiting body always moves tangentially.

A Gallery of Classic Curves

Every working scientist and engineer should recognise these on sight. They are the "periodic table" of 2D curves.

NameParametric formWhat it looks likeFamous use
Line(x₀ + at, y₀ + bt)StraightPhysics — uniform motion
Circle(R cos t, R sin t)Closed loopWheels, oscillators, complex roots
Ellipse(a cos t, b sin t)Squashed circlePlanetary orbits (Kepler)
Parabola(t, t²)U-shapeProjectile motion, optics
Lissajous(sin(kt + φ), sin t)Knot / pretzelOscilloscope phase comparison
Astroid(cos³ t, sin³ t)Four-pointed starEnvelope of a sliding ladder
Cycloid(r(t − sin t), r(1 − cos t))Series of archesBrachistochrone — fastest slide
Cardioid(2 cos t − cos 2t, 2 sin t − sin 2t)Heart shapeMicrophone polar patterns
Helix (3D)(R cos t, R sin t, ct)Spiral staircaseDNA, springs, MRI trajectories

Worked Example: The Cycloid by Hand

The cycloid is the path traced by a point on the rim of a wheel rolling along the ground. Its parametric form is

r(t)=(r(tsint), r(1cost)).r(t) = \bigl(r(t - \sin t),\ r(1 - \cos t)\bigr).

Take r=1r = 1 and trace one full arch by hand. Open the panel below, work through every row with pencil and paper, then unpause the rolling animation in the next subsection and watch the same numbers go by in real time.

▶ Click to expand the full hand calculation

Step 1. Start at t=0t = 0. The wheel has not moved at all. The tracked point is at the bottom of the rim:

r(0)=(0sin0, 1cos0)=(0, 0).r(0) = (0 - \sin 0,\ 1 - \cos 0) = (0,\ 0).

Step 2. At t=π/4t = \pi/4:

sin(π/4)0.7071,cos(π/4)0.7071.\sin(\pi/4) \approx 0.7071, \quad \cos(\pi/4) \approx 0.7071.
r(π/4)(π/40.7071, 10.7071)(0.0783, 0.2929).r(\pi/4) \approx (\pi/4 - 0.7071,\ 1 - 0.7071) \approx (0.0783,\ 0.2929).

The point has crept slightly to the right and risen about a quarter of the wheel.

Step 3. At t=π/2t = \pi/2:

sin(π/2)=1,cos(π/2)=0.\sin(\pi/2) = 1, \quad \cos(\pi/2) = 0.
r(π/2)=(π/21, 10)(0.5708, 1.0000).r(\pi/2) = (\pi/2 - 1,\ 1 - 0) \approx (0.5708,\ 1.0000).

We are halfway up the side of the wheel — height 1, which equals the radius.

Step 4. At t=πt = \pi:

sinπ=0,cosπ=1.\sin \pi = 0, \quad \cos \pi = -1.
r(π)=(π0, 1(1))=(π, 2).r(\pi) = (\pi - 0,\ 1 - (-1)) = (\pi,\ 2).

Top of the arch! Height 2 (the diameter), x-coordinate π\pi (half the circumference). The wheel has rolled exactly half a turn.

Step 5. At t=3π/2t = 3\pi/2:

sin(3π/2)=1,cos(3π/2)=0.\sin(3\pi/2) = -1, \quad \cos(3\pi/2) = 0.
r(3π/2)=(3π/2+1, 1)(5.7124, 1.0000).r(3\pi/2) = (3\pi/2 + 1,\ 1) \approx (5.7124,\ 1.0000).

Symmetric mirror of Step 3. Coming down the other side.

Step 6. At t=2πt = 2\pi the wheel has rolled exactly one full turn and the tracked point is back on the ground:

r(2π)=(2π0, 11)=(2π, 0).r(2\pi) = (2\pi - 0,\ 1 - 1) = (2\pi,\ 0).

Distance travelled: 2π2\pi — exactly the circumference of the wheel. That is what "rolling without slipping" means.

tx = t − sin ty = 1 − cos tGeometric meaning
000Touching ground
π/40.07830.2929Starting to lift
π/20.57081.0000Quarter turn — height = R
π3.14162.0000Top of arch — height = 2R
3π/25.71241.0000Mirror of π/2
6.28320Cusp — back on ground

The big payoff. Differentiate each component:

r(t)=(1cost, sint).r'(t) = \bigl(1 - \cos t,\ \sin t\bigr).

At t=0t = 0 and t=2πt = 2\pi both components vanish: r(0)=r(2π)=(0,0)r'(0) = r'(2\pi) = (0, 0). The particle is instantaneously stationary exactly at the moments it kisses the ground — and that is geometrically why those two points are sharp cusps, not smooth curves.

The speed:

r(t)=(1cost)2+sin2t=22cost=2sin(t/2).|r'(t)| = \sqrt{(1 - \cos t)^2 + \sin^2 t} = \sqrt{2 - 2\cos t} = 2\,\bigl|\sin(t/2)\bigr|.

This is zero at t=0,2πt = 0, 2\pi, maxes out at t=πt = \pi with r(π)=2|r'(\pi)| = 2. The point on the rim moves twice as fast as the wheel's centre at the top of the arch — try saying that out loud, it is surprising the first time you hear it.


The Cycloid as a Rolling Wheel

Watch the grey wheel roll. The amber dot is the point on the rim you just hand-computed. The cyan curve is the trail it leaves behind — the cycloid.

The Cycloid — A Rolling Wheel

x=r(tsint), y=r(1cost)x = r(t - \sin t),\ y = r(1 - \cos t)
t = 2.400(x, y) = (1.72, 1.74)

The grey circle is a wheel of radius r=1r = 1 rolling along the ground. The amber dot is a fixed mark on the rim. The cyan curve is the path that mark traces — the cycloid. Notice the sharp cusps every time the dot touches the ground:r(t)=0r'(t) = \mathbf{0} there.

Two things to notice while it rolls:

  • The cusps occur exactly when the amber dot touches the ground — i.e., when the spoke points straight down. That matches the calculation: r(t)=(0,0)r'(t) = (0,0) at t=0,2π,4π,t = 0, 2\pi, 4\pi, \ldots.
  • At the top of each arch the dot is whizzing across the screen — that is the r(π)=2|r'(\pi)| = 2 observation. A point at the top of a rolling wheel moves at twice the speed of the wheel's centre. This is why mudguards exist.

A historical brag

The cycloid is the answer to the brachistochrone problem: of all curves connecting two points AA (higher) and BB (lower), which one allows a bead to slide from AA to BB under gravity in the shortest time? Bernoulli, Newton, and Leibniz all independently proved it is an upside-down arch of the cycloid. A straight line is not the fastest.

Into 3D: The Helix

Parametric thinking generalises to three dimensions for free. Just add a third clock:

r(t)=(x(t), y(t), z(t)).r(t) = \bigl(x(t),\ y(t),\ z(t)\bigr).

The textbook example is the helix: a circle in two coordinates, plus steady linear rise in the third.

r(t)=(Rcost, Rsint, ct).r(t) = \bigl(R\cos t,\ R\sin t,\ c\,t\bigr).

Drop the third coordinate (the "shadow" on the floor) and you see a circle. Drop the first two and you see a straight line. The helix is the union — a circle promoted into space by a constant lift.

Loading 3D helix…

Slide cc to zero and the helix collapses to a circle (the shadow). Crank cc up and the spiral stretches into a near-vertical staircase. The speed

r(t)=R2sin2t+R2cos2t+c2=R2+c2|r'(t)| = \sqrt{R^2 \sin^2 t + R^2 \cos^2 t + c^2} = \sqrt{R^2 + c^2}

is constant — the particle climbs the spiral at uniform speed. The reading on the right of the viewer confirms this in real time.

Why this curve is everywhere

DNA double-helix, telephone-cord coil, spring, fusilli pasta, the screw thread you tightened this morning, the trajectory of a charged particle in a magnetic field, the path of an MRI scanner's sampling pattern — all are helices. The same six characters (Rcost,Rsint,ct)(R\cos t, R\sin t, ct) describe every one of them.

Python Implementation

Time to make this concrete. We will plot the parametric circle in plain Python with NumPy, then read the velocity vector off the analytic derivative. The whole script is twenty lines.

Parametric circle, plotted + velocity by hand
🐍parametric_circle.py
1Import NumPy

NumPy gives us cos, sin and linspace — all vectorised so we can evaluate r(t) on hundreds of t-values in one call instead of looping.

EXAMPLE
np.cos(np.array([0, 1.5]))  ->  array([1.0000, 0.0707])
2Import matplotlib

pyplot is the standard plotting library. We use it only to draw the traced curve; the math is all NumPy.

4Define the parametric circle

One function returns BOTH coordinates of r(t). The parametric mindset: stop thinking 'y of x' — think 'two clocks of t'. Here cos drives x, sin drives y.

5Docstring

Always state what the function returns. For parametric curves the return type is a tuple (x, y) — not a single y.

6x(t) = R cos t

Because t and R are arrays/numbers and np.cos is vectorised, this single line works whether t is a scalar or a length-200 array. Same code, different sizes.

7y(t) = R sin t

The second clock. The PAIR (cos, sin) is what generates the circle — neither half alone does.

8Return the pair

Tuples are the natural shape of a parametric output. Downstream code unpacks x, y = ... in a single line.

11Sample t on [0, 2π]

linspace(0, 2π, 200) builds 200 equally-spaced t-values. 200 is enough that adjacent points are visually indistinguishable when plotted.

EXAMPLE
np.linspace(0, 2*np.pi, 5) -> [0, 1.57, 3.14, 4.71, 6.28]
14Vectorised evaluation

One call evaluates r(t) at all 200 samples. Both x and y come back as length-200 arrays. No Python loop — NumPy runs the math in C.

17Pick a specific instant t0 = π/4

We want to demonstrate the velocity vector at one point. π/4 is convenient — the point is exactly halfway up the upper-right quadrant of the circle.

18Reuse the same function on a scalar

Because parametric_circle is vectorised, calling it with a single scalar t0 returns scalar x0, y0. No special case needed.

19Velocity by hand

r(t) = (R cos t, R sin t), so r'(t) = (-R sin t, R cos t). We plug t0 in directly. The derivative of a parametric curve is just the pair of derivatives.

20Speed = |r'(t)|

np.hypot(vx, vy) = sqrt(vx² + vy²). For a circle of radius R this should equal R itself — the particle covers R units of arc per unit of t.

EXAMPLE
For R = 1.5 we expect 1.5000 every time.
21Print the point

Expected: (1.0607, 1.0607) — perfectly diagonal, since cos(π/4) = sin(π/4) = √2/2 ≈ 0.7071, times R = 1.5.

22Print the velocity

Expected: (-1.0607, 1.0607). It points perpendicular to the radius (you can verify: dot product with the point vector is 0).

23Print the speed

Expected: 1.5000. The speed equals the radius R — a uniform sweep around the circle.

26Open a square figure

(5, 5) keeps the figure square so the circle does not look like an ellipse.

27Plot the curve

plt.plot draws the 200 sampled points connected by straight segments. The eye sees a smooth circle because the spacing is dense.

28Velocity arrow

plt.arrow draws a vector starting at (x0, y0) with displacement (vx*0.3, vy*0.3). The 0.3 is just a visual scale so the arrow is not the size of the whole plot.

29Mark the current point

scatter places a single dot exactly at r(t0). zorder=5 makes sure it sits on top of the curve.

30Equal aspect ratio

Without this, the plot would stretch and the circle would look like an ellipse. Always set aspect equal for geometric curves.

13 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3
4def parametric_circle(t, R=1.5):
5    """Return (x, y) on a circle of radius R for parameter t."""
6    x = R * np.cos(t)
7    y = R * np.sin(t)
8    return x, y
9
10# Sample the parameter t from 0 to 2 pi
11t = np.linspace(0.0, 2 * np.pi, 200)
12
13# Vectorised evaluation: shape (200,)
14x, y = parametric_circle(t, R=1.5)
15
16# Velocity vector at a chosen instant t0 = pi / 4
17t0 = np.pi / 4
18x0, y0 = parametric_circle(t0, R=1.5)
19vx, vy = -1.5 * np.sin(t0), 1.5 * np.cos(t0)
20speed = np.hypot(vx, vy)
21print(f"point  at t0  = ({x0:.4f}, {y0:.4f})")
22print(f"r'(t0)        = ({vx:.4f}, {vy:.4f})")
23print(f"|r'(t0)|      = {speed:.4f}")
24
25# Plot the trace and the velocity arrow at t0
26plt.figure(figsize=(5, 5))
27plt.plot(x, y, color="#22d3ee", lw=2, label="r(t)")
28plt.arrow(x0, y0, vx*0.3, vy*0.3, head_width=0.08, color="#a78bfa")
29plt.scatter([x0], [y0], color="#f59e0b", zorder=5)
30plt.gca().set_aspect("equal")
31plt.grid(True, alpha=0.3)
32plt.title("Parametric circle r(t) = (R cos t, R sin t)")
33plt.legend()
34plt.show()

Expected output when you run the script:

point  at t0  = (1.0607, 1.0607)
r'(t0)        = (-1.0607, 1.0607)
|r'(t0)|      = 1.5000

Match? Good. Now the speed is exactly the radius, as the calculus predicts. Twenty lines of code, and you have the curve, the velocity, the speed, and a picture.


PyTorch & Autograd: Letting the Computer Differentiate

In the NumPy code above, we differentiated r(t)r(t) by hand and typed the result (Rsint,Rcost)(-R\sin t, R\cos t) into the script. That works for elementary curves. For a complicated r(t)r(t) — say, the position of a robot end-effector after seven chained rotations — you do not want to differentiate by hand. You want PyTorch to do it for you.

Autograd derives r'(t) automatically
🐍parametric_autograd.py
1Import torch

torch is the only library we need — same NumPy-like API, plus the autograd engine. No matplotlib here; we are confirming calculus numerically.

2Import pi

Plain Python's pi is fine for a scalar tensor. PyTorch also has torch.pi if you prefer.

5Parameter t with requires_grad=True

This is the magic line. Setting requires_grad=True tells autograd: 'remember every operation that touches t so I can differentiate later.' Without it, autograd silently does nothing.

EXAMPLE
t = torch.tensor(0.5, requires_grad=True)
6Fix R = 1.5

Plain Python float — not a tensor — because R is a constant, not something we want to differentiate with respect to.

9x = R cos t

torch.cos is differentiable. autograd records this op in the computation graph attached to t. x is now a tensor that 'remembers' its origin.

10y = R sin t

Same idea. After this, the graph attached to t has two leaves: x and y. We can ask for the derivative of either with respect to t.

13Get dx/dt

torch.autograd.grad(x, t) walks the graph backward and returns the gradient as a 1-tuple. retain_graph=True keeps the graph alive so we can call grad again on y.

EXAMPLE
If we forget retain_graph=True, line 14 raises 'graph has been freed'.
14Get dy/dt

Second autograd call. No retain_graph needed because this is the last call — the graph can be freed now.

16Compute the speed

Element-wise square, sum, sqrt — still tensor operations. speed itself is a 0-d tensor we can .item() to get a Python float.

18Print the point

Expected: (1.0607, 1.0607). Numerically identical to the NumPy version on the previous slide — same math, different engine.

19Print the autograd-derived velocity

Expected: (-1.0607, 1.0607). We never wrote the formula r'(t) = (-R sin t, R cos t) — autograd discovered it from the chain rule applied to cos and sin.

20Print the speed

Expected: 1.5000 — the radius. This is the KEY check that the parametric circle has CONSTANT speed.

23Build the analytic answer

(-R sin t, R cos t) evaluated at the same t0 we used above. Detached scalars (.item()) avoid building a second graph.

24Stack the autograd answer

torch.stack glues the two scalar tensors into a length-2 vector. .detach() removes the graph so comparison is purely numerical.

25Assert numerical equality

torch.allclose with atol=1e-6 is the standard 'are these effectively the same?' check. Autograd is exact up to floating-point rounding for elementary functions like cos and sin.

26Confirmation print

If we reach this line, the assertion passed — autograd and the textbook formula agree. This is exactly the calculus identity d/dt (R cos t, R sin t) = (-R sin t, R cos t).

10 lines without explanation
1import torch
2from math import pi
3
4# Parameter t with autograd tracking
5t = torch.tensor(pi / 4, requires_grad=True)
6R = 1.5
7
8# r(t) = (R cos t, R sin t)
9x = R * torch.cos(t)
10y = R * torch.sin(t)
11
12# r'(t) = (dx/dt, dy/dt) — autograd derives each component for us
13(dx_dt,) = torch.autograd.grad(x, t, retain_graph=True)
14(dy_dt,) = torch.autograd.grad(y, t)
15
16speed = torch.sqrt(dx_dt ** 2 + dy_dt ** 2)
17
18print(f"r(t0)    = ({x.item():.4f}, {y.item():.4f})")
19print(f"r'(t0)   = ({dx_dt.item():.4f}, {dy_dt.item():.4f})")
20print(f"|r'(t0)| = {speed.item():.4f}   # expect 1.5000")
21
22# Sanity check against analytic derivative
23expected = torch.tensor([-R * torch.sin(t).item(), R * torch.cos(t).item()])
24got      = torch.stack([dx_dt, dy_dt]).detach()
25assert torch.allclose(expected, got, atol=1e-6)
26print("autograd matches analytic derivative ✓")

Expected output:

r(t0)    = (1.0607, 1.0607)
r'(t0)   = (-1.0607, 1.0607)
|r'(t0)| = 1.5000   # expect 1.5000
autograd matches analytic derivative ✓
Autograd discovered the formula ddtcost=sint\tfrac{d}{dt}\cos t = -\sin t by walking backward through the computational graph. We never typed it. This is the bridge between pencil-and-paper calculus and modern machine learning — every neural network is, at heart, a long chain of parametric maps whose derivatives are computed by exactly this mechanism.

Real-World Applications

DomainParametric curve at play
Computer graphicsEvery spline (Bézier, B-spline, NURBS) is parametric. Type designers, CAD systems, animation rigs all use t ∈ [0, 1] interpolation.
RoboticsEnd-effector trajectories are r(t) = (x(t), y(t), z(t)). Velocity and acceleration matter for safe motion — both are derivatives of the parametric form.
Physics — orbitsKepler's ellipses are most naturally written parametrically; eliminating t loses the time-of-flight information needed for spacecraft rendezvous.
Signal processingLissajous figures on an oscilloscope are the parametric trace (x(t), y(t)) of two phase-locked sine waves. Used to calibrate frequencies.
Machine learningDiffusion models follow a parametric SDE x(t) from noise (t = 0) to data (t = 1). The 'curve' is in latent space but the calculus is the same.
Differential geometryGeodesics on curved surfaces are parametric curves r(t) satisfying r''(t) = 0 (in the intrinsic sense). The whole subject is built on this.
BiologyBacterial flagella, virus capsids, DNA, plant phyllotaxis — helices and spirals everywhere. All parametric.
EngineeringCam profiles, gear teeth, roller-coaster tracks — designed parametrically because the velocity / acceleration constraints are first-class.

Common Pitfalls

1. Same curve, different parametrisation

(cost,sint)(\cos t, \sin t) and (cos2t,sin2t)(\cos 2t, \sin 2t) trace the same circle, but the second goes around twice as fast. Different velocity, same trail. Always ask: do I care about the path, or about the motion?

2. Direction of travel matters

(cost,sint)(\cos t, \sin t) goes counter-clockwise. (cost,sint)(\cos t, -\sin t) goes clockwise. Same circle, opposite orientation. In physics this is the difference between "orbits Earth eastward" and "orbits Earth westward".

3. Eliminating t can lose information

(cost,sint)(\cos t, \sin t) for t[0,π]t \in [0, \pi] traces only the upper half of the circle. Eliminate the parameter and you get x2+y2=1x^2 + y^2 = 1 — the entire circle. You quietly added the lower half. Always carry the parameter range with you.

4. Cusps and self-intersections

Whenever r(t)=0r'(t) = \mathbf{0}, the curve may have a corner (cusp). Whenever r(t1)=r(t2)r(t_1) = r(t_2) with t1t2t_1 \neq t_2, the curve crosses itself. Cartesian formulas hide both. Parametric forms wear them on their sleeves.

Summary

A parametric representation describes a curve by giving the position of a moving point as a function of a parameter:

r(t)=(x(t), y(t))orr(t)=(x(t), y(t), z(t)).r(t) = \bigl(x(t),\ y(t)\bigr) \quad \text{or} \quad r(t) = \bigl(x(t),\ y(t),\ z(t)\bigr).
  1. The parameter tt is a clock; the curve is the trail the moving point leaves behind.
  2. The velocity vector r(t)=(x(t),y(t))r'(t) = (x'(t), y'(t)) is the derivative of each component. Its magnitude is the scalar speed r(t)|r'(t)|; its direction is tangent to the curve.
  3. Eliminating tt sometimes recovers y=f(x)y = f(x) — by solving for tt or by a trig identity — but loses orientation, speed, and parameter range.
  4. Cusps occur where r(t)=0r'(t) = \mathbf{0} (the pen pauses); self-intersections occur where two distinct tt give the same point.
  5. NumPy evaluates parametric curves vectorially in one call. PyTorch autograd computes r(t)r'(t) for any curve you can write down — the formula you would have differentiated by hand emerges from the chain rule the engine applies behind the scenes.
  6. The classic curves — circle, ellipse, Lissajous, astroid, cycloid, helix — are the working vocabulary of physics, graphics, robotics, biology, and machine learning. You will meet every one of them again.
The takeaway. A curve is not a graph; it is the history of a moving point. Once you adopt that mindset, every curve in the universe becomes a small program — two or three clocks, ticked through their range, leaving a trail.
Loading comments...