TExcelTAD
Home › Calculus Essentials › Derivatives of Trig Functions

Derivatives of Trig Functions

Sine and cosine describe anything that repeats: waves, rotations, oscillating springs, sound. Their derivatives turn out to be each other (up to a sign), which is why circular motion and vibration are so neat to analyse. All six trig derivatives follow from one limit and the rules you already know.

The two key limits

With angles in radians,

lim⁡h→0sin⁡hh=1lim⁡h→0cos⁡h−1h=0\lim_{h \to 0} \frac{\sin h}{h} = 1 \qquad\qquad \lim_{h \to 0} \frac{\cos h - 1}{h} = 0

Using sin⁡(x+h)=sin⁡xcos⁡h+cos⁡xsin⁡h\sin(x + h) = \sin x \cos h + \cos x \sin h:

sin⁡(x+h)−sin⁡xh=sin⁡x⋅cos⁡h−1h+cos⁡x⋅sin⁡hh→sin⁡x⋅0+cos⁡x⋅1=cos⁡x\begin{aligned} \frac{\sin(x + h) - \sin x}{h} &= \sin x \cdot \frac{\cos h - 1}{h} + \cos x \cdot \frac{\sin h}{h} \\ &\to \sin x \cdot 0 + \cos x \cdot 1 = \cos x \end{aligned}

A similar calculation gives (cos⁡x)′=−sin⁡x(\cos x)' = -\sin x. Everything else comes from the quotient rule.

The table

Function Derivative
sin⁡x\sin x cos⁡x\cos x
cos⁡x\cos x −sin⁡x-\sin x
tan⁡x\tan x sec⁡2x=1/cos⁡2x\sec^2 x = 1/\cos^2 x
cot⁡x\cot x −csc⁡2x-\csc^2 x
sec⁡x\sec x sec⁡x⋅tan⁡x\sec x \cdot \tan x
csc⁡x\csc x −csc⁡x⋅cot⁡x-\csc x \cdot \cot x
arcsin⁡x\arcsin x 11−x2\frac{1}{\sqrt{1 - x^2}}
arctan⁡x\arctan x 11+x2\frac{1}{1 + x^2}

A memory aid: the "co-" functions get a minus sign. Differentiating sin⁡\sin four times brings you back to sin⁡\sin: sin⁡→cos⁡→−sin⁡→−cos⁡→sin⁡\sin \to \cos \to -\sin \to -\cos \to \sin.

Numeric evidence and SymPy

python · try it yourself
import math

print("   x      numeric d/dx sin    cos x")
h = 1e-5
for x in [0, math.pi / 6, math.pi / 2, 2.0, math.pi]:
    numeric = (math.sin(x + h) - math.sin(x - h)) / (2 * h)
    print(f"{x:6.4f}   {numeric:16.10f}   {math.cos(x):13.10f}")
   x      numeric d/dx sin    cos x
0.0000       1.0000000000    1.0000000000
0.5236       0.8660254038    0.8660254038
1.5708       0.0000000000    0.0000000000
2.0000      -0.4161468365   -0.4161468365
3.1416      -1.0000000000   -1.0000000000
python · try it yourself
import sympy as sp

x = sp.symbols('x')
for f in [sp.tan(x), sp.sec(x), sp.atan(x), sp.sin(3 * x) * sp.cos(x), sp.sin(x)**2 + sp.cos(x)**2]:
    print(f"d/dx {str(f):<20} = {sp.simplify(sp.diff(f, x))}")
d/dx tan(x)               = cos(x)**(-2)
d/dx sec(x)               = tan(x)*sec(x)
d/dx atan(x)              = 1/(x**2 + 1)
d/dx sin(3*x)*cos(x)      = cos(2*x) + 2*cos(4*x)
d/dx sin(x)**2 + cos(x)**2 = 0

The last line is a nice sanity check: sin⁡2x+cos⁡2x=1\sin^2 x + \cos^2 x = 1 is constant, so its derivative is 0. SymPy prints the derivative of tan⁡\tan as cos(x)**(-2), which is 1/cos⁡2x=sec⁡2x1/\cos^2 x = \sec^2 x; another equivalent form is 1+tan⁡2x1 + \tan^2 x.

Why radians?

The limit sin⁡hh→1\frac{\sin h}{h} \to 1 holds only when hh is measured in radians. In degrees, sin⁡h∘h→π180\frac{\sin h^\circ}{h} \to \frac{\pi}{180}, so ddxsin⁡(x∘)=π180⋅cos⁡(x∘)\frac{d}{dx} \sin(x^\circ) = \frac{\pi}{180} \cdot \cos(x^\circ). Every calculus formula with trig assumes radians, and so do math.sin, np.sin and the trig functions in every game engine.

python · try it yourself
import math

h = 1e-6
deg_slope = (math.sin(math.radians(30 + h)) - math.sin(math.radians(30 - h))) / (2 * h)
print("slope of sin in degrees at 30°:", round(deg_slope, 8))
print("(π/180)·cos(30°)              :", round(math.pi / 180 * math.cos(math.radians(30)), 8))
slope of sin in degrees at 30°: 0.01511499
(π/180)·cos(30°)              : 0.01511499

Chain rule with trig

The inner derivative becomes a frequency factor:

