Basic Trigonometry: Sine, Cosine and Tangent

Updated 20 min read Beginner to intermediate Baca dalam Bahasa Indonesia

Geometry Algebra Computing Python JavaScript

Quick answer

Trigonometry links the angles of a triangle to the lengths of its sides: in a right triangle, the sine of an angle is the opposite side over the hypotenuse, the cosine is the adjacent side over the hypotenuse, and the tangent is the opposite side over the adjacent side. These ratios depend only on the angle, never on the size of the triangle, so one angle and one side give you every other side. The unit circle extends them to every angle, positive or negative.

Key takeaways

  • For an acute angle θ of a right triangle: \sinθ=(opposite)/(hypotenuse), \cosθ=(adjacent)/(hypotenuse), \tanθ=(opposite)/(adjacent) (SOH-CAH-TOA). Their reciprocals are \cscθ, \secθ and \cotθ. Two right triangles with the same angle are similar, so the ratios do not depend on the size.
  • To find a missing side, pick the ratio that holds the side you know and the side you want, and solve; to find an angle, use the inverse function (\arcsin, \arccos, \arctan). Always check the calculator mode: degrees for a problem in degrees.
  • The exact values at 30^\circ, 45^\circ and 60^\circ come from half an equilateral triangle and half a square: \sin30^\circ=\frac12, \sin45^\circ=(√2)/(2), \sin60^\circ=(√3)/(2), with the cosines in reverse order, and \tan is (√3)/(3), 1, √3.
  • On the unit circle the point at angle θ is (\cosθ,\sinθ). That defines the functions for every angle, with signs by quadrant (all positive in I, sine in II, tangent in III, cosine in IV) and the value equal to the value at the reference angle, up to sign. Sine and cosine repeat every 360^\circ, tangent every 180^\circ.
  • The basic identities are \sin^2θ+\cos^2θ=1, \tanθ=(\sinθ)/(\cosθ), \sin(90^\circ-θ)=\cosθ, \sin2θ=2\sinθ\cosθ and \sin(α+β)=\sinα\cosβ+\cosα\sinβ. The tempting ones such as \sin(α+β)=\sinα+\sinβ are false: one lucky angle does not prove an identity.
  • The equation \sin x=c has two solutions between 0^\circ and 360^\circ (the angle and its mirror image), \cos x=c has two, and \tan x=c has two a half turn apart. The graph of y=a\sin(b(x-c))+d has amplitude |a|, period (360^\circ)/(b), phase shift c and midline y=d. In code, convert degrees to radians, and prefer atan2 to find an angle.

What are sine, cosine and tangent?

Trigonometry is the part of mathematics that connects the angles of a triangle with the lengths of its sides; its three basic tools are the sine, the cosine and the tangent of an angle. The name comes from the Greek for triangle measure. It starts with the right triangle, the one with a 90^\circ angle.

Pick one of the two acute angles and call it θ. The three sides now have names relative to θ:

  • the hypotenuse is the side opposite the right angle, always the longest;
  • the opposite side is the one across from θ;
  • the adjacent side is the other leg, the one that touches θ.
The sides of a right triangle named from the angle $\theta$: $a$ is the opposite side, $b$ the adjacent side and $c$ the hypotenuse. Then $\sin\theta=\frac{a}{c}$, $\cos\theta=\frac{b}{c}$ and $\tan\theta=\frac{a}{b}$.

Then the three ratios are

\sinθ=(opposite)/(hypotenuse), \cosθ=(adjacent)/(hypotenuse), \tanθ=(opposite)/(adjacent).

A way to remember them is SOH-CAH-TOA: Sine is Opposite over Hypotenuse, Cosine is Adjacent over Hypotenuse, Tangent is Opposite over Adjacent. There are also three reciprocals: the cosecant \cscθ=(1)/(\sinθ), the secant \secθ=(1)/(\cosθ) and the cotangent \cotθ=(1)/(\tanθ).

Why does this make sense? Two right triangles that share the angle θ have all three angles equal, so they are similar: one is an enlargement of the other, and the ratio of two sides stays the same. So \sinθ is a number that belongs to the angle, not to the triangle: it is the same for a triangle on paper and for one the size of a tower. Because the hypotenuse is the longest side, \sinθ and \cosθ of an acute angle are always between 0 and 1.

Two right triangles with the same angle $\theta$. Every side of the larger one is twice the matching side of the smaller one, so $\sin\theta=\frac35=\frac{6}{10}$ in both: the ratio belongs to the angle, not to the size of the triangle.

