TExcelTAD
Home › Calculus in Depth › Polar Coordinates

Polar Coordinates

Polar coordinates locate a point by its distance from the origin and its angle, instead of by xx and yy. Circles centred at the origin, spirals, roses and orbits all have far simpler equations in polar form. This lesson covers conversion (including the atan2 detail that trips up programmers), graphing and symmetry, and tangent lines to polar curves.

Definition

Choose a point OO (the pole) and a ray from it (the polar axis, usually the positive xx-axis). A point PP has polar coordinates (r,θ)(r, \theta) when it is at distance rr from OO along the ray that makes angle θ\theta with the polar axis, measured anticlockwise. Two conventions make every pair (r,θ)(r, \theta) meaningful:

  • (r,θ)(r, \theta) and (r,θ+2πk)(r, \theta + 2\pi k) are the same point, for every integer kk;
  • a negative rr means "go ∣r∣\lvert r \rvert in the opposite direction": (−r,θ)=(r,θ+π)(-r, \theta) = (r, \theta + \pi).

So, unlike Cartesian coordinates, every point has infinitely many polar representations, and the pole is (0,θ)(0, \theta) for any θ\theta. This non-uniqueness is the source of most polar pitfalls, such as missing intersection points of two curves.

Converting

x=rcos⁡θr2=x2+y2y=rsin⁡θtan⁡θ=y/x(x≠0)\begin{aligned} x &= r\cos\theta & r^2 &= x^2 + y^2 \\ y &= r\sin\theta & \tan\theta &= y/x \quad (x \ne 0) \end{aligned}

The second column does not determine θ\theta by itself: tan⁡θ=y/x\tan\theta = y/x gives the same value for (1,1)(1, 1) and (−1,−1)(-1, -1). arctan⁡(y/x)\arctan(y/x) only returns angles in (−π/2,π/2)(-\pi/2, \pi/2), so you must pick the quadrant from the signs of xx and yy. Every programming language provides this as atan2(y, x), which returns the correct angle in (−π,π](-\pi, \pi] (see atan2).

python · try it yourself
import math

points = [(1, 1), (-1, -1), (-3, 4), (0, -2)]
for x, y in points:
    naive = math.atan(y / x) if x != 0 else float("nan")
    th = math.atan2(y, x)
    r = math.hypot(x, y)
    back = (round(r * math.cos(th), 12) + 0.0, round(r * math.sin(th), 12) + 0.0)
    print(f"({x:2}, {y:2}): r = {r:.4f}, atan2 = {math.degrees(th):8.3f}°, "
          f"atan(y/x) = {math.degrees(naive):8.3f}°, back to {back}")
( 1,  1): r = 1.4142, atan2 =   45.000°, atan(y/x) =   45.000°, back to (1.0, 1.0)
(-1, -1): r = 1.4142, atan2 = -135.000°, atan(y/x) =   45.000°, back to (-1.0, -1.0)
(-3,  4): r = 5.0000, atan2 =  126.870°, atan(y/x) =  -53.130°, back to (-3.0, 4.0)
( 0, -2): r = 2.0000, atan2 =  -90.000°, atan(y/x) =      nan°, back to (0.0, -2.0)

For (−1,−1)(-1, -1) the naive formula returns 45°, a point in the first quadrant, while atan2 correctly returns −135°.

Polar curves

A polar curve is the set of points whose polar coordinates satisfy an equation, usually r=f(θ)r = f(\theta). Converting is often the quickest way to recognise one:

Polar Cartesian Curve
r=3r = 3 x2+y2=9x^2 + y^2 = 9 circle, centre OO
θ=π/6\theta = \pi/6 y=x/3y = x/\sqrt{3} line through OO
r=4sin⁡θr = 4\sin\theta x2+(y−2)2=4x^2 + (y - 2)^2 = 4 circle through OO (multiply by rr: r2=4rsin⁡θr^2 = 4r\sin\theta)
r=2sec⁡θr = 2\sec\theta x=2x = 2 vertical line
r=1+cos⁡θr = 1 + \cos\theta (x2+y2−x)2=x2+y2(x^2 + y^2 - x)^2 = x^2 + y^2 cardioid
r=cos⁡(kθ)r = \cos(k\theta) — rose with kk petals (kk odd) or 2k2k petals (kk even)
r=aθr = a\theta — Archimedean spiral: equally spaced turns
r=ebθr = e^{b\theta} — logarithmic spiral: crosses every ray at the same angle

Symmetry tests (sufficient, not necessary):

  • unchanged when θ→−θ\theta \to -\theta: symmetric about the polar axis (xx-axis);
  • unchanged when r→−rr \to -r, or when θ→θ+π\theta \to \theta + \pi: symmetric about the pole;
  • unchanged when θ→π−θ\theta \to \pi - \theta: symmetric about the line θ=π/2\theta = \pi/2 (yy-axis).

