△ Trigonometry & Trig Calculus

Circles, Triangles, Angles — and the Calculus That Moves Them
Complete reference: rigorous proofs, derivatives & integrals of every trig function, interactive explorations, cryptographic applications & GNU Octave laboratory.

§01 Angles & Measurement

1.1 — Degrees, Radians & Gradians

An angle measures rotation between two rays sharing a common vertex. The radian is the natural unit: the angle subtended by an arc equal in length to the radius.

θ (radians) = arc length / radius = s / r
360° = 2π rad = 400 grad   ⟹   1 rad = 180°/π ≈ 57.2958°

1.2 — Conversion Formulas

FromTo RadiansTo Degrees
Degrees dd · π/180
Radians rr · 180/π
Turns tt · 2πt · 360

1.3 — Special Angles

DegreesRadianssincostan
0010
30°π/61/2√3/21/√3
45°π/4√2/2√2/21
60°π/3√3/21/2√3
90°π/210undefined
180°π0−10
270°3π/2−10undefined

1.4 — Arc Length & Sector Area

Arc length: s = rθ     Sector area: A = ½r²θ     (θ in radians)
PROOF — Sector area A = ½r²θ
A full circle has area πr² and subtends 2π radians.
A sector of angle θ occupies fraction θ/(2π) of the circle.
A = πr² · θ/(2π) = ½r²θ.

§02 The Unit Circle

2.1 — Definition

The unit circle is the circle x² + y² = 1 centered at the origin. Every point on it can be written as (cos θ, sin θ) where θ is the angle measured counterclockwise from the positive x-axis.

2.2 — Interactive Unit Circle

↑ Move cursor to explore angles. Shows (cos θ, sin θ), all six trig functions, and the reference triangle.

2.3 — Quadrant Signs (ASTC Rule)

QuadrantAngle RangesincostanMnemonic
I0° – 90°+++All positive
II90° – 180°+Sin positive
III180° – 270°+Tan positive
IV270° – 360°+Cos positive

2.4 — Reference Angles

The reference angle θ′ is the acute angle between the terminal side and the x-axis. For any θ: trig(θ) = ±trig(θ′), with the sign determined by the quadrant (ASTC rule).

§03 The Six Trigonometric Functions

3.1 — Definitions on the Unit Circle

sin θ = y    cos θ = x    tan θ = y/x = sin θ / cos θ
csc θ = 1/sin θ    sec θ = 1/cos θ    cot θ = 1/tan θ = cos θ / sin θ

3.2 — Domains & Ranges

FunctionDomainRangePeriod
sin θAll ℝ[−1, 1]
cos θAll ℝ[−1, 1]
tan θθ ≠ π/2 + nπ(−∞, ∞)π
csc θθ ≠ nπ(−∞,−1]∪[1,∞)
sec θθ ≠ π/2 + nπ(−∞,−1]∪[1,∞)
cot θθ ≠ nπ(−∞, ∞)π

3.3 — Even/Odd Properties

cos(−θ) = cos θ  (even)     sin(−θ) = −sin θ  (odd)     tan(−θ) = −tan θ  (odd)
PROOF — sin is odd, cos is even
On the unit circle, reflecting angle θ across the x-axis gives angle −θ.
Point (cos θ, sin θ) maps to (cos θ, −sin θ).
The x-coordinate is unchanged: cos(−θ) = cos θ. The y-coordinate negates: sin(−θ) = −sin θ.

§04 Right Triangles & SOH-CAH-TOA

4.1 — Definitions via Right Triangle

In a right triangle with acute angle θ, hypotenuse h, opposite side o, adjacent side a:

sin θ = o/h    cos θ = a/h    tan θ = o/a
csc θ = h/o    sec θ = h/a    cot θ = a/o

Mnemonic: SOH-CAH-TOA — Sin = Opposite/Hypotenuse, Cos = Adjacent/Hypotenuse, Tan = Opposite/Adjacent.

4.2 — The Pythagorean Theorem