Two more facts follow at once. The other acute angle is 90^\circ-θ, and the opposite and adjacent sides swap when you look from it, so \sin(90^\circ-θ)=\cosθ. And by the Pythagorean theorem, opposite^2+adjacent^2=hypotenuse^2; divide by the hypotenuse squared and you get \sin^2θ+\cos^2θ=1.

Try it: move the angle and the size, and switch the angle you look from.

Interactive: the ratios of a right triangle

Slide an angle and the hypotenuse of a right triangle and read sine, cosine, tangent and their reciprocals as ratios of sides: the sides grow, the ratios do not.

How do you find a missing side or angle of a right triangle?

To find a missing side, choose the ratio that contains the side you know and the side you want, write it down and solve for the unknown; to find a missing angle, use the inverse function of that ratio. Any right triangle can be solved from an angle and a side, or from two sides.

  1. Draw the triangle and mark the angle θ you are using.
  2. Name the sides relative to θ: opposite, adjacent, hypotenuse.
  3. Pick the ratio that holds the known side and the unknown side: opposite and hypotenuse mean sine, adjacent and hypotenuse mean cosine, opposite and adjacent mean tangent.
  4. Write the equation, for example \sinθ=(opposite)/(hypotenuse), and solve it: multiply to find a side, or take the inverse function (\arcsin, \arccos, \arctan) to find an angle.
  5. Check that the hypotenuse is the longest side, and that opposite^2+adjacent^2=hypotenuse^2.

Example, a side. You stand 40 m from the foot of a tower and see its top at an angle of elevation of 35^\circ (the angle above the horizontal). The known side is the adjacent 40 and the unknown is the opposite, so the tangent is the right ratio: \tan35^\circ=(h)/(40), hence h=40\tan35^\circ≈28.01 m. (Add the height of your eye to get the height of the tower.) Looking down from a tower to a boat uses the angle of depression, measured below the horizontal; it equals the angle of elevation seen from the boat.

The tower problem: from $40$ m away you see the top at an angle of elevation of $35^\circ$. The height above your eye is $h=40\tan35^\circ\approx28$ m. (The drawing uses $10$ units for $40$ m.)

Example, an angle. A road rises 8 m over a horizontal distance of 100 m. Then \tanθ=(8)/(100), so θ=\arctan0.08≈4.57^\circ. A grade of 8\% is exactly this tangent.

Example, a ladder. A 5 m ladder leans against a wall at 70^\circ to the ground. The hypotenuse is 5, so it reaches 5\sin70^\circ≈4.70 m up the wall, and its foot is 5\cos70^\circ≈1.71 m from the wall.

The inverse functions are the subject of their own article: \arcsin x is the angle between -90^\circ and 90^\circ whose sine is x. For a triangle that is not a right triangle, use the law of sines and the law of cosines (solving a triangle). The solver below takes any pair of measurements and also has these examples ready.

Interactive: solve a right triangle

Give an angle and a side, or two sides, and get every side and angle with the formula used; five everyday problems (a tower, a ladder, a ramp, a road, a shadow) are ready to try.

What are the exact values of sine and cosine at 30°, 45° and 60°?

The exact values at 30^\circ, 45^\circ and 60^\circ come from two triangles you can draw: half of an equilateral triangle, and half of a square.

Half of an equilateral triangle. Take an equilateral triangle with side 2 and cut it in half along a height. You get a right triangle with angles 30^\circ, 60^\circ and 90^\circ, hypotenuse 2, the short leg 1 (half of the base) and the long leg √(2^2-1^2)=√3. Read the ratios: \sin30^\circ=\frac12, \cos30^\circ=(√3)/(2), \tan30^\circ=(1)/(√3)=(√3)/(3), and from the other angle \sin60^\circ=(√3)/(2), \cos60^\circ=\frac12, \tan60^\circ=√3.

An equilateral triangle of side $2$ cut along its height. Each half is a right triangle with angles $30^\circ$, $60^\circ$, $90^\circ$ and sides $1$, $\sqrt3$, $2$ (the long leg is $\sqrt{2^2-1^2}=\sqrt3$).

Half of a square. Cut a square of side 1 along a diagonal. You get a right triangle with two angles of 45^\circ, legs 1 and hypotenuse √2. So \sin45^\circ=\cos45^\circ=(1)/(√2)=(√2)/(2) and \tan45^\circ=1.

A square of side $1$ cut along a diagonal. Each half is a right triangle with two angles of $45^\circ$ and sides $1$, $1$, $\sqrt2$, so $\sin45^\circ=\cos45^\circ=\frac{1}{\sqrt2}=\frac{\sqrt2}{2}$ and $\tan45^\circ=1$.
θ0^\circ30^\circ45^\circ60^\circ90^\circ
\sinθ0\frac12(√2)/(2)(√3)/(2)1
\cosθ1(√3)/(2)(√2)/(2)\frac120
\tanθ0(√3)/(3)1√3undefined