Why the rose has kk or 2k2k petals. For r=cos⁡(kθ)r = \cos(k\theta) with kk odd, cos⁡(k(θ+π))=−cos⁡(kθ)\cos(k(\theta + \pi)) = -\cos(k\theta), so the second half-turn π≤θ≤2π\pi \le \theta \le 2\pi retraces the first half: only kk petals appear. For kk even, cos⁡(k(θ+π))=cos⁡(kθ)\cos(k(\theta + \pi)) = \cos(k\theta) while the point (r,θ+π)(r, \theta + \pi) is opposite (r,θ)(r, \theta), so the second half draws kk new petals: 2k2k in total.

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

def polar_xy(th, r):                 # apply the (−r, θ) = (r, θ + π) rule
    return np.where(r < 0, th + np.pi, th), np.abs(r)

th = np.linspace(0, 2 * np.pi, 2000)
fig, axes = plt.subplots(1, 3, figsize=(10, 3.8), subplot_kw={"projection": "polar"})
axes[0].plot(*polar_xy(th, np.cos(3 * th))); axes[0].set_title("r = cos 3θ (3 petals)")
axes[1].plot(*polar_xy(th, np.cos(4 * th))); axes[1].set_title("r = cos 4θ (8 petals)")
t6 = np.linspace(0, 6 * np.pi, 3000)
axes[2].plot(t6, 0.5 * t6, label="r = θ/2")
axes[2].plot(t6, np.exp(0.15 * t6) - 1, label="r = e^(0.15θ) − 1")
axes[2].set_title("spirals"); axes[2].legend(loc="upper center", bbox_to_anchor=(0.5, -0.12), fontsize=7)
for ax in axes:
    ax.set_rlim(0, None); ax.set_yticklabels([])
plt.tight_layout(); plt.show()

# Matplotlib does not apply the negative-r rule itself, so polar_xy does it
print("r = cos 3θ is negative on", round(float(np.mean(np.cos(3 * th) < 0)) * 100), "% of [0, 2π]")
r = cos 3θ is negative on 50 % of [0, 2π]

Tangents to polar curves

Treat θ\theta as a parameter: x=f(θ)cos⁡θx = f(\theta)\cos\theta, y=f(θ)sin⁡θy = f(\theta)\sin\theta. With r′=dr/dθr' = dr/d\theta, the parametric slope formula gives

dydx=dy/dθdx/dθ=r′sin⁡θ+rcos⁡θr′cos⁡θ−rsin⁡θ\frac{dy}{dx} = \frac{dy/d\theta}{dx/d\theta} = \frac{r'\sin\theta + r\cos\theta}{r'\cos\theta - r\sin\theta}