a² + b² = c²    (where c is the hypotenuse)
PROOF — Pythagorean Theorem (Euclid's proof via similar triangles)
Drop an altitude h from the right angle to the hypotenuse c, creating two sub-triangles.
Both sub-triangles are similar to the original (AA similarity).
From the first: a/c = (segment₁)/a ⟹ a² = c · segment₁.
From the second: b/c = (segment₂)/b ⟹ b² = c · segment₂.
Adding: a² + b² = c(segment₁ + segment₂) = c · c = c².

4.3 — Special Right Triangles

TriangleAnglesSide Ratios
45-45-90π/4, π/4, π/21 : 1 : √2
30-60-90π/6, π/3, π/21 : √3 : 2
PROOF — 30-60-90 side ratios
Start with an equilateral triangle of side 2. All angles are 60°.
Drop an altitude: it bisects the base, creating two 30-60-90 triangles.
Each has hypotenuse 2, short side 1, and altitude = √(2²−1²) = √3.

4.4 — Interactive Triangle Solver

30° 60° 60
↑ Adjust angle A, angle B, and side c. Triangle auto-solves using Law of Sines. C = 180° − A − B.

§05 Oblique Triangles

5.1 — Law of Sines

a/sin A = b/sin B = c/sin C = 2R    (R = circumradius)
PROOF — Law of Sines
Drop altitude h from vertex C to side c. Then h = a sin B = b sin A.
So a sin B = b sin A ⟹ a/sin A = b/sin B.
Repeat with altitude from A: b/sin B = c/sin C.
For the circumradius: inscribe the triangle in a circle of radius R. The inscribed angle theorem gives c = 2R sin C, so c/sin C = 2R.

5.2 — Law of Cosines

c² = a² + b² − 2ab cos C
PROOF — Law of Cosines (coordinate method)
Place C at origin, B at (a, 0), A at (b cos C, b sin C).
c² = ‖A − B‖² = (b cos C − a)² + (b sin C)²
= b² cos²C − 2ab cos C + a² + b² sin²C
= a² + b²(cos²C + sin²C) − 2ab cos C = a² + b² − 2ab cos C.

5.3 — Law of Tangents

(a − b)/(a + b) = tan((A−B)/2) / tan((A+B)/2)

5.4 — Heron's Formula

Area = √[s(s−a)(s−b)(s−c)]    where s = (a+b+c)/2
PROOF — Heron's Formula from the Law of Cosines
Area = ½ab sin C. From the law of cosines: cos C = (a²+b²−c²)/(2ab).
sin²C = 1 − cos²C = [4a²b² − (a²+b²−c²)²] / (4a²b²).
Factor the numerator as a difference of squares: [2ab − (a²+b²−c²)][2ab + (a²+b²−c²)].
= [c² − (a−b)²][(a+b)² − c²] = (c−a+b)(c+a−b)(a+b−c)(a+b+c).
Substituting s = (a+b+c)/2: Area² = (½ab)² · sin²C = s(s−a)(s−b)(s−c).

5.5 — Area Formulas Summary

MethodFormula
Base × HeightA = ½bh
Two sides + included angleA = ½ab sin C
Heron's (three sides)A = √[s(s−a)(s−b)(s−c)]
CircumradiusA = abc / (4R)
InradiusA = rs   (r = inradius)

§06 Circles — Geometry & Trigonometry

6.1 — Circle Equations

Standard: (x−h)² + (y−k)² = r²    Center (h,k), radius r
Parametric: x = h + r cos t,   y = k + r sin t,   t ∈ [0, 2π)

6.2 — Arc Length & Sector Area

Arc: s = rθ     Sector: A = ½r²θ     Segment: A = ½r²(θ − sin θ)

6.3 — Inscribed Angle Theorem

THEOREM & PROOF — Inscribed angle = ½ central angle
An inscribed angle is formed by two chords meeting at a point on the circle.
Case 1 (one side is a diameter): Let the inscribed angle be α at point A, subtending arc BC where AB is a diameter. Triangle OAC is isosceles (OA = OC = r). The exterior angle at O = 2α. So the central angle = 2α, giving α = ½(central angle).
General case: Draw diameter AD. Apply Case 1 to angles BAD and DAC separately, then add or subtract.

6.4 — Thales' Theorem

An angle inscribed in a semicircle is always 90°. This is the inscribed angle theorem with central angle 180° (π), giving inscribed angle = π/2.

6.5 — Chord Length & Tangent Lines

Chord length: ℓ = 2r sin(θ/2)    (θ = central angle)
Tangent-Radius: tangent ⊥ radius at point of tangency
Power of a Point: PA · PB = PC · PD   (intersecting chords/secants)

6.6 — Circles & Trigonometry in Navigation

The Haversine formula computes great-circle distances on a sphere using trig:

a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2)
d = 2R · arctan2(√a, √(1−a))

where φ = latitude, λ = longitude, R = Earth's radius. Every GPS device uses this formula.

§07 Trigonometric Identities

7.1 — Pythagorean Identities

sin²θ + cos²θ = 1     1 + tan²θ = sec²θ     1 + cot²θ = csc²θ
PROOF — sin²θ + cos²θ = 1
On the unit circle, (cos θ, sin θ) satisfies x² + y² = 1.
Therefore cos²θ + sin²θ = 1. Divide by cos²θ: 1 + tan²θ = sec²θ. Divide by sin²θ: cot²θ + 1 = csc²θ.

7.2 — Sum & Difference Formulas

sin(α ± β) = sin α cos β ± cos α sin β
cos(α ± β) = cos α cos β ∓ sin α sin β
tan(α ± β) = (tan α ± tan β) / (1 ∓ tan α tan β)
PROOF — cos(α − β) via distance formula on the unit circle
Points A = (cos α, sin α) and B = (cos β, sin β) lie on the unit circle.
Distance² = (cos α − cos β)² + (sin α − sin β)²
= cos²α − 2cos α cos β + cos²β + sin²α − 2sin α sin β + sin²β
= 2 − 2(cos α cos β + sin α sin β).
But also, by the law of cosines on the unit circle triangle: Distance² = 2 − 2cos(α − β).
Equating: cos(α − β) = cos α cos β + sin α sin β.
Replace β with −β: cos(α + β) = cos α cos β − sin α sin β.
Use sin θ = cos(π/2 − θ) to derive the sine formulas.

