mathprecalc

trig

sine, cosine and tangent as a point going around the unit circle.

report a mistake
.md

a point walks around the unit circle, the circle of radius 1 centered at the origin. the angle is how far it has walked, its height is the sine, its x is the cosine, and the slope of the line to it is the tangent. everything else follows from that picture.

radians
θ = arc / radius a full turn is 2π ≈ 6.28, so 1 rad ≈ 57.3°
the point
(cos θ, sin θ) x first, then y
tan θ
sin θ / cos θ no value where cos θ = 0
pythagoras
sin²θ + cos²θ = 1 the radius is 1
period
2π a full turn changes nothing
arcsin
[−π/2, π/2] one angle of the two in each turn
reach for it
  • an angle to a direction, and a direction back to an angle
  • anything that turns or repeats: rotation, waves, orbits
  • a right triangle with one side and one angle known
on this page
  1. the idea
  2. explore
  3. try it
  4. the rules
  5. worked examples
  6. the key idea up close
  7. pitfalls
  8. practice
  9. sources

the idea

put a point on the unit circle, the circle of radius 1 centered at the origin, and let it walk counter-clockwise from (1, 0). every question in trig is a question about that point. how far has it walked? that’s the angle. how high is it? the sine. how far to the right? the cosine. how steep is the line from the center to it? the tangent. the graphs are what you get by writing those down as it goes around.

a point walks around the unit circle, starting at (1, 0). the angle θ\theta is how far it has walked along the arc: π/2≈1.57\pi/2 \approx 1.57 at the top, π\pi at the far left, 2π≈6.282\pi \approx 6.28 for the full turn. the same length is laid along the axis of the graph beside it.

an animation in four laps of the unit circle, with a graph beside it. first a point walks around from (1, 0): the angle θ is the arc it has walked, π/2 ≈ 1.57 at the top and 2π ≈ 6.28 for the full turn, and the same length is laid along the axis of the graph. second lap: the point's height, sin θ, is plotted against θ and draws the sine wave: 0, then 1 at π/2, 0 at π, −1 at 3π/2, 0 at 2π. third lap: its x, cos θ, draws the same wave a quarter turn ahead: 1 at 0, 0 at π/2, −1 at π. fourth lap: tan θ, the slope of the radius, read off where the extended radius meets the line x = 1: 0 at 0, 1 at π/4, off the top near π/2 and back from the bottom past it, with no value at π/2 and 3π/2.

explore

−101−101sin θcos θ0π/2π3π/22π−101θ

drag the point around the circle, or tab to it and use the arrow keys: 5° a step, 15° with shift

θ
60° = π/3 ≈ 1.047
sin θ, the height
√3/2 ≈ 0.866
cos θ, the x
1/2
tan θ, the slope
√3 ≈ 1.732

quadrant I: the point is right of the y axis and above the x axis, so cos θ is positive, sin θ is positive and tan θ is positive.

a point on the unit circle, at 60° to start, with the line from the center to it, its height in cyan, its x in amber, and the slope of the radius measured up the line x = 1. beside it, a graph of sin in cyan and cos in amber from 0 to 2π with the same angle marked, level with the point. drag the point, or tab to it and use the arrow keys, and the readout follows: θ in degrees and radians, 60° = π/3 ≈ 1.047 to start, sin θ = √3/2 ≈ 0.866, cos θ = 1/2, tan θ = √3 ≈ 1.732, and the quadrant with the sign of each. at 90° and 270° tan reads undefined.

the dashed line from the point to the graph is its height. on the circle it's sin θ; on the graph it's the point at (θ, sin θ).

try it

θ is between π/2 and π, in quadrant II. what are the signs of (cos θ, sin θ)?

II

pick one.

0 / 0 right

a practice exercise with a small circle under each question: the signs of cos θ and sin θ in a quadrant, the exact value of sin, cos or tan at a special angle like 2π/3, and degrees to radians and back. after an answer the circle shows the legs with their signs or their exact values.

the rules

radians

θ=sr2π rad=360∘1 rad=180∘π≈57.3∘\begin{gathered} \theta = \frac{s}{r} \\[6pt] 2\pi \text{ rad} = 360^\circ \\[6pt] 1 \text{ rad} = \frac{180^\circ}{\pi} \approx 57.3^\circ \end{gathered}

