Trigonometry: Circles, Triangles, Calculus, and Cryptography

A complete, interactive guide from the geometric origins of sine and cosine to their derivatives, integrals, and surprising roles in modern encryption.

1 Foundations – Angles, Degrees, Radians, Unit Circle

An angle measures rotation. Degrees are historical (360° = full turn). Radians are natural: one radian is the angle that subtends an arc equal to the radius. Therefore:

2π radians = 360°   |   rad = deg × π/180   |   deg = rad × 180/π

The unit circle is x2 + y2 = 1. For an angle θ from the positive x-axis, the point where the ray meets the circle is defined as:

(cos θ, sin θ)

Thus cos θ is the horizontal coordinate, sin θ is the vertical. The tangent is the slope: tan θ = sin θ / cos θ. Geometrically it is the length of the tangent segment at (1,0) up to the extended radius.

This definition works for any angle, not just acute triangles, and immediately gives periodicity and signs in quadrants.

θ: 0.524 rad
deg: 30.0°
cos: 0.866
sin: 0.500
tan: 0.577
quad: I
% GNU Octave: unit circle
theta = linspace(0, 2*pi, 400);
plot(cos(theta), sin(theta), 'LineWidth', 2); axis equal; grid on;
xlabel('cos \theta'); ylabel('sin \theta'); title('Unit Circle');

2 Right Triangles – SOHCAHTOA

For a right triangle with acute angle θ:

sin θ = opposite / hypotenuse   (SOH)
cos θ = adjacent / hypotenuse   (CAH)
tan θ = opposite / adjacent   (TOA)

Squaring and adding gives the first Pythagorean identity:

sin2θ + cos2θ = (opp2+adj2)/hyp2 = 1

Drag the angle in the demo. The hypotenuse stays fixed, showing how sine grows as the angle opens.

θ: 30°
hyp: 150
opp: 75.0
adj: 129.9
sin: 0.500
cos: 0.866
% GNU Octave: solve right triangle
theta = 30 * pi/180;  % radians
hyp = 1;
opp = hyp * sin(theta);
adj = hyp * cos(theta);
printf('sin=%.4f cos=%.4f tan=%.4f\n', opp/hyp, adj/hyp, opp/adj);

3 Graphs of Trig Functions

Sin and cos are waves of period 2π, amplitude 1. Tangent repeats every π with vertical asymptotes where cos=0. Sec = 1/cos, csc = 1/sin, cot = 1/tan inherit asymptotes.

General form

y = A · f(Bx + C)

A scales height, B compresses horizontally (period = 2π/B for sin/cos), C shifts left/right.

FunctionPeriodZeros
sin x, cos xsin at kπ, cos at π/2+kπ
tan x, cot xπtan at kπ
sec x, csc xnone (asymptotes)
% GNU Octave: parameterized wave
x = -2*pi:0.01:2*pi;
A = 2; B = 1.5; C = pi/4;
y = A * sin(B*x + C);
plot(x,y); grid on; xlabel('x'); ylabel('y');

4 Identities

Pythagorean

  • sin2a + cos2a = 1
  • 1 + tan2a = sec2a
  • 1 + cot2a = csc2a

Sum / Difference

  • sin(a±b) = sin a cos b ± cos a sin b
  • cos(a±b) = cos a cos b ∓ sin a sin b
  • tan(a+b) = (tan a + tan b)/(1 - tan a tan b)

Double-angle

  • sin 2a = 2 sin a cos a
  • cos 2a = cos2a - sin2a
  • cos 2a = 2cos2a -1 = 1-2sin2a
LHS: -
RHS: -
Diff: -
Status: -
% GNU Octave: verify sum identity numerically
a = 0.7; b = 1.2;
lhs = sin(a+b);
rhs = sin(a)*cos(b) + cos(a)*sin(b);
abs(lhs - rhs)  % ~1e-16

5 Inverse Trigonometric Functions

Since sin, cos, tan are periodic, we restrict domains to make inverses single-valued (principal branches):

  • arcsin x: domain [-1,1], range [-π/2, π/2]
  • arccos x: domain [-1,1], range [0, π]
  • arctan x: domain ℝ, range (-π/2, π/2)
arcsin: 0.524 rad
arccos: 1.047 rad
arctan: 0.785 rad

The diagram shows y = sin θ. For a given y, arcsin picks the unique θ in the right half of the unit circle. This restriction is why calculators return only one angle.

Use arctan2(y,x) in programming to recover the full angle in (-π,π] from coordinates.
% GNU Octave: inverses
x = 0.5;
asin(x)   % 0.5236
acos(x)   % 1.0472
atan(10)  % 1.4711

6 Calculus of Trig Functions

Derivatives