7.3 — Double-Angle Formulas

sin 2θ = 2 sin θ cos θ
cos 2θ = cos²θ − sin²θ = 2cos²θ − 1 = 1 − 2sin²θ
tan 2θ = 2tan θ / (1 − tan²θ)

7.4 — Half-Angle Formulas

sin(θ/2) = ±√[(1 − cos θ)/2]     cos(θ/2) = ±√[(1 + cos θ)/2]
tan(θ/2) = sin θ/(1 + cos θ) = (1 − cos θ)/sin θ

7.5 — Product-to-Sum & Sum-to-Product

sin α cos β = ½[sin(α+β) + sin(α−β)]
cos α cos β = ½[cos(α−β) + cos(α+β)]
sin α + sin β = 2 sin((α+β)/2) cos((α−β)/2)
cos α + cos β = 2 cos((α+β)/2) cos((α−β)/2)

7.6 — Power-Reduction Formulas

sin²θ = (1 − cos 2θ)/2     cos²θ = (1 + cos 2θ)/2

7.7 — Auxiliary Angle Method

PROOF — a sin θ + b cos θ = R sin(θ + φ)
Let R = √(a² + b²) and φ = arctan(b/a).
R sin(θ + φ) = R[sin θ cos φ + cos θ sin φ] = R cos φ · sin θ + R sin φ · cos θ.
Set R cos φ = a and R sin φ = b: these give R² = a² + b² and tan φ = b/a. ✓

§08 Inverse Trigonometric Functions

8.1 — Definitions & Ranges

FunctionDomainRange (Principal Value)
arcsin x = sin⁻¹ x[−1, 1][−π/2, π/2]
arccos x = cos⁻¹ x[−1, 1][0, π]
arctan x = tan⁻¹ x(−∞, ∞)(−π/2, π/2)
arccsc x|x| ≥ 1[−π/2, 0) ∪ (0, π/2]
arcsec x|x| ≥ 1[0, π/2) ∪ (π/2, π]
arccot x(−∞, ∞)(0, π)

8.2 — Key Identities

arcsin x + arccos x = π/2    arctan x + arccot x = π/2
arctan x + arctan(1/x) = π/2   (x > 0)

8.3 — atan2: The Full-Circle Arctangent

atan2(y, x) = angle of (x,y) from the positive x-axis, range (−π, π]

Unlike arctan(y/x), atan2 uses both coordinates to determine the correct quadrant. Essential in computer graphics, robotics, and signal processing.

8.4 — Compositions

sin(arccos x) = √(1−x²)    cos(arcsin x) = √(1−x²)    tan(arcsin x) = x/√(1−x²)
PROOF — sin(arccos x) = √(1−x²)
Let θ = arccos x, so cos θ = x and θ ∈ [0,π].
sin²θ = 1 − cos²θ = 1 − x². Since θ ∈ [0,π], sin θ ≥ 0.
Therefore sin(arccos x) = √(1−x²).

§09 Graphs, Transformations & Waves

9.1 — General Sinusoid

y = A sin(Bx + C) + D
ParameterEffectFormula
AAmplitude|A|
BFrequencyPeriod = 2π/|B|
CPhase shiftShift = −C/B
DVertical shiftMidline y = D

9.2 — Interactive Wave Explorer

1.0 1.0 0.0 0.0
↑ y = A·sin(Bx + C) + D — adjust sliders to see amplitude, frequency, phase & vertical shift in real time.

9.3 — Graphs of All Six Functions

FunctionShapePeriodAsymptotes
sin xSmooth wave, through originNone
cos xSmooth wave, max at x=0None
tan xIncreasing through origin, S-curvesπx = π/2 + nπ
csc xU/∩ curves between asymptotesx = nπ
sec xU/∩ curves between asymptotesx = π/2 + nπ
cot xDecreasing S-curvesπx = nπ

9.4 — Beats & Interference

sin(ω₁t) + sin(ω₂t) = 2 cos((ω₁−ω₂)t/2) sin((ω₁+ω₂)t/2)

When ω₁ ≈ ω₂, the cosine factor creates a slow envelope — the phenomenon of beats in acoustics. The sum-to-product identity is the mathematical engine.

§10 Derivatives of Trigonometric Functions

10.1 — The Foundational Limits