A pattern to remember. Write the sines of 0^\circ,30^\circ,45^\circ,60^\circ,90^\circ as (√0)/(2),(√1)/(2),(√2)/(2),(√3)/(2),(√4)/(2); the cosines are the same list backwards, and the tangent is the sine divided by the cosine. The angle 0^\circ is a degenerate triangle with no height (\sin0^\circ=0) and at 90^\circ the adjacent side shrinks to nothing, so \tan90^\circ=1/0 has no value.

The multiples of 15^\circ need a little more: \sin15^\circ=(√6-√2)/(4), \cos15^\circ=(√6+√2)/(4) and \tan15^\circ=2-√3, which follow from the angle formulas below (15^\circ=45^\circ-30^\circ). The unit circle further down gives the exact value of all of them. These triangles are also the ones from right triangles, where their sides appear as the ratios 1:1:√2 and 1:√3:2.

How does the unit circle give sine and cosine for every angle?

On the unit circle, the circle of radius 1 around the origin, the point reached by turning through an angle θ from the positive x-axis is (\cosθ,\sinθ). This is the definition that works for every angle. For an acute angle it agrees with the triangle: drop a perpendicular from the point to the x-axis, and the right triangle has hypotenuse 1, so the adjacent side is \cosθ and the opposite side is \sinθ. Positive angles turn counterclockwise, negative angles clockwise (see how angles are measured), and \tanθ=(\sinθ)/(\cosθ) wherever the cosine is not 0.

The unit circle. The point at the angle $\theta$ is $(\cos\theta,\sin\theta)$: the radius is the hypotenuse, of length $1$, the horizontal leg is $\cos\theta$ and the vertical leg is $\sin\theta$. Pythagoras gives $\sin^2\theta+\cos^2\theta=1$.

Three things follow.

Signs by quadrant. The sign of \cosθ is the sign of the x-coordinate and the sign of \sinθ that of the y-coordinate:

QuadrantAngles\sin\cos\tan
I0^\circ to 90^\circ+++
II90^\circ to 180^\circ+--
III180^\circ to 270^\circ--+
IV270^\circ to 360^\circ-+-

In words: all three are positive in I, only sine in II, only tangent in III and only cosine in IV (English speakers remember it as "All Students Take Calculus").

Reference angles. The reference angle of θ is the acute angle between its terminal side and the x-axis. By symmetry, each function at θ has the absolute value it has at the reference angle, and the sign is given by the quadrant.

  1. Find the reference angle: θ in quadrant II gives 180^\circ-θ, in III gives θ-180^\circ, in IV gives 360^\circ-θ.
  2. Read the value at the reference angle (the table in the previous section).
  3. Put the sign of the quadrant in front.

For example \sin210^\circ: it is in quadrant III, the reference angle is 30^\circ, and sine is negative there, so \sin210^\circ=-\frac12. And \cos120^\circ=-\cos60^\circ=-\frac12, \tan135^\circ=-\tan45^\circ=-1.

The angle $150^\circ$ is in quadrant II. Its reference angle is $180^\circ-150^\circ=30^\circ$, so $\sin150^\circ=\sin30^\circ=\frac12$ (positive there) and $\cos150^\circ=-\cos30^\circ=-\frac{\sqrt3}{2}$ (negative there). The signs written in each quadrant are those of $\sin$, $\cos$ and $\tan$, in that order.

Periodicity and negative angles. A full turn changes nothing, so \sin(θ+360^\circ)=\sinθ and the same for cosine; the tangent repeats after a half turn, \tan(θ+180^\circ)=\tanθ. Turning the other way mirrors the point in the x-axis: \sin(-θ)=-\sinθ and \cos(-θ)=\cosθ. So \sin(-30^\circ)=-\frac12 and \cos(-30^\circ)=(√3)/(2). (Mathematicians measure the same turn in radians, where 360^\circ=2π.)

Move the angle below, from -360^\circ to 720^\circ, and watch the point, the signs and the exact values.

Interactive: the unit circle

Turn an angle from −360° to 720° and watch the point (cos, sin) move on the unit circle, with its quadrant, reference angle, signs, exact values for multiples of 15° and all six functions.

How do you solve sin x = c, cos x = c and tan x = c?

To solve \sin x=c, \cos x=c or \tan x=c, find one angle with the inverse function, find its mirror image on the unit circle, and add whole turns to both. The reason there is a second angle is that two points of the unit circle have the same height (the same sine), two have the same x-coordinate (the same cosine), and two opposite points give the same tangent.