an angle in radians is the length of arc it cuts out of the unit circle. a full turn is the whole circumference, 2π ≈ 6.28, a half turn is π, and a right angle is π/2 ≈ 1.57. it holds on any circle: an arc on a circle of radius r is r times longer, so arc over radius depends on the angle alone. to convert, multiply by π/180 one way and by 180/π the other: 90° = π/2, 60° = π/3, 45° = π/4, 30° = π/6, and 1° = π/180 ≈ 0.01745.

the point

(x,y)=(cos⁡θ, sin⁡θ)tan⁡θ=sin⁡θcos⁡θ\begin{gathered} (x, y) = (\cos\theta,\ \sin\theta) \\[6pt] \tan\theta = \frac{\sin\theta}{\cos\theta} \end{gathered}

the point at angle θ is (cos θ, sin θ). that is the definition: cos is the x and sin is the y, for any θ, including angles past 90° and negative ones, where no triangle fits. tan θ is the slope of the radius, rise over run. it has no value where cos θ = 0, at π/2, 3π/2 and every half turn from there: the radius is vertical, and a vertical line has no slope.

signs by quadrant

sin is the height, so it’s positive above the x axis: quadrants I and II. cos is the x, positive to the right of the y axis: I and IV. tan is their ratio, positive where they have the same sign: I and III.

quadrantθcos θsin θtan θ
I0 to π/2+++
IIπ/2 to π−+−
IIIπ to 3π/2−−+
IV3π/2 to 2π+−−

the special angles

θ0π/6π/4π/3π/2
degrees0°30°45°60°90°
sin θ01/2√2/2√3/21
cos θ1√3/2√2/21/20
tan θ0√3/31√3none

tan has no value at π/2, where cos is 0. two triangles explain the rest of the table. cut a square with a diagonal of 1 in half along the diagonal: the two legs are equal, and pythagoras gives each one √2/2 ≈ 0.707, so sin and cos at 45° are both √2/2 and tan is 1. cut an equilateral triangle of side 1 down the middle: the half base is 1/2, the height is √(1 − 1/4) = √3/2 ≈ 0.866, and the corners are 60° at the base and 30° at the top. so at 60° the height √3/2 is sin and the half base 1/2 is cos, and at 30° they swap. tan at 30° is (1/2) / (√3/2) = 1/√3 = √3/3 ≈ 0.577.

three right triangles. the first has θ at its left corner, with the hypotenuse, the side opposite θ in cyan and the side adjacent to it in amber. the second is an equilateral triangle of side 1 cut down the middle: the left half has a base of 1/2, a height of √3/2, a corner of π/3 at the bottom and π/6 at the top. the third is a square with a diagonal of 1 cut along the diagonal: the lower half has two legs of √2/2 and a corner of π/4.

sin is the cyan side over the hypotenuse, cos the amber one. with the hypotenuse 1, they're the sides themselves.

for an angle outside the first quadrant, take its reference angle, how far it is from the x axis, read the size off the table, and put the sign in from the quadrant: 5π/6 is π/6 short of π, in quadrant II, so sin(5π/6) = 1/2 and cos(5π/6) = −√3/2.

do that for every multiple of 30° and 45° and you have the unit circle chart: 16 angles, each with its radians and its exact point. the sizes are the first quadrant’s, four times over. only the signs change.

0°30°45°60°90°120°135°150°180°210°225°240°270°300°315°330°

tap a point to pick it, or tab into the chart and use the arrow keys. Home is 0°, End is 330°

θ
150° = 5π/6 ≈ 2.618
cos θ, the x
−√3/2 ≈ −0.866
sin θ, the height
1/2

quadrant II: the reference angle is 30°, so the legs are the ones at 30° with cos θ negative and sin θ positive.