PROOF — limθ→0 sin θ / θ = 1 (Squeeze Theorem)
For 0 < θ < π/2, consider a unit circle sector. By area comparison:
Area(inner triangle) ≤ Area(sector) ≤ Area(outer triangle)
½ sin θ ≤ ½θ ≤ ½ tan θ
Divide by ½ sin θ > 0: 1 ≤ θ/sin θ ≤ 1/cos θ.
Invert: cos θ ≤ sin θ/θ ≤ 1.
As θ → 0⁺, cos θ → 1, so by the Squeeze Theorem, sin θ/θ → 1. By the even/odd argument, the limit from the left also equals 1.
PROOF — limθ→0 (cos θ − 1)/θ = 0
Multiply by (cos θ + 1)/(cos θ + 1): (cos²θ − 1)/(θ(cos θ + 1)) = −sin²θ/(θ(cos θ + 1)).
= −(sin θ/θ) · sin θ/(cos θ + 1) → −1 · 0/(1+1) = 0.

10.2 — d/dx [sin x] = cos x

PROOF — Derivative of sine from the definition
d/dx[sin x] = limh→0 [sin(x+h) − sin x]/h
= limh→0 [sin x cos h + cos x sin h − sin x]/h
= sin x · lim[(cos h − 1)/h] + cos x · lim[sin h / h]
= sin x · 0 + cos x · 1 = cos x.

10.3 — d/dx [cos x] = −sin x

PROOF — Derivative of cosine
d/dx[cos x] = d/dx[sin(π/2 − x)] = cos(π/2 − x) · (−1) = −sin x.
Alternatively, from the definition: limh→0 [cos(x+h)−cos x]/h = lim[cos x(cos h−1) − sin x sin h]/h = −sin x.

10.4 — d/dx [tan x] = sec² x

PROOF — Derivative of tangent via quotient rule
d/dx[tan x] = d/dx[sin x / cos x] = (cos x · cos x − sin x · (−sin x)) / cos²x
= (cos²x + sin²x) / cos²x = 1/cos²x = sec²x.

10.5 — Complete Derivative Table

f(x)f′(x)f(x)f′(x)
sin xcos xarcsin x1/√(1−x²)
cos x−sin xarccos x−1/√(1−x²)
tan xsec²xarctan x1/(1+x²)
csc x−csc x cot xarccsc x−1/(|x|√(x²−1))
sec xsec x tan xarcsec x1/(|x|√(x²−1))
cot x−csc²xarccot x−1/(1+x²)

10.6 — Inverse Trig Derivative Proofs

PROOF — d/dx [arcsin x] = 1/√(1−x²)
Let y = arcsin x, so sin y = x and y ∈ [−π/2, π/2].
Differentiate implicitly: cos y · dy/dx = 1 ⟹ dy/dx = 1/cos y.
Since cos y = √(1 − sin²y) = √(1 − x²) (cos y ≥ 0 on [−π/2, π/2]):
d/dx[arcsin x] = 1/√(1 − x²).
PROOF — d/dx [arctan x] = 1/(1+x²)
Let y = arctan x, so tan y = x.
Differentiate: sec²y · dy/dx = 1 ⟹ dy/dx = 1/sec²y = 1/(1 + tan²y) = 1/(1 + x²).

10.7 — The nth Derivative Cycle

dⁿ/dxⁿ [sin x] = sin(x + nπ/2)     dⁿ/dxⁿ [cos x] = cos(x + nπ/2)

The derivatives cycle with period 4: sin → cos → −sin → −cos → sin → ⋯

§11 Integration of Trigonometric Functions

11.1 — Basic Antiderivatives

∫ f(x) dxResult + C
∫ sin x dx−cos x
∫ cos x dxsin x
∫ tan x dx−ln|cos x| = ln|sec x|
∫ cot x dxln|sin x|
∫ sec x dxln|sec x + tan x|
∫ csc x dx−ln|csc x + cot x| = ln|csc x − cot x|
∫ sec²x dxtan x
∫ csc²x dx−cot x
∫ sec x tan x dxsec x
∫ csc x cot x dx−csc x

11.2 — Proofs of Non-Obvious Integrals

PROOF — ∫ tan x dx = ln|sec x| + C
∫ tan x dx = ∫ sin x / cos x dx. Let u = cos x, du = −sin x dx.
= −∫ du/u = −ln|u| + C = −ln|cos x| + C = ln|sec x| + C.
PROOF — ∫ sec x dx = ln|sec x + tan x| + C
Multiply by (sec x + tan x)/(sec x + tan x):
∫ sec x dx = ∫ [sec²x + sec x tan x] / [sec x + tan x] dx.
Let u = sec x + tan x, du = (sec x tan x + sec²x) dx = numerator dx.
= ∫ du/u = ln|u| + C = ln|sec x + tan x| + C.

11.3 — Powers of Trig Functions

∫ sinⁿx dx and ∫ cosⁿx dx

Odd power: Strip one factor, convert the rest using sin²x = 1 − cos²x, substitute u = cos x (or vice versa).

Even power: Use power-reduction: sin²x = (1 − cos 2x)/2, cos²x = (1 + cos 2x)/2.