At the pole (r=0r = 0, r′≠0r' \ne 0) this collapses to dy/dx=tan⁡θdy/dx = \tan\theta: the curve passes through the pole along the ray at angle θ\theta. For the rose r=cos⁡3θr = \cos 3\theta, the zeros θ=π/6,π/2,5π/6\theta = \pi/6, \pi/2, 5\pi/6 are exactly the directions in which the petals meet at the centre.

python · try it yourself
import sympy as sp

th = sp.symbols("theta", real=True)
r = 1 + sp.cos(th)                        # cardioid
x, y = r * sp.cos(th), r * sp.sin(th)
slope = sp.simplify(y.diff(th) / x.diff(th))
print("dy/dx =", slope)
print("slope at θ = π/3:", sp.simplify(slope.subs(th, sp.pi / 3)))
print("horizontal tangents:", sp.solve(sp.Eq(y.diff(th), 0), th))
print("vertical tangents:  ", sp.solve(sp.Eq(x.diff(th), 0), th))
print("at θ = π: dx/dθ =", x.diff(th).subs(th, sp.pi), ", dy/dθ =", y.diff(th).subs(th, sp.pi))
dy/dx = -(cos(theta) + cos(2*theta))/(sin(theta) + sin(2*theta))
slope at θ = π/3: 0
horizontal tangents: [-pi/3, pi/3]
vertical tangents:   [0, -2*pi/3, 2*pi/3]
at θ = π: dx/dθ = 0 , dy/dθ = 0

By hand, dy/dθ=cos⁡θ+cos⁡2θ=(2cos⁡θ−1)(cos⁡θ+1)dy/d\theta = \cos\theta + \cos 2\theta = (2\cos\theta - 1)(\cos\theta + 1) and dx/dθ=−sin⁡θ(1+2cos⁡θ)dx/d\theta = -\sin\theta(1 + 2\cos\theta), so both also vanish at θ=π\theta = \pi, a root SymPy's lists happen to leave out (always check candidate points by substitution; the slope formula is 0/00/0 there). The last line confirms it: θ=π\theta = \pi is the cusp of the cardioid at the pole, not a horizontal or vertical tangent.

In software

  • Radial menus, gauges and pie charts place items at (cx+Rcos⁡θi, cy+Rsin⁡θi)(cx + R\cos\theta_i,\ cy + R\sin\theta_i) and find the item under the mouse with atan2.
  • Bullet-hell and particle patterns are polar curves: rotate the emission angle by a constant each frame and you get a spiral; modulate radius by cos⁡(kθ)\cos(k\theta) and you get a rose.
  • Shaders convert UVs to polar coordinates (length(uv), atan(uv.y, uv.x)) to draw rings, radar sweeps and kaleidoscopes.
  • Procedural generation: spiral galaxies use logarithmic spirals; sunflower-style point layouts use r=cnr = c\sqrt{n}, θ=n⋅137.5∘\theta = n \cdot 137.5^\circ.
  • Signal processing: complex numbers in polar form reiθr e^{i\theta} (magnitude and phase) are the language of the FFT.

Exercises

Exercise 1: Convert to Cartesian

Convert the point (r,θ)=(4,5π/6)(r, \theta) = (4, 5\pi/6) to Cartesian coordinates and give one other polar representation with negative rr.

Answer

(−23,2)(-2\sqrt{3}, 2); for example (−4,−π/6)(-4, -\pi/6).

Solution
x=4cos⁡5π6=4⋅(−32)=−23,y=4sin⁡5π6=4⋅12=2(−4,θ) is (4,θ+π), so θ+π=5π6+2πk  ⇒  θ=−π6 works.\begin{aligned} &x = 4\cos\tfrac{5\pi}{6} = 4 \cdot \left(-\tfrac{\sqrt{3}}{2}\right) = -2\sqrt{3}, \qquad y = 4\sin\tfrac{5\pi}{6} = 4 \cdot \tfrac{1}{2} = 2 \\ &(-4, \theta) \text{ is } (4, \theta + \pi), \text{ so } \theta + \pi = \tfrac{5\pi}{6} + 2\pi k \;\Rightarrow\; \theta = -\tfrac{\pi}{6} \text{ works.} \end{aligned}

Exercise 2: Identify the curve

Show that r=6cos⁡θr = 6\cos\theta is a circle and find its centre and radius.

Answer

Circle with centre (3,0)(3, 0) and radius 3.

Solution
r2=6rcos⁡θ  ⇒  x2+y2=6x  ⇒  (x−3)2+y2=9r^2 = 6r\cos\theta \;\Rightarrow\; x^2 + y^2 = 6x \;\Rightarrow\; (x - 3)^2 + y^2 = 9

(Multiplying by rr adds only the pole, which is already on the curve at θ=π/2\theta = \pi/2.)

Exercise 3: Polar angle in code

Write a function that returns the polar angle of (x,y)(x, y) in degrees in [0,360)[0, 360), and test it on (0,1)(0, 1), (−1,0)(-1, 0), (1,−1)(1, -1) and (−2,−23)(-2, -2\sqrt{3}).

Answer

90.0, 180.0, 315.0, 240.0

Solution

atan2 returns (−180∘,180∘](-180^\circ, 180^\circ]; add 360 and reduce mod 360. For (−2,−23)(-2, -2\sqrt{3}): r=4r = 4, the reference angle is 60° and the point is in the third quadrant, so 240°.

python · try it yourself
import math

def polar_deg(x, y):
    return round(math.degrees(math.atan2(y, x)) % 360, 9)

print([polar_deg(*p) for p in [(0, 1), (-1, 0), (1, -1), (-2, -2 * math.sqrt(3))]])
[90.0, 180.0, 315.0, 240.0]

Exercise 4: Petals and tangents at the pole

How many petals does r=sin⁡5θr = \sin 5\theta have, and in which directions does the curve pass through the pole for 0≤θ<π0 \le \theta < \pi?

Answer

5 petals; through the pole at θ=0,π/5,2π/5,3π/5,4π/5\theta = 0, \pi/5, 2\pi/5, 3\pi/5, 4\pi/5.

Solution

k=5k = 5 is odd, so the curve has 5 petals (the interval [0,π][0, \pi] already draws them all). At the pole r=0r = 0, i.e. sin⁡5θ=0\sin 5\theta = 0, so θ=kπ/5\theta = k\pi/5; since r′=5cos⁡5θ≠0r' = 5\cos 5\theta \ne 0 there, the tangent at the pole is the ray at that angle.

Test yourself

Which polar coordinates describe the same point as (2,π/3)(2, \pi/3)?

  1. (2,−π/3)(2, -\pi/3)
  2. (−2,4π/3)(-2, 4\pi/3)
  3. (−2,π/3)(-2, \pi/3)
  4. (2,4π/3)(2, 4\pi/3)

Why do programs use atan2(y, x) instead of atan(y/x) to get the polar angle?

  1. It is faster
  2. It picks the correct quadrant and handles x=0x = 0
  3. It returns degrees
  4. It returns rr as well

How many petals does r=cos⁡6θr = \cos 6\theta have?

  1. 3
  2. 6
  3. 12
  4. 24