the 16 special angles as points on the unit circle, each labeled with its degrees, and on a wide screen with its radians and exact (cos θ, sin θ) too: 0° = 0: (1, 0); 30° = π/6: (√3/2, 1/2); 45° = π/4: (√2/2, √2/2); 60° = π/3: (1/2, √3/2); 90° = π/2: (0, 1); 120° = 2π/3: (−1/2, √3/2); 135° = 3π/4: (−√2/2, √2/2); 150° = 5π/6: (−√3/2, 1/2); 180° = π: (−1, 0); 210° = 7π/6: (−√3/2, −1/2); 225° = 5π/4: (−√2/2, −√2/2); 240° = 4π/3: (−1/2, −√3/2); 270° = 3π/2: (0, −1); 300° = 5π/3: (1/2, −√3/2); 315° = 7π/4: (√2/2, −√2/2); 330° = 11π/6: (√3/2, −1/2). tap a point, or tab into the chart and use the arrow keys, Home and End, to pick one: the chart draws its x in amber and its height in cyan, and the readout gives its degrees, radians and exact (cos θ, sin θ). it starts at 150° = 5π/6 ≈ 2.618, with cos θ = −√3/2 ≈ −0.866 and sin θ = 1/2. on a phone a button opens the full chart in a frame that scrolls sideways. buttons under the chart save, copy or share the full chart as an image.

cos θ is the x in amber, sin θ the height in cyan. 150° and 30° have the same two sizes, with the x flipped.

pythagoras on the circle

sin⁡2θ+cos⁡2θ=1\sin^2\theta + \cos^2\theta = 1

the point is on the circle of radius 1, so its distance from the origin is 1, and its coordinates are cos θ and sin θ. pythagoras on the two legs is the identity. it’s why one of sin and cos pins down the other up to a sign: cos θ = ±√(1 − sin²θ), with the sign from the quadrant.

mirrors and turns

sin⁡(−θ)=−sin⁡θcos⁡(−θ)=cos⁡θsin⁡(θ+2π)=sin⁡θcos⁡θ=sin⁡ ⁣(θ+π2)\begin{gathered} \sin(-\theta) = -\sin\theta \\[6pt] \cos(-\theta) = \cos\theta \\[6pt] \sin(\theta + 2\pi) = \sin\theta \\[6pt] \cos\theta = \sin\!\left(\theta + \tfrac{\pi}{2}\right) \end{gathered}

−θ is the same walk clockwise, so its point is the mirror image across the x axis: the same x, the opposite y. a full turn lands on the same point, so adding 2π changes nothing, and neither does adding any number of turns. a quarter turn sends (x, y) to (−y, x), so the height of the point a quarter turn ahead is this point’s x: cos θ = sin(θ + π/2), and the cosine wave is the sine wave moved π/2 to the left. the mirror across the y axis gives two more: sin(π − θ) = sin θ and cos(π − θ) = −cos θ.

the angle sum

sin⁡(α+β)=sin⁡αcos⁡β+cos⁡αsin⁡βcos⁡(α+β)=cos⁡αcos⁡β−sin⁡αsin⁡β\begin{aligned} \sin(\alpha + \beta) &= \sin\alpha\cos\beta \\ &\quad + \cos\alpha\sin\beta \\[6pt] \cos(\alpha + \beta) &= \cos\alpha\cos\beta \\ &\quad - \sin\alpha\sin\beta \end{aligned}

the point at α + β is the point at β, turned by α. turning by α sends (1, 0) to (cos α, sin α) and (0, 1) to (−sin α, cos α), and turning a sum of arrows turns each one, so (cos β, sin β) = cos β · (1, 0) + sin β · (0, 1) lands on cos β · (cos α, sin α) + sin β · (−sin α, cos α). its x is the cosine formula and its y the sine formula. those two turned arrows are the columns of the rotation matrix on the cg fundamentals page. with α = β: sin 2θ = 2 sin θ cos θ and cos 2θ = cos²θ − sin²θ.

the graphs

y=a sin⁡(b(x−h))+ky = a\,\sin\big(b(x - h)\big) + k

sin and cos drawn against θ are waves between −1 and 1 with period 2π, and cos is sin moved π/2 to the left. the four numbers are the transformations from the functions page: a stretches the wave up and down, so the amplitude, half its height, is |a|. b squeezes it sideways, so the period is 2π/|b|. h slides it right, k slides it up, and y = k is the midline it swings around.

−2π−π0π2π−4−20243.0 at π/3x
amplitude |a|
2.0
period 2π/b
2π/3 ≈ 2.09
shift h
π/6 right
midline k
1.0
highest point
3.0 at x = π/3
sin x
for comparison