PROOF — Reduction formula: ∫ sinⁿx dx = −(sinⁿ⁻¹x cos x)/n + (n−1)/n · ∫ sinⁿ⁻²x dx
Write ∫ sinⁿx dx = ∫ sinⁿ⁻¹x · sin x dx. Integration by parts: u = sinⁿ⁻¹x, dv = sin x dx.
du = (n−1)sinⁿ⁻²x cos x dx, v = −cos x.
= −sinⁿ⁻¹x cos x + (n−1)∫ sinⁿ⁻²x cos²x dx
= −sinⁿ⁻¹x cos x + (n−1)∫ sinⁿ⁻²x (1 − sin²x) dx
= −sinⁿ⁻¹x cos x + (n−1)∫ sinⁿ⁻²x dx − (n−1)∫ sinⁿx dx.
Move the last term to the left: n∫ sinⁿx dx = −sinⁿ⁻¹x cos x + (n−1)∫ sinⁿ⁻²x dx. ÷n.

11.4 — Trigonometric Substitution

ExpressionSubstitutionIdentity Used
√(a² − x²)x = a sin θ1 − sin²θ = cos²θ
√(a² + x²)x = a tan θ1 + tan²θ = sec²θ
√(x² − a²)x = a sec θsec²θ − 1 = tan²θ
EXAMPLE — ∫ dx/√(1−x²) = arcsin x + C
Let x = sin θ, dx = cos θ dθ. Then √(1−x²) = cos θ.
∫ cos θ dθ / cos θ = ∫ dθ = θ + C = arcsin x + C.

11.5 — The Weierstrass Substitution

t = tan(x/2)  ⟹  sin x = 2t/(1+t²),   cos x = (1−t²)/(1+t²),   dx = 2dt/(1+t²)
PROOF — Weierstrass substitution formulas
Let t = tan(x/2). Then sin x = 2sin(x/2)cos(x/2).
Divide by cos²(x/2) + sin²(x/2) = 1: sin x = 2tan(x/2)/sec²(x/2) = 2t/(1+t²).
Similarly cos x = (cos²(x/2) − sin²(x/2))/(cos²(x/2) + sin²(x/2)) = (1−t²)/(1+t²).
For dx: x = 2 arctan t, so dx = 2/(1+t²) dt.

This converts any rational function of sin and cos into a rational function of t, solvable by partial fractions.

11.6 — The Gaussian Integral via Trig

PROOF — ∫−∞ e−x² dx = √π (polar coordinates method)
Let I = ∫−∞ e−x² dx. Then I² = ∫∫ e−(x²+y²) dx dy.
Convert to polar: x = r cos θ, y = r sin θ, dx dy = r dr dθ.
I² = ∫₀ ∫₀ e−r² r dr dθ = 2π · [−½e−r²]₀ = 2π · ½ = π.
Therefore I = √π. This integral underpins Gaussian distributions in probability and cryptographic lattice sampling.

§12 Polar Coordinates & Complex Numbers

12.1 — Polar Coordinates

x = r cos θ    y = r sin θ    r = √(x²+y²)    θ = atan2(y,x)

12.2 — Common Polar Curves

CurveEquationShape
Circler = aCircle radius a
Cardioidr = a(1 + cos θ)Heart shape
Roser = a cos(nθ)n petals (n odd) or 2n petals (n even)
Lemniscater² = a² cos 2θFigure-8
Spiralr = aθArchimedean spiral

12.3 — Area in Polar Coordinates

A = ½ ∫αβ r(θ)² dθ
PROOF — Polar area formula
Divide the region into thin sectors of angle Δθ. Each has area ≈ ½r²Δθ (sector area formula).
Summing: A ≈ Σ ½r(θᵢ)²Δθ → ½∫ r²dθ as Δθ → 0.

12.4 — Complex Numbers & Euler's Formula

z = a + bi = r(cos θ + i sin θ) = re
PROOF — Euler's formula e = cos θ + i sin θ (via Taylor series)
e = Σ (iθ)ⁿ/n! = 1 + iθ − θ²/2! − iθ³/3! + θ⁴/4! + ⋯
Separate real and imaginary: = (1 − θ²/2! + θ⁴/4! − ⋯) + i(θ − θ³/3! + θ⁵/5! − ⋯)
= cos θ + i sin θ.

12.5 — De Moivre's Theorem

(cos θ + i sin θ)ⁿ = cos nθ + i sin nθ
PROOF — De Moivre's Theorem
(e)ⁿ = einθ. By Euler's formula:
(cos θ + i sin θ)ⁿ = cos nθ + i sin nθ.

12.6 — Roots of Unity

zn = 1  ⟹  zk = e2πik/n = cos(2πk/n) + i sin(2πk/n),   k = 0,1,…,n−1

The n-th roots of unity form a regular n-gon on the unit circle. They are the foundation of the DFT (§13) and NTT (§14, lattice cryptography).

12.7 — Euler's Identity

e + 1 = 0

Five fundamental constants — e, i, π, 1, 0 — united by trigonometry and the exponential function.

§13 Fourier Series & Applications

13.1 — Fourier Series

Any periodic function f(x) with period 2π can be expressed as:

f(x) = a₀/2 + Σn=1 [aₙ cos(nx) + bₙ sin(nx)]
aₙ = (1/π) ∫−ππ f(x) cos(nx) dx     bₙ = (1/π) ∫−ππ f(x) sin(nx) dx
PROOF — Orthogonality of {sin(nx), cos(mx)}
−ππ sin(nx)cos(mx) dx = 0 for all n,m (product of odd × even function over symmetric interval).
−ππ cos(nx)cos(mx) dx = πδnm (use product-to-sum: ½∫[cos(n−m)x + cos(n+m)x]dx).
−ππ sin(nx)sin(mx) dx = πδnm (similarly).
Multiply f(x) by cos(mx) and integrate, using orthogonality: only the aₘ term survives.

13.2 — Discrete Fourier Transform (DFT)

X[k] = Σn=0N−1 x[n] · e−2πikn/N    (analysis: decompose into frequencies)
x[n] = (1/N) Σk=0N−1 X[k] · e2πikn/N    (synthesis: reconstruct from frequencies)

13.3 — The FFT Algorithm

The Fast Fourier Transform computes the DFT in O(N log N) instead of O(N²) by exploiting the symmetry of roots of unity (the Cooley-Tukey butterfly). This makes audio processing, image compression (JPEG uses DCT, a real cousin of DFT), and polynomial multiplication practical.

13.4 — Parseval's Theorem

(1/2π) ∫−ππ |f(x)|² dx = |a₀|²/4 + ½Σ(aₙ² + bₙ²)

Energy in the time domain equals energy in the frequency domain — a conservation law derived from trig orthogonality.

13.5 — Application: The Basel Problem

PROOF — Σ 1/n² = π²/6 via Fourier series
Let f(x) = x on [−π,π]. Its Fourier coefficients: a₀ = 0, aₙ = 0, bₙ = (−1)ⁿ⁺¹ · 2/n.
Parseval: (1/2π)∫|x|²dx = ½Σ(4/n²). Left side: (1/2π)·(2π³/3) = π²/3.
So π²/3 = 2 Σ 1/n² ⟹ Σ 1/n² = π²/6.

§14 Cryptography — Trigonometry in Security

14.1 — Why Trig in Crypto?

Trigonometry appears throughout cryptography: from the periodicity that makes modular arithmetic work, to the Fourier transforms at the heart of lattice-based post-quantum schemes, to the geometry of elliptic curves.

14.2 — The Number Theoretic Transform (NTT)

The NTT is a DFT over a finite field 𝔽q instead of ℂ. It replaces e−2πi/N with a primitive N-th root of unity ω in 𝔽q (where ωN ≡ 1 mod q). The NTT enables fast polynomial multiplication in lattice cryptography (CRYSTALS-Kyber, Dilithium) without floating-point errors.

CONNECTION — Trig roots → NTT roots
In ℂ: the N-th roots of unity are e2πik/N = cos(2πk/N) + i sin(2πk/N).
In 𝔽q: we need ω with ωN ≡ 1 (mod q) and ωk ≢ 1 for 0 < k < N.
This exists when N | (q−1). The FFT butterfly structure is identical in both settings.
The trig orthogonality relations become: Σn ωkn ≡ 0 (mod q) for k ≢ 0.

14.3 — Gaussian Sampling for Lattice Crypto

Lattice schemes sample noise from a discrete Gaussian ρσ(x) = exp(−π‖x‖²/σ²). The normalization uses the Gaussian integral (§11.6). The smoothing parameter ηε is computed via the Poisson summation formula, which is the Fourier transform (a trig integral) applied to lattices.

14.4 — Elliptic Curve Trigonometric Parameterization

Elliptic curves over ℂ can be parameterized by the Weierstrass ℘-function, which is doubly-periodic (two independent "periods" in the complex plane, generalizing the single period 2π of sin/cos). The group law on E corresponds to the addition theorem for ℘ — a direct generalization of trig addition formulas.

14.5 — CORDIC Algorithm

The CORDIC (COordinate Rotation DIgital Computer) algorithm computes sin, cos, arctan using only shifts and adds — no multiplication. It rotates a vector by successively smaller angles αᵢ = arctan(2⁻ⁱ):

xi+1 = xi − σᵢ 2⁻ⁱ yi     yi+1 = yi + σᵢ 2⁻ⁱ xi

where σᵢ = ±1 chooses the rotation direction. After n iterations, (xn, yn) ≈ K(cos θ, sin θ). CORDIC is used in hardware crypto accelerators where multipliers are expensive.

14.6 — Diffie-Hellman via Trig Analogy

The Diffie-Hellman key exchange: Alice picks secret a, publishes ga mod p. Bob picks secret b, publishes gb mod p. Shared secret: gab mod p.

Trig analogy: ga is like rotating by angle a on a "discrete unit circle" (the cyclic group ℤp*). Knowing the rotation angle from the final position is the discrete logarithm problem — as hard as un-rotating a circle when you can only see the endpoint.

14.7 — RSA & Euler's Totient