1. If c is outside -1\le c\le1 for sine or cosine, there is no solution. 2. Find the principal angle α with the inverse function (\arcsin c, \arccos c or \arctan c). 3. Find the second angle between 0^\circ and 360^\circ from the symmetry: - sine: x=α and x=180^\circ-α; - cosine: x=α and x=360^\circ-α (that is, ±α); - tangent: x=α and x=α+180^\circ. 4. Add whole turns for all the solutions: 360^\circ k for sine and cosine, 180^\circ k for tangent, where k is any whole number. 5. Check the answers by substituting.

Example. \sin x=\frac12. The principal angle is α=30^\circ, so the solutions between 0^\circ and 360^\circ are 30^\circ and 180^\circ-30^\circ=150^\circ; in general x=30^\circ+360^\circ k or x=150^\circ+360^\circ k. For \cos x=-(√2)/(2) the principal angle is 135^\circ, and the solutions are 135^\circ and 225^\circ. For \tan x=√3 they are 60^\circ and 240^\circ.

A calculator or program gives only the principal value (\arcsin returns an angle between -90^\circ and 90^\circ), so the second solution is yours to find. The same method solves harder equations once they are brought to this form, for instance 2\sin^2x=\sin x becomes \sin x (2\sin x-1)=0, so \sin x=0 or \sin x=\frac12.

The equation $\sin x=\frac12$. The line $y=\frac12$ cuts the sine wave between $0^\circ$ and $360^\circ$ at two points, $x=30^\circ$ and $x=180^\circ-30^\circ=150^\circ$; every further turn adds $360^\circ$.

Interactive: solve sin x = c, cos x = c and tan x = c

Choose a function and a level c and see every angle between 0° and 360° that reaches it as the crossings of a graph and a line, with the general solution for all turns.

What are the basic trigonometric identities?

A trigonometric identity is an equation that is true for every angle for which both sides are defined, which makes it different from an equation, which is true only for some angles. \sin x=\frac12 is an equation (it holds at 30^\circ and 150^\circ and so on); \sin^2x+\cos^2x=1 is an identity (it holds always). These are the ones to know.

NameIdentity
Pythagorean\sin^2x+\cos^2x=1 and 1+\tan^2x=(1)/(\cos^2x)
Quotient and reciprocal\tan x=(\sin x)/(\cos x), \csc x=(1)/(\sin x), \sec x=(1)/(\cos x), \cot x=(1)/(\tan x)
Cofunction\sin(90^\circ-x)=\cos x and \cos(90^\circ-x)=\sin x
Supplement and negative angle\sin(180^\circ-x)=\sin x, \sin(-x)=-\sin x, \cos(-x)=\cos x
Double angle\sin2x=2\sin x\cos x and \cos2x=\cos^2x-\sin^2x
Sum\sin(x+y)=\sin x\cos y+\cos x\sin y and \cos(x+y)=\cos x\cos y-\sin x\sin y

Where they come from. The Pythagorean identity is the equation of the unit circle, x^2+y^2=1, with x=\cosθ and y=\sinθ; divide it by \cos^2x for the second form. The cofunction identity says that the sine of an angle is the cosine of its complement (the two acute angles of a right triangle). The double-angle formulas are the sum formulas with y=x, and the sum formulas can be proved from the geometry of the unit circle. With them you get exact values beyond the table, for example \sin75^\circ=\sin(45^\circ+30^\circ), which by the sum formula is (√2)/(2)·(√3)/(2)+(√2)/(2)·\frac12, that is (√6+√2)/(4).

An identity is not proved by trying a number. The tempting formulas \sin(x+y)=\sin x+\sin y, \sin2x=2\sin x and \sin x+\cos x=1 are false, yet each is true at a few angles: \sin2x=2\sin x holds at x=0^\circ and x=180^\circ, and a single lucky test would convince you. A false identity is refuted by one counterexample (\sin(30^\circ+60^\circ)=1 but \sin30^\circ+\sin60^\circ≈1.366); a true one has to be proved, with algebra or geometry. The tester below compares both sides over all 360 whole degrees. The sum, double-angle and half-angle formulas, with their proofs and a strategy for proving identities, are in the article on trigonometric identities.

Interactive: test a trigonometric identity

Pick one of eleven true identities or six tempting false ones, move the angles, and compare both sides over all 360 whole degrees: an identity never fails, and a false one fails at a counterexample.

What do the graphs of sine and cosine look like?

The graphs of y=\sin x and y=\cos x are waves that repeat every 360^\circ and oscillate between -1 and 1; the cosine is the sine shifted left by 90^\circ. Plot the height of the point on the unit circle against the angle and you get the sine wave: it starts at 0, rises to 1 at 90^\circ, falls through 0 at 180^\circ to -1 at 270^\circ and is back at 0 at 360^\circ. The tangent has a different shape: it repeats every 180^\circ and blows up near 90^\circ and 270^\circ, where the cosine is 0.