the graph of a sin(b(x − h)) + k in cyan from −2π to 2π, against sin x dashed in gray, with a slider for each of a, b, h and k. it starts at 2 sin(3(x − π/6)) + 1: amplitude 2, period 2π/3 ≈ 2.09, shifted π/6 right, midline 1, and its highest point, 3, marked at x = π/3. a readout gives those five numbers for any setting.

a and k act on the output, so they move the wave up and down. b and h act on the input, so they move it sideways.

a spring that overshoots traces a cosine that shrinks: the spring figure on the motion page draws one.

right triangles

sin⁡θ=oppositehypotenusecos⁡θ=adjacenthypotenusetan⁡θ=oppositeadjacent\begin{gathered} \sin\theta = \frac{\text{opposite}}{\text{hypotenuse}} \\[6pt] \cos\theta = \frac{\text{adjacent}}{\text{hypotenuse}} \\[6pt] \tan\theta = \frac{\text{opposite}}{\text{adjacent}} \end{gathered}

take a right triangle with an acute angle θ and scale it so its hypotenuse is 1. put the corner at θ on the origin, and the far corner lands on the circle: the opposite side is the height, sin θ, and the adjacent side is the x, cos θ. scaling keeps every ratio, so the three fractions hold at any size. the circle is the triangle with hypotenuse 1, and it keeps going past 90°, where no triangle does.

going back

arcsin⁡x∈[−π2,π2]arccos⁡x∈[0,π]arctan⁡x∈(−π2,π2)atan2⁡(y,x)∈[−π,π]\begin{gathered} \arcsin x \in \left[-\tfrac{\pi}{2}, \tfrac{\pi}{2}\right] \\[6pt] \arccos x \in [0, \pi] \\[6pt] \arctan x \in \left(-\tfrac{\pi}{2}, \tfrac{\pi}{2}\right) \\[6pt] \operatorname{atan2}(y, x) \in [-\pi, \pi] \end{gathered}

every height between −1 and 1 is reached twice in a turn, once on the way up and once on the way down, so arcsin has to pick, and it picks the angle nearest 0: between −π/2 and π/2.1 the other one is π − arcsin x, and then any number of turns on top of either. arccos picks between 0 and π, and arctan, like arcsin, between −π/2 and π/2, so atan(y / x) can’t tell (3, 4) from (−3, −4): the ratio is the same. atan2(y, x) takes the two parts separately, y first, and gives the whole direction, from −π to π.2 it’s the one to reach for when you need the angle of a vector, in a game, a plot or a shader.

worked examples

135° to radians, and 5π/6 to degrees. degrees to radians is times π/180: 135 · π/180 = (135/180) π, and 135/180 reduces to 3/4, so 135° = 3π/4. the other way is times 180/π: (5π/6) (180/π) = 5 · 30 = 150°.

sin, cos and tan of 5π/6. 5π/6 is 150°, in quadrant II. the reference angle is π − 5π/6 = π/6, 30°. from the table, sin(π/6) = 1/2 and cos(π/6) = √3/2. in quadrant II sin is positive and cos negative, so sin(5π/6) = 1/2, cos(5π/6) = −√3/2, and tan(5π/6) = (1/2) / (−√3/2) = −1/√3 = −√3/3 ≈ −0.577.

a right triangle. the hypotenuse is 10 and one angle is 30°. the side opposite the angle is 10 · sin 30° = 10 · 1/2 = 5. the side next to it is 10 · cos 30° = 10 · √3/2 = 5√3 ≈ 8.66. check with pythagoras: 5² + (5√3)² = 25 + 75 = 100 = 10².

read a wave. y = 2 sin(3(x − π/6)) + 1. the amplitude is 2, so it swings from 1 − 2 = −1 up to 1 + 2 = 3. the period is 2π/3 ≈ 2.09. it’s shifted π/6 to the right and 1 up, so it crosses its midline going up at x = π/6, and reaches its first high point a quarter period later, at π/6 + π/6 = π/3. that’s the wave in the figure above, where it starts.

the direction of a vector. which way does (−3, 4) point? atan2(4, −3) = 2.2143 rad = 126.87°: up and to the left, quadrant II, as it should be. atan(4 / −3) = atan(−4/3) = −0.9273 rad = −53.13°, which points down and to the right: the ratio −4/3 is also the ratio of (3, −4), and atan can’t tell them apart. the two answers differ by exactly π.