Using limh→0 sin h / h = 1 and lim (cos h -1)/h = 0:

d/dx sin x = cos x
d/dx cos x = -sin x
d/dx tan x = sec2x = 1 + tan2x
d/dx sec x = sec x tan x ,   d/dx csc x = -csc x cot x ,   d/dx cot x = -csc2x

Proof sketch for sin: sin(x+h)-sin x = sin x(cos h -1)+cos x sin h. Divide by h, take limits → cos x.

Integrals

∫ sin x dx = -cos x + C
∫ cos x dx = sin x + C
∫ sec2x dx = tan x + C
∫ sec x tan x dx = sec x + C

Chain rule

d/dx sin(u(x)) = cos(u) · u'
d/dx cos(3x2) = -sin(3x2)·6x
f(x0): -
f'(x0): -
slope: -
∫₀ᵇ f: -
Formula: -
% GNU Octave: symbolic calculus (pkg load symbolic)
pkg load symbolic
syms x
diff(sin(x))          % cos(x)
diff(cos(x))          % -sin(x)
diff(tan(x))          % 1 + tan(x)^2
int(sin(x))           % -cos(x)
int(cos(x))           % sin(x)
int(sec(x)^2)         % tan(x)

7 Applications in Calculus – Harmonic Motion

Simple harmonic motion solves y'' + ω2y = 0. The characteristic equation r22=0 gives r=±iω, so:

y(t) = A cos(ωt) + B sin(ωt) = R cos(ωt - φ)

Mass-spring systems, pendulums (small angles), AC circuits, and sound waves all follow this. Trig functions are eigenfunctions of the second derivative, which makes Fourier series possible.

For y'' + y = 0 with y(0)=1, y'(0)=0, the unique solution is y = cos t. Check: y' = -sin t, y'' = -cos t = -y.

% GNU Octave: solve y'' + y = 0 numerically
t = 0:0.01:10;
y = cos(t);  % analytic
plot(t,y); grid on; title('Simple Harmonic Motion');

8 Mathematics and Cryptography of Trigonometry

Chebyshev polynomials

Define Tn(x) = cos(n·arccos x) for x∈[-1,1]. Then:

Tn(cos θ) = cos(nθ)

Key property – composition commutes:

Tm(Tn(x)) = Tmn(x) = Tn(Tm(x))

This mimics exponentiation: (gn)m = gnm. In the 1990s, researchers proposed a Diffie-Hellman-like key exchange: public x, Alice sends A = Ta(x), Bob sends B = Tb(x), shared secret S = Ta(B)=Tb(A)=Tab(x).

Why it failed – Bergamo attack (2004)

Over real numbers, given x and y = cos(a·arccos x), an attacker computes a' = arccos y / arccos x (mod 2π). Because cosine is periodic and computable, the "discrete log" is easy. Over finite fields, variants reduce to linear algebra. Bergamo et al. showed the system is insecure in practice.

Modern trigonometric crypto

  • Chaotic maps: xn+1 = sin(π r xn) or the sine logistic map generates pseudo-random sequences for image encryption. Sensitivity to initial k provides key space.
  • Stream ciphers: lightweight IoT devices use |sin(k·i)| scaled to bytes as keystream: ci = mi XOR floor(255·|sin(k·i)|). Fast, no S-boxes, but needs good key management.
  • DFT and lattices: The Discrete Fourier Transform uses complex exponentials e-i2πkn/N = cos - i sin. Lattice-based post-quantum schemes (Kyber, Dilithium) use the Number Theoretic Transform, an integer analogue of FFT, to multiply polynomials in O(n log n). The trig structure enables speed, not security directly.

Chebyshev Iteration

Tₙ(x): -
Tₘ(Tₙ): -
Tₙ(Tₘ): -
Tₘₙ(x): -

Trig Stream Cipher Demo

kstream: floor(255·|sin(k·i)|)
% GNU Octave: Chebyshev key exchange (insecure demo)
Tn = @(x,n) cos(n*acos(x));
x = 0.3; a = 123; b = 456;
A = Tn(x,a); B = Tn(x,b);
S1 = Tn(B,a); S2 = Tn(A,b);
printf('Shared equal? %d\n', abs(S1-S2) < 1e-12);
% GNU Octave: sine-based stream cipher
msg = 'HELLO'; k = 2.71828;
m = double(msg);
c = zeros(size(m));
for i = 1:length(m)
  ks = floor(255 * abs(sin(k*i)));
  c(i) = bitxor(m(i), ks);
endfor
% decrypt same loop
Security note: The sine XOR cipher here is for education only. Real cryptography requires proper key derivation, nonces, and authenticated encryption (e.g., ChaCha20). Never use raw sin for production security.