One turn of the sine wave (solid) and of the cosine wave (dashed). The cosine is the sine shifted $90^\circ$ to the left. Both oscillate between $-1$ and $1$ and repeat every $360^\circ$.

Every wave of the form y=a\sin(b(x-c))+d (or with the cosine) is described by four numbers:

  • the amplitude |a|, the distance from the middle line to a peak; a negative a flips the wave upside down;
  • the period (360^\circ)/(b), the length of one full cycle (in radians, (2π)/(b)); a larger b squeezes the wave;
  • the phase shift c, how far the wave is moved to the right;
  • the midline y=d, the height around which it oscillates; the maximum is d+|a| and the minimum d-|a|.

Example. y=2\sin(3x)+1: amplitude 2, period (360^\circ)/(3)=120^\circ, no shift, midline y=1, maximum 3, minimum -1. The zeros are where \sin3x=-\frac12.

The graph of $y=2\sin3x+1$. The midline is $y=1$ (dashed), the amplitude is $2$ (from the midline up to the peak at $y=3$) and the period is $\frac{360^\circ}{3}=120^\circ$ (the bar at the bottom).

Waves of this shape describe anything that goes round and round or back and forth: the height of a tide, a swinging pendulum, a sound of one pure pitch, alternating current, the seasons of daylight. Their slopes are another wave, which is the subject of the derivatives of sine and cosine. Change the four numbers below and watch the table.

Interactive: the graph of a sine or cosine wave

Change a, b, c and d in y = a sin(b(x − c)) + d and watch the amplitude, period, phase shift and midline change, with the maximum, the minimum and where the wave crosses zero.

Where is trigonometry used?

Trigonometry is used wherever you cannot measure a length or a direction directly but can measure an angle, or wherever something turns or oscillates.

  • Heights and distances. The height of a tower, a tree or a mountain, the width of a river, the distance to a ship: one angle and one measured length give the rest (surveying works exactly like this, with a theodolite to measure the angles).
  • Slopes. The gradient of a road or a roof is the tangent of its angle; a ramp for a wheelchair should not exceed about 5^\circ.
  • Navigation. A bearing is an angle from north (see directions and bearings); the components of a course east and north are d\sinθ and d\cosθ for a bearing θ.
  • Physics and engineering. A force or velocity at angle θ has components F\cosθ and F\sinθ; a block on a slope feels mg\sinθ along it.
  • Waves and signals. Sound, light, radio, alternating current and tides are sums of sine waves.
  • Computers. A point rotated by θ about the origin goes to (x\cosθ-y\sinθ, x\sinθ+y\cosθ), the basis of graphics, games and robot arms; the position of a point on a circle is (r\cosθ, r\sinθ).

All of it rests on the same picture: a right triangle, or the point on the unit circle.

How do you use trigonometry in code?

Every programming language takes angles in radians, so convert first: math.sin(math.radians(30)) in Python, Math.sin(30 Math.PI / 180) in JavaScript, sin(30 PI / 180) in C++. Forgetting this is the most common error: math.sin(30) is the sine of 30 radians, about -0.988.

The second trap is rounding. Because π is stored with a small error, the values you expect to be exact are not: math.sin(math.radians(30)) gives 0.49999999999999994, math.cos(math.radians(90)) gives 6.1e-17 instead of 0, and math.tan(math.radians(90)) gives about 1.6×10^16 instead of "undefined". Compare with a tolerance, never with ==, or fold the angle to a reference angle between 0^\circ and 90^\circ first, as the function sin_deg below does.

To go the other way, use the inverse functions, and prefer atan2(opposite, adjacent) to atan(opposite / adjacent): it gets the quadrant right and does not divide by zero (see the angle between two vectors). The program solves the tower and the road of the examples, the 3-4-5 triangle and the equation \sin x=\frac12.

Python: degrees and radians, rounding, and the examples of this article
import math


def sin_deg(d):
    """Sine of an angle in degrees: fold to a reference angle first, so 30 and 90 come out exact."""
    n = d % 360
    ref, sign = (n, 1) if n <= 90 else (180 - n, 1) if n <= 180 else (n - 180, -1) if n <= 270 else (360 - n, -1)
    v = {0: 0.0, 30: 0.5, 90: 1.0}.get(ref, math.sin(math.radians(ref)))
    return sign * v if v else 0.0


def cos_deg(d):
    return sin_deg(90 - d)


