Skip to content
AI360Xpert
Beta

Trigonometry

Trigonometry turns angles into numbers you can compute with, so rotations, waves, and repeating patterns become algebra instead of geometry.

In a right triangle the 30 degree angle fixes every side ratio at once: sine one half, cosine root 3 over 2, and tangent 1 over root 3
In a right triangle the 30 degree angle fixes every side ratio at once: sine one half, cosine root 3 over 2, and tangent 1 over root 3

Why Does This Exist?

Machine learning keeps meeting angles it cannot avoid. Word order becomes rotation in a positional encoding, sound becomes oscillation, an image gets rotated for augmentation, and a robot arm must convert a joint angle into a hand position. Staring at the angle tells you nothing computable. Trigonometry is the bridge: it converts each angle into ordinary numbers, ratios of triangle sides, that plug straight into formulas and code.

Without it you would be stuck measuring pictures. With it, a rotation is a multiplication, a wave is a function you can differentiate, and a periodic pattern is something a model can learn. This page covers the core idea: angles determine fixed side ratios, and those ratios are the sine, cosine, and tangent. The separate pages on angles, radians and degrees and sine, cosine, tangent go deeper on each half.

The one idea you need first

A ratio is one length divided by another, so it has no units and stays the same when you scale the picture up or down. If a triangle's short side is always half its longest side, that "one half" is true for a sketch and for a skyscraper. Trigonometry is the discovery that fixing an angle fixes three such ratios, which is why one small triangle teaches you every triangle with the same angles.

Think of It Like This

A ladder against a wall

Lean a ladder against a wall. The angle at the ground decides everything about its shape: a shallow angle means the foot sits far out, a steep angle brings it close. Now double the ladder's length while a friend holds the angle fixed. The foot distance doubles too, but the foot-distance-divided-by-ladder-length never changes. That unchanging fraction is what trigonometry names.

Sine, cosine, and tangent are just three such fractions, written down once so nobody remeasures the ladder. The analogy stops where circles start: ladders only make angles up to 90 degrees, while the full functions keep going around the whole circle, which is where waves come from.

How It Actually Works

Take any right triangle and pick one of its two sharp angles, call it θ\theta (theta). Name the sides relative to it: opposite (across from θ\theta), adjacent (touching θ\theta, not the hypotenuse), and hypotenuse (the longest side, across from the right angle). The three functions are three divisions:

sin⁡θ=oppositehypotenuse,cos⁡θ=adjacenthypotenuse,tan⁡θ=oppositeadjacent\sin \theta = \frac{\text{opposite}}{\text{hypotenuse}}, \qquad \cos \theta = \frac{\text{adjacent}}{\text{hypotenuse}}, \qquad \tan \theta = \frac{\text{opposite}}{\text{adjacent}}

In plain words: sine is how much of the longest side points "up" across from your angle, cosine is how much points "along" beside it, and tangent is the slope, rise over run. Every symbol is a length except θ\theta itself, which is the angle. Because similar triangles scale all sides together, these fractions depend on θ\theta alone. Change the angle and the ratios change; keep the angle and no scaling in the world moves them.

Worked example

Use the classic 30-60-90 triangle with hypotenuse 2. Its sides are in the fixed proportion 1:3:21 : \sqrt{3} : 2, so opposite =1= 1, adjacent =3≈1.732= \sqrt{3} \approx 1.732, hypotenuse =2= 2 for the 30 degree angle:

  • sin⁡30°=1/2=0.5\sin 30° = 1 / 2 = 0.5
  • cos⁡30°=1.732/2≈0.866\cos 30° = 1.732 / 2 \approx 0.866
  • tan⁡30°=1/1.732≈0.577\tan 30° = 1 / 1.732 \approx 0.577

Quick check that ties them together: sin⁡2+cos⁡2=0.25+0.75=1.0\sin^2 + \cos^2 = 0.25 + 0.75 = 1.0, exactly as the identity promises (see trigonometric identities). And tan⁡=sin⁡/cos⁡=0.5/0.866≈0.577\tan = \sin / \cos = 0.5 / 0.866 \approx 0.577, consistent. One angle, three numbers, all agreeing with each other.

Code

The point here is the check: compute the three ratios from side lengths and confirm they match the library functions of the angle.

import numpy as np
opp, adj, hyp = 1.0, float(np.sqrt(3)), 2.0theta = np.deg2rad(30)  # 30 degrees as the library expects it, in radians
print(opp / hyp)                      # -> 0.5print(np.isclose(opp / hyp, np.sin(theta)))  # -> Trueprint(round(adj / hyp, 4))            # -> 0.866print(round(opp / adj, 4))            # -> 0.5774

Side division and sin agree, which is the whole claim in one line: the angle determines the ratio.

Watch Out For

Feeding degrees to a function that expects radians

You compute sin(30) and get −0.988-0.988 instead of 0.50.5, so you conclude your geometry is broken. It is not. Nearly every library (np.sin, math.sin, torch) takes radians, and 30 radians is a huge angle spun many times around the circle.

The symptom is values that look random for familiar angles: sin(30) near −0.99-0.99, sin(90) near 0.890.89. Fix it at the boundary with np.deg2rad or np.radians before calling, and keep one convention inside each function. See angles, radians and degrees for the conversion.

Using the wrong angle of the two

A right triangle has two sharp angles, and opposite and adjacent swap when you switch between them. Picking the 60 degree angle while reading off the sides labelled for 30 degrees gives sin⁡60°=0.866\sin 60° = 0.866 where you expected 0.50.5.

Always mark which angle is θ\theta first, then name the sides relative to it. If sine comes out larger than cosine for an angle you believed was small, you are almost certainly reading the other angle's ratios.

The Quick Version

  • Trigonometry converts each angle into fixed side ratios, so geometry becomes arithmetic.
  • Sine is opposite over hypotenuse, cosine is adjacent over hypotenuse, tangent is opposite over adjacent.
  • The ratios depend on the angle alone; scaling the triangle changes nothing.
  • A 30 degree angle always gives sine one half and cosine about 0.866, at any size.
  • Libraries take radians, not degrees, so convert first or familiar angles give nonsense.
  • These ratios are the raw material for rotations, waves, and everything in sine, cosine, tangent.