sin 75° from the angle sum. 75° = 45° + 30°, so sin 75° = sin 45° cos 30° + cos 45° sin 30° = (√2/2)(√3/2) + (√2/2)(1/2) = (√6 + √2) / 4 ≈ 0.9659. the calculator agrees: sin(75 · π/180) = 0.9659.

the key idea up close

the circle, unrolled

the graph of sine is a record of the walk. the horizontal axis is the distance the point has walked along the arc, which is what a radian measures, and the vertical axis is how high the point is at that moment. every moment of the walk is one point of the graph:

(arc walked, height)=(θ, sin⁡θ)(\text{arc walked},\ \text{height}) = (\theta,\ \sin\theta)

that’s the whole construction, and the shape of the wave follows from the shape of the circle.

the slope of that first climb, 1 at θ = 0, is where calculus picks the story up: the slope of sin θ at any θ is cos θ, and at 0 cos is 1.

pitfalls

practice

  1. convert 210° to radians, and 7π/4 to degrees.

    answer

    210° = 210 · π/180, and 210/180 reduces to 7/6, so 210° = 7π/6 ≈ 3.665. the other way: 7π/4 = (7/4) · 180° = 315°.

  2. without a calculator: cos(5π/4), sin(7π/6) and tan(2π/3).

    answer

    5π/4 is 225°, in quadrant III, with reference angle π/4. cos is negative there, so cos(5π/4) = −√2/2. 7π/6 is 210°, also quadrant III, with reference angle π/6: sin(7π/6) = −1/2. 2π/3 is 120°, quadrant II, with reference angle π/3: tan(π/3) = √3, and tan is negative in quadrant II, so tan(2π/3) = −√3.

  3. a right triangle has a hypotenuse of 12 and an angle of 30°. find the other two sides.

    answer

    the side opposite the 30° angle is 12 · sin 30° = 12 · 1/2 = 6. the side next to it is 12 · cos 30° = 12 · √3/2 = 6√3 ≈ 10.39. check: 6² + (6√3)² = 36 + 108 = 144 = 12².

  4. for y = 3 cos(2x − π/2) − 1, give the amplitude, the period, the shift, and the highest and lowest values.

    answer

    factor the inside first: 2x − π/2 = 2(x − π/4), so the wave is 3 cos(2(x − π/4)) − 1. amplitude 3. period 2π/2 = π ≈ 3.14. shifted π/4 to the right and 1 down, so the midline is y = −1. highest −1 + 3 = 2, at x = π/4, where the inside is 0 and cos is 1. lowest −1 − 3 = −4, half a period later at x = 3π/4.

  5. solve cos θ = −1/2 for 0 ≤ θ < 2π.

    answer

    arccos(−1/2) = 2π/3, the one answer between 0 and π. its mirror across the x axis has the same x, so the same cos: 2π − 2π/3 = 4π/3. so θ = 2π/3 or 4π/3. check: both have reference angle π/3, where cos is 1/2, and both sit left of the y axis, where cos is negative.

  6. a sprite at (2, 5) has to face a target at (−1, 1). what angle should it turn to, in radians and degrees, and what does atan get wrong?

    answer

    the direction is the target minus the sprite: (−1 − 2, 1 − 5) = (−3, −4). atan2(−4, −3) = −2.2143 rad = −126.87°, which is 233.13° measured counter-clockwise from the x axis: down and to the left, quadrant III. atan(−4 / −3) = atan(4/3) = 0.9273 rad = 53.13°, up and to the right. the two minus signs cancel in the ratio, so atan sees (3, 4) and answers for the opposite direction.

sources

  1. mdn’s Math.asin() (opens in a new tab) page: the result is in radians, between −π/2 and π/2 inclusive, and NaN for an input outside −1 to 1. ↩ ↩2

  2. mdn’s Math.atan2() (opens in a new tab) page: the arguments are the y coordinate first and the x second, the result is the angle in radians from the positive x axis to the ray through (x, y), between −π and π inclusive, and a table of the inputs where it differs from atan(y / x). ↩ ↩2

  3. mdn’s Math.sin() (opens in a new tab) page: the argument is an angle in radians. ↩