print(math.sin(math.radians(30)), sin_deg(30))       # 0.49999999999999994 0.5
print(math.cos(math.radians(90)), cos_deg(90))       # 6.123233995736766e-17 0.0
print(math.tan(math.radians(90)))                    # 1.633123935319537e+16, not "undefined"
print(round(40 * math.tan(math.radians(35)), 2))     # 28.01: the tower seen at 35 degrees from 40 m
print(round(math.degrees(math.atan2(8, 100)), 2))    # 4.57: the road that rises 8 m in 100 m
print(round(math.degrees(math.atan2(3, 4)), 4), math.hypot(3, 4))     # 36.8699 5.0
x = math.degrees(math.asin(0.5))                     # the principal value of sin x = 1/2
print(round(x, 6), round(180 - x, 6))                # 30.0 150.0: the mirror image is yours to add
print(round(math.sin(math.radians(75)), 6), round((math.sqrt(6) + math.sqrt(2)) / 4, 6))   # 0.965926 0.965926
print(sin_deg(210), sin_deg(-30), cos_deg(120))      # -0.5 -0.5 -0.5
JavaScript: the same functions
const rad = (d) => (d * Math.PI) / 180
const deg = (r) => (r * 180) / Math.PI

function sinDeg(d) {
  const n = ((d % 360) + 360) % 360                     // JavaScript's % keeps the sign of d, so fix it
  const [ref, sign] = n <= 90 ? [n, 1] : n <= 180 ? [180 - n, 1] : n <= 270 ? [n - 180, -1] : [360 - n, -1]
  const v = ref === 0 ? 0 : ref === 30 ? 0.5 : ref === 90 ? 1 : Math.sin(rad(ref))
  return v === 0 ? 0 : sign * v
}
const cosDeg = (d) => sinDeg(90 - d)

;[Math.sin(rad(30)), sinDeg(30)]                        // [0.49999999999999994, 0.5]
;[Math.cos(rad(90)), cosDeg(90)]                        // [6.123233995736766e-17, 0]
Math.tan(rad(90))                                       // 16331239353195370, not "undefined"
+(40 * Math.tan(rad(35))).toFixed(2)                    // 28.01
+deg(Math.atan2(8, 100)).toFixed(2)                     // 4.57
;[deg(Math.asin(0.5)), 180 - deg(Math.asin(0.5))].map((x) => +x.toFixed(6))   // [30, 150]
;[sinDeg(210), sinDeg(-30), cosDeg(120)]                // [-0.5, -0.5, -0.5]
C++: the same functions with <cmath>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

const double PI = 3.14159265358979323846;

double radians(double d) { return d * PI / 180.0; }

double sinDeg(double d) {
  double n = d - 360.0 * floor(d / 360.0);        // into [0, 360)
  double ref = n;
  double sign = 1;
  if (n > 270) { ref = 360 - n; sign = -1; }
  else if (n > 180) { ref = n - 180; sign = -1; }
  else if (n > 90) { ref = 180 - n; }
  double v;
  if (ref == 0) v = 0;
  else if (ref == 30) v = 0.5;
  else if (ref == 90) v = 1;
  else v = sin(radians(ref));
  return v == 0 ? 0 : sign * v;
}

double cosDeg(double d) { return sinDeg(90 - d); }

int same(double a, double b) { return a == b ? 1 : 0; }

int main() {
  printf("%d %d\n", same(sin(radians(30)), 0.5), same(sinDeg(30), 0.5));
  printf("%d %d\n", same(cos(radians(90)), 0), same(cosDeg(90), 0));
  printf("%.2f\n", 40 * tan(radians(35)));
  printf("%.2f\n", atan2(8, 100) * 180 / PI);
  printf("%.4f %.4f\n", sinDeg(210), cosDeg(120));
  printf("%.6f %.6f\n", asin(0.5) * 180 / PI, 180 - asin(0.5) * 180 / PI);
  return 0;
}

/* output:
0 1
0 1
28.01
4.57
-0.5000 -0.5000
30.000000 150.000000
*/

Where does trigonometry come from?