CONNECTION — Euler's formula and Euler's theorem
Euler's formula: e has period 2π, so ei(θ+2π) = e.
Euler's theorem: aφ(n) ≡ 1 (mod n) — exponentiation has period φ(n) in ℤn*.
Both are periodicity: one in the continuous world (trig), one in the discrete world (number theory).
RSA exploits this: e·d ≡ 1 mod φ(n), so med = m1+kφ(n) = m · (mφ(n))k ≡ m.
GNU Octave — Crypto Trig
% --- NTT roots of unity in F_q ---
q = 7681; N = 256; % q ≡ 1 mod 256
g = 17; % generator of F_q*
omega = mod(power_mod(g, (q-1)/N, q), q);
function r = power_mod(b,e,m)
  r=1;b=mod(b,m);while e>0;if mod(e,2)==1,r=mod(r*b,m);end;e=floor(e/2);b=mod(b*b,m);end
end
printf("NTT: ω=%d, ω^N mod q = %d (should be 1)\n", omega, power_mod(omega, N, q));

% --- CORDIC sine/cosine ---
angles = atan(2.^-(0:29));
K = prod(1./sqrt(1 + 2.^(-2*(0:29))));
target = pi/5; x = K; y = 0; z = target;
for i = 0:29
  s = sign(z) + (z==0);
  xn = x - s*y*2^(-i); yn = y + s*x*2^(-i);
  z = z - s*angles(i+1); x = xn; y = yn;
end
printf("CORDIC: cos(π/5)=%.10f (exact %.10f)\n", x, cos(target));
printf("CORDIC: sin(π/5)=%.10f (exact %.10f)\n", y, sin(target));

§15 GNU Octave — Trigonometry & Trig Calculus Laboratory

15.1 — Verifying Trig Identities

GNU Octave — Identity Verification
% Verify fundamental identities at 1000 random angles
th = 2*pi*rand(1,1000);
e1 = max(abs(sin(th).^2 + cos(th).^2 - 1));
e2 = max(abs(sin(2*th) - 2*sin(th).*cos(th)));
e3 = max(abs(cos(2*th) - (cos(th).^2 - sin(th).^2)));
a = rand(1,1000)*pi; b = rand(1,1000)*pi;
e4 = max(abs(sin(a+b) - (sin(a).*cos(b) + cos(a).*sin(b))));
printf("Identity errors (should be ≈0):\n");
printf("  sin²+cos²=1:   %.2e\n  sin 2θ:         %.2e\n", e1, e2);
printf("  cos 2θ:         %.2e\n  sin(a+b):       %.2e\n", e3, e4);

15.2 — Numerical Derivatives of Trig Functions

GNU Octave — Complex-Step Derivatives
% Verify all 6 trig derivatives with complex-step method
h = 1e-20; x = 0.7;
deriv = @(f,x) imag(f(x + 1i*h)) / h;

funcs = {@sin, @cos, @tan, @csc, @sec, @cot};
exact_d = {cos(x), -sin(x), sec(x)^2, -csc(x)*cot(x), sec(x)*tan(x), -csc(x)^2};
names = {'sin','cos','tan','csc','sec','cot'};

printf("Trig derivatives at x = %.1f:\n", x);
for k = 1:6
  d = deriv(funcs{k}, x);
  printf("  d/dx[%s] = %12.8f  (exact %12.8f, err %.1e)\n", ...
    names{k}, d, exact_d{k}, abs(d - exact_d{k}));
end

15.3 — Numerical Integration of Trig Functions

GNU Octave — Trig Integrals via Quadrature
% Verify antiderivatives numerically
printf("Trig integrals:\n");
I1 = quad(@sin, 0, pi);
printf("  ∫₀^π sin x dx = %.10f (exact 2)\n", I1);

I2 = quad(@(x) sec(x).^2, 0, pi/4);
printf("  ∫₀^(π/4) sec²x dx = %.10f (exact tan(π/4)=1)\n", I2);

I3 = quad(@(x) 1./(1+x.^2), 0, 1);
printf("  ∫₀¹ 1/(1+x²) dx = %.10f (exact π/4=%.10f)\n", I3, pi/4);

I4 = quad(@(x) 1./sqrt(1-x.^2), 0, 0.5);
printf("  ∫₀^0.5 1/√(1-x²) dx = %.10f (exact arcsin(0.5)=%.10f)\n", I4, asin(0.5));

% Reduction formula: ∫₀^(π/2) sin⁶x dx = 5π/32
I5 = quad(@(x) sin(x).^6, 0, pi/2);
printf("  ∫₀^(π/2) sin⁶x dx = %.10f (exact 5π/32=%.10f)\n", I5, 5*pi/32);

15.4 — Fourier Synthesis & Analysis

GNU Octave — Fourier Series of Square Wave
% Square wave: f(x) = (4/π) Σ sin((2k-1)x)/(2k-1)
x = linspace(-pi, pi, 1000);
for N = [1, 5, 20, 100]
  f = zeros(size(x));
  for k = 1:N
    n = 2*k - 1;
    f = f + sin(n*x)/n;
  end
  f = f * 4/pi;
  err = mean(abs(f - sign(sin(x))));
  printf("Fourier N=%3d terms: mean error = %.6f\n", N, err);