ddtsin⁡(ωt)=ωcos⁡(ωt)ddtcos⁡(ωt)=−ωsin⁡(ωt)ddtAsin⁡(ωt+φ)=Aωcos⁡(ωt+φ)\begin{aligned} &\frac{d}{dt} \sin(\omega t) = \omega \cos(\omega t) \qquad \frac{d}{dt} \cos(\omega t) = -\omega \sin(\omega t) \\ &\frac{d}{dt} A \sin(\omega t + \varphi) = A\omega \cos(\omega t + \varphi) \end{aligned}

A wave with angular frequency ω\omega has velocity amplitude AωA\omega: doubling the frequency doubles the peak speed.

In software

  • Circular motion: a point orbiting at radius rr with angular speed ω\omega sits at (rcos⁡ωt,rsin⁡ωt)(r \cos \omega t, r \sin \omega t). Its velocity (−rωsin⁡ωt,rωcos⁡ωt)(-r\omega \sin \omega t, r\omega \cos \omega t) is perpendicular to the radius, with speed rωr\omega. See Curvilinear Motion and radians and trig.
  • Oscillation in games and audio: a bobbing pickup y=y0+Asin⁡(ωt)y = y_0 + A \sin(\omega t) has its fastest motion at the middle and stops at the top and bottom, because cos⁡\cos is 0 exactly where sin⁡\sin peaks. Synthesizers and spring systems (springs) rely on (sin⁡)′′=−sin⁡(\sin)'' = -\sin.
  • Positional encodings: transformer models encode token positions with sines and cosines of many frequencies (transformers). Thanks to the angle-addition formulas (the same ones used above to differentiate sin⁡\sin), shifting the position is just a rotation of each (sin⁡,cos⁡)(\sin, \cos) pair.

Exercises

Exercise 1: Product of trig functions

Differentiate f(x)=x2cos⁡xf(x) = x^2 \cos x.

Answer

f′(x)=2xcos⁡x−x2sin⁡xf'(x) = 2x \cos x - x^2 \sin x

Solution
product rule: (x2)′cos⁡x+x2(cos⁡x)′=2xcos⁡x−x2sin⁡x\text{product rule: } (x^2)' \cos x + x^2 (\cos x)' = 2x \cos x - x^2 \sin x

Exercise 2: Derive tan from the quotient rule

Show that ddxtan⁡x=1cos⁡2x\frac{d}{dx} \tan x = \frac{1}{\cos^2 x}.

Answer

cos⁡x⋅cos⁡x−sin⁡x⋅(−sin⁡x)cos⁡2x=1cos⁡2x\dfrac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x} = \dfrac{1}{\cos^2 x}

Solution
tan⁡x=sin⁡xcos⁡x(tan⁡x)′=(sin⁡x)′cos⁡x−sin⁡x(cos⁡x)′cos⁡2x=cos⁡2x+sin⁡2xcos⁡2x=1cos⁡2x(since sin⁡2+cos⁡2=1)\begin{aligned} \tan x &= \frac{\sin x}{\cos x} \\ (\tan x)' &= \frac{(\sin x)' \cos x - \sin x (\cos x)'}{\cos^2 x} \\ &= \frac{\cos^2 x + \sin^2 x}{\cos^2 x} \\ &= \frac{1}{\cos^2 x} && (\text{since } \sin^2 + \cos^2 = 1) \end{aligned}

Exercise 3: Peak speed of a bob

A floating pickup moves as y(t)=2+0.3sin⁡(4t)y(t) = 2 + 0.3 \sin(4t) (metres, seconds). What is its maximum vertical speed, and at what height does it occur?

Answer

1.2 m/s1.2\ \text{m/s}, at the middle height y=2y = 2.

Solution
y′(t)=0.3⋅4cos⁡(4t)=1.2cos⁡(4t),largest ∣y′∣=1.2 when cos⁡(4t)=±1then sin⁡(4t)=0, so y=2\begin{aligned} &y'(t) = 0.3 \cdot 4 \cos(4t) = 1.2 \cos(4t), \quad \text{largest } \lvert y' \rvert = 1.2 \text{ when } \cos(4t) = \pm 1 \\ &\text{then } \sin(4t) = 0, \text{ so } y = 2 \end{aligned}

Exercise 4: Check arctan's derivative

Check numerically that the derivative of arctan⁡x\arctan x at x=2x = 2 is 11+x2=0.2\frac{1}{1 + x^2} = 0.2, and with SymPy.

Answer

Both give 0.2 (SymPy: 1/5).

Solution
python · try it yourself
import math
import sympy as sp

h = 1e-5
print(round((math.atan(2 + h) - math.atan(2 - h)) / (2 * h), 8))
x = sp.symbols('x')
print(sp.diff(sp.atan(x), x).subs(x, 2))
0.2
1/5

Test yourself

What is ddxcos⁡x\frac{d}{dx} \cos x?

  1. sin⁡x\sin x
  2. −cos⁡x-\cos x
  3. sec⁡x\sec x
  4. −sin⁡x-\sin x

What is ddtsin⁡(5t)\frac{d}{dt} \sin(5t)?

  1. cos⁡(5t)\cos(5t)
  2. 5cos⁡(t)5 \cos(t)
  3. 5cos⁡(5t)5 \cos(5t)
  4. −5cos⁡(5t)-5 \cos(5t)

Why must xx be in radians for (sin⁡x)′=cos⁡x(\sin x)' = \cos x?

  1. Degrees are not allowed in Python
  2. Because lim⁡sin⁡hh=1\lim \frac{\sin h}{h} = 1 only holds with hh in radians
  3. Radians are always larger
  4. It works in degrees too