Trigonometry began as the astronomy of chords, grew sines and cosines in India and the Islamic world, and became the functions we write today in the eighteenth century.

  • About 150 BC. Hipparchus builds the first table of chords (the length of the segment joining two points of a circle for a given angle), to predict the positions of the Sun and Moon. Around 150 AD, Ptolemy's Almagest has a chord table for every half degree.
  • About 500 AD. Indian astronomers such as Aryabhata work with the half-chord instead, the jya, which is our sine, and tabulate it; the cosine appears as the sine of the complement.
  • About 800 to 1000. In the Islamic world, scholars including al-Khwarizmi and Abu al-Wafa extend the tables and use all six functions, and al-Battani replaces the Greek chords by sines in his astronomy.
  • 12th century. Latin translators render the Arabic jayb (a mis-reading of the Sanskrit jya) as sinus, which means "fold" or "bay": that is how the word sine got its name.
  • 1464. Regiomontanus writes De triangulis omnimodis, the first European book on trigonometry as a subject of its own, apart from astronomy.
  • 1595. Bartholomaeus Pitiscus publishes Trigonometria and gives the subject its name.
  • 1748. Euler's Introductio in analysin infinitorum fixes the modern notation (sin, cos, tan) and treats them as functions of a number, which opens the way to calculus and to waves.

What are the common mistakes in trigonometry?

The most common mistakes in trigonometry are the nine below, each with the correct statement.

MistakeCorrect
❌ Use the calculator or program in the wrong modeDegrees for degrees, radians for radians; check that \sin30 gives 0.5 in degree mode.
❌ \sin(x+y)=\sin x+\sin y\sin(x+y)=\sin x\cos y+\cos x\sin y; for 30^\circ and 60^\circ the first gives 1 and the wrong one 1.366.
❌ \sin2x=2\sin x\sin2x=2\sin x\cos x; the wrong version only works at 0^\circ and 180^\circ.
❌ \sin^-1x means (1)/(\sin x)\sin^-1x is the inverse function \arcsin x; the reciprocal is \csc x.
❌ Opposite and adjacent are fixed sidesThey depend on the angle you look from; they swap when you look from the other acute angle.
❌ \tan90^\circ=∞ or 0It is undefined: \tan90^\circ=(\sin90^\circ)/(\cos90^\circ)=\frac10.
❌ A big triangle has a bigger sineThe ratios depend only on the angle; for an acute angle the sine is between 0 and 1.
❌ \sin150^\circ is negative because 150^\circ>90^\circIt is in quadrant II, where sine is positive: \sin150^\circ=\sin30^\circ=\frac12.
❌ \sin x=\frac12 has only the solution 30^\circThere are two between 0^\circ and 360^\circ: 30^\circ and 150^\circ (and every turn more).

Practice: test your understanding

These questions mix everything above. A wrong answer costs nothing here: read the hint and try again.

True or false?

Decide whether each statement is True or False.

  • The sine of an acute angle in a right triangle is the opposite side divided by the hypotenuse.
  • \tan45^\circ=1.
  • \cos120^\circ is positive.
  • \sin^2x+\cos^2x=1 for every angle x.
  • \sin(x+y)=\sin x+\sin y.
  • A bigger right triangle with the same angle has a bigger sine.

A side from a sine

A right triangle has a hypotenuse of 10 and an angle of 30^\circ. How long is the side opposite that angle?

A tower

From 30 m away you see the top of a tower at an angle of elevation of 45^\circ. How tall is the tower above your eye, in metres?

An exact value

What is the exact value of \cos60^\circ?

  • \frac12
  • (√3)/(2)
  • (√2)/(2)
  • 1

A reference angle

What is the reference angle of 210^\circ, in degrees?

A sine in the third quadrant

What is \sin210^\circ?

  • -\frac12
  • \frac12
  • -(√3)/(2)
  • (√3)/(2)

Two solutions

Which angles between 0^\circ and 360^\circ satisfy \sin x=(√3)/(2)? Choose all that apply.

  • 30^\circ
  • 60^\circ
  • 120^\circ
  • 150^\circ
  • 240^\circ

A period

What is the period of y=\sin3x, in degrees?

An amplitude

What is the amplitude of y=-4\cos x+1?

An identity

Which of these is an identity (true for every angle)?

  • \cos^2x=1-\sin^2x
  • \sin2x=2\sin x
  • \sin x+\cos x=1
  • \cos2x=2\cos x

Order the steps

Put the steps of finding the height of a tower from an angle of elevation in order.

Fill in the ratio

Complete the sentence.