end

15.5 — Haversine Navigation

GNU Octave — Great-Circle Distance
% Haversine formula: distance between two points on Earth
function d = haversine(lat1, lon1, lat2, lon2)
  R = 6371; % Earth radius km
  p = pi/180;
  dlat = (lat2-lat1)*p; dlon = (lon2-lon1)*p;
  a = sin(dlat/2)^2 + cos(lat1*p)*cos(lat2*p)*sin(dlon/2)^2;
  d = 2*R*atan2(sqrt(a), sqrt(1-a));
end

% New York → London
d = haversine(40.7128, -74.0060, 51.5074, -0.1278);
printf("NYC → London: %.1f km\n", d);

% Tokyo → Sydney
d = haversine(35.6762, 139.6503, -33.8688, 151.2093);
printf("Tokyo → Sydney: %.1f km\n", d);

15.6 — Lissajous Figures & 3D Trig Surfaces

GNU Octave — Lissajous & Parametric Surfaces
% Lissajous: x = sin(at+δ), y = sin(bt)
t = linspace(0, 2*pi, 10000);
for params = [3,2,pi/4; 5,4,pi/3; 7,6,pi/6]'
  a = params(1); b = params(2); delta = params(3);
  x = sin(a*t + delta); y = sin(b*t);
  printf("Lissajous a=%d b=%d: bounding box [%.2f,%.2f]×[%.2f,%.2f]\n", ...
    a, b, min(x), max(x), min(y), max(y));
end

% 3D Torus: (R+r cos v)cos u, (R+r cos v)sin u, r sin v
R = 3; r = 1;
[u,v] = meshgrid(linspace(0,2*pi,50));
X = (R+r*cos(v)).*cos(u);
Y = (R+r*cos(v)).*sin(u);
Z = r*sin(v);
printf("Torus: R=%d, r=%d, surface area = %.4f (exact 4π²Rr = %.4f)\n", ...
  R, r, 4*pi^2*R*r, 4*pi^2*R*r);

15.7 — Comprehensive Verification

GNU Octave — Master Verification Suite
printf("=== TRIG & CALCULUS VERIFICATION ===\n\n");

% Euler's identity
printf("|e^(iπ)+1| = %.2e\n", abs(exp(1i*pi)+1));

% De Moivre n=7
th = 0.3; n = 7;
lhs = (cos(th)+1i*sin(th))^n;
rhs = cos(n*th)+1i*sin(n*th);
printf("De Moivre (n=%d): error = %.2e\n", n, abs(lhs-rhs));

% Machin's formula: π = 4(4·atan(1/5) - atan(1/239))
pi_machin = 4*(4*atan(1/5) - atan(1/239));
printf("Machin π = %.15f (error %.2e)\n", pi_machin, abs(pi_machin-pi));

% Wallis product: π/2 = Π(4n²/(4n²-1))
n = 1:100000;
wallis = prod(4*n.^2 ./ (4*n.^2 - 1));
printf("Wallis π/2 = %.10f (exact %.10f)\n", wallis, pi/2);

% Leibniz: π/4 = 1 - 1/3 + 1/5 - ...
n = 0:1e6; leibniz = sum((-1).^n ./ (2*n+1));
printf("Leibniz π/4 = %.10f (exact %.10f)\n", leibniz, pi/4);

% Basel: Σ1/n² = π²/6
n = 1:1e6; basel = sum(1./n.^2);
printf("Basel π²/6 = %.10f (exact %.10f)\n", basel, pi^2/6);

% Gaussian integral
I = quad(@(x) exp(-x.^2), -20, 20);
printf("∫exp(-x²) = %.10f (exact √π = %.10f)\n", I, sqrt(pi));

⚡ Quick Reference Card

Trig Values

θ0π/6π/4π/3π/2
sin0½√2/2√3/21
cos1√3/2√2/2½0
tan01/√31√3

Derivatives & Integrals

ff′∫f dx
sin xcos x−cos x
cos x−sin xsin x
tan xsec²xln|sec x|
sec xsec x tan xln|sec x+tan x|
csc x−csc x cot xln|csc x−cot x|
cot x−csc²xln|sin x|

Inverse Trig Derivatives

ff′
arcsin x1/√(1−x²)
arccos x−1/√(1−x²)
arctan x1/(1+x²)

Key Identities

Identity
sin²θ + cos²θ = 1
sin(α±β) = sin α cos β ± cos α sin β
cos(α±β) = cos α cos β ∓ sin α sin β
sin 2θ = 2 sin θ cos θ
cos 2θ = cos²θ − sin²θ
e = cos θ + i sin θ

Triangle Laws

LawFormula
Sinesa/sin A = b/sin B = c/sin C
Cosinesc² = a² + b² − 2ab cos C
HeronA = √[s(s−a)(s−b)(s−c)]

Trig Substitution

√(a²−x²)√(a²+x²)√(x²−a²)
x = a sin θx = a tan θx = a sec θ