Summary: basic trigonometry at a glance

  • Ratios: \sinθ=(opp)/(hyp), \cosθ=(adj)/(hyp), \tanθ=(opp)/(adj) (SOH-CAH-TOA); reciprocals \csc, \sec, \cot; they depend only on the angle (similar triangles).
  • Solve a right triangle: one angle and one side, or two sides; pick the ratio with the known and unknown sides; inverse functions for angles; check with Pythagoras.
  • Special angles: \sin30^\circ=\frac12, \sin45^\circ=(√2)/(2), \sin60^\circ=(√3)/(2); cosines in reverse; \tan: (√3)/(3), 1, √3; \tan90^\circ undefined.
  • Unit circle: the point at angle θ is (\cosθ,\sinθ); signs: all, sine, tangent, cosine in quadrants I to IV; reference angle; period 360^\circ (tangent 180^\circ); \sin(-θ)=-\sinθ, \cos(-θ)=\cosθ.
  • Equations: \sin x=c: α and 180^\circ-α; \cos x=c: ±α; \tan x=c: α and α+180^\circ; add turns.
  • Identities: \sin^2x+\cos^2x=1, \tan x=(\sin x)/(\cos x), \sin(90^\circ-x)=\cos x, \sin2x=2\sin x\cos x, \sin(x+y)=\sin x\cos y+\cos x\sin y; a counterexample refutes, a proof is needed to confirm.
  • Graphs: y=a\sin(b(x-c))+d has amplitude |a|, period (360^\circ)/(b), phase shift c, midline d.
  • Code: radians for sin and cos; compare with a tolerance; atan2 for angles; the inverse functions give only one solution.

Glossary: key terms

Trigonometry
The branch of mathematics that relates the angles of a triangle to the lengths of its sides, through the sine, cosine and tangent.
Hypotenuse
The side of a right triangle opposite the right angle, and its longest side.
Sine
For an acute angle of a right triangle, the length of the opposite side divided by the hypotenuse; on the unit circle, the y-coordinate of the point at that angle.
Cosine
For an acute angle of a right triangle, the adjacent side divided by the hypotenuse; on the unit circle, the x-coordinate of the point at that angle.
Tangent
The opposite side divided by the adjacent side, which equals sine divided by cosine; it is undefined where the cosine is zero.
Unit circle
The circle of radius 1 centered at the origin, used to define sine and cosine for every angle.
Reference angle
The acute angle between the terminal side of an angle and the x-axis; the functions at the angle equal those at the reference angle up to sign.
Angle of elevation
The angle above the horizontal at which you look up at an object; the angle of depression is the same angle measured below the horizontal.
Trigonometric identity
An equation involving trigonometric functions that is true for every angle at which both sides are defined, such as sin squared plus cos squared equals 1.
Amplitude and period
For a sine or cosine wave, the amplitude is the height from the midline to a peak, and the period is the length of one full cycle.

Frequently asked questions

What are sine, cosine and tangent?

They are the three basic ratios of a right triangle for one of its acute angles: sine is opposite over hypotenuse, cosine is adjacent over hypotenuse and tangent is opposite over adjacent. They depend only on the angle.

What does SOH-CAH-TOA mean?

It is a memory aid: Sine is Opposite over Hypotenuse, Cosine is Adjacent over Hypotenuse, Tangent is Opposite over Adjacent. The sides are named from the angle you are looking at.

How do you find a side of a right triangle with trigonometry?

Pick the ratio that contains the side you know and the side you want, write it as an equation and solve. For example, with an angle of 35 degrees and an adjacent side of 40, the opposite side is 40 times tan 35.

What are the exact values of sin, cos and tan for 30, 45 and 60 degrees?

Sine is one half, root 2 over 2 and root 3 over 2; cosine is the same list backwards; tangent is root 3 over 3, 1 and root 3. They come from half an equilateral triangle and half a square.

What is the unit circle in trigonometry?

It is the circle of radius 1 around the origin. The point reached by turning through an angle from the positive x-axis has coordinates cosine and sine of that angle, which defines the functions for every angle.

Why is tan 90 degrees undefined?

Tangent is sine divided by cosine, and at 90 degrees the cosine is 0 while the sine is 1, so the division has no value. The graph of the tangent rises without bound near 90 degrees.

Is sin(a + b) equal to sin a + sin b?

No. The correct formula is sin a cos b plus cos a sin b. For 30 and 60 degrees the left side is sin 90, which is 1, while sin 30 plus sin 60 is about 1.366.

Why does my calculator give a wrong answer for sin 30?

It is probably in radian mode, where 30 means 30 radians and the sine is about minus 0.988. Switch to degree mode to get 0.5. Programming languages always use radians, so convert degrees first.

References

  1. Eli Maor (1998). Trigonometric Delights. Princeton University Press.
  2. I. M. Gelfand, Mark Saul (2001). Trigonometry (2nd ed.). Birkhäuser.
  3. James Stewart, Lothar Redlin, Saleem Watson (2016). Precalculus: Mathematics for Calculus (chapters on trigonometric functions). Cengage Learning.
  4. Carl B. Boyer, Uta C. Merzbach (2011). A History of Mathematics (3rd ed.). Wiley.
  5. G. J. Toomer (1984). Ptolemy's Almagest (translated and annotated). Springer.
  6. Leonhard Euler (1748). Introductio in analysin infinitorum. Marcum-Michaelem Bousquet.