← Root & Branch

Derivative of sin x from First Principles: Why It's cos x

Starting from only the definition of a derivative and the sin(a + b) formula, see step by step why the derivative of sin x is cos x, with an interactive graph and a proof of the two key limits.


Every calculus student learns that the derivative of sin x is cos x, and most of us just memorise it. In this post we'll build it ourselves, starting from only the definition of a derivative and one formula from school trigonometry, and see exactly where the cos x comes from. No derivative rules allowed.

Before any algebra, look at the shape. A derivative tells you how steep a curve is at each point. The sine curve climbs most steeply at x=0x=0 (slope 11), is flat at its peak (slope 00), and falls most steeply at x=πx=\pi (slope −1-1). Write those slopes down, plot them underneath, and you get another wave that starts at 11. That wave is cos⁡x\cos x. The rest of this post proves it isn't a coincidence.

The sine curve with tangent lines of slope 1, 0, -1, 0 and 1. Plotting those slopes underneath traces out the cosine curve.10-101sin xcos xπ/2π3π/22π0the slopes of sindraw cos!Red: the slope of sin x at that point. Plot each slope underneath and you get cos x.

Step 0: what a derivative is

Pick a point xx on a curve, and a second point a small step hh further along, at x+hx+h. The straight line through the two points is called a secant. Its slope is rise over run:

slope of the secant=f(x+h)−f(x)h\text{slope of the secant}=\frac{f(x+h)-f(x)}{h}

Now make hh smaller and smaller. The second point slides towards the first, and the secant turns into the tangent: the line that just touches the curve at xx. The slope of that tangent is the derivative. The notation lim⁡h→0\lim_{h\to0} means “the value this settles on as hh gets closer and closer to 00”, without hh ever being exactly 00:

f′(x)=lim⁡h→0f(x+h)−f(x)hf'(x)=\lim_{h\to0}\frac{f(x+h)-f(x)}{h}

That's what “first principles” means: we use only this definition. Try it below. Press Shrink h and watch the red secant turn into a tangent. The red dot underneath sits at the height of the secant's slope, and as hh shrinks it lands on the dashed cos curve. Then press Slide x across to watch the slopes trace out the whole curve.

Shrink the gap h and watch the slope become cos x
π2π0y = sin xy = cos xh
Slope of the red line
-0.1620
cos x
0.5403
Difference
-0.7023

Step 1: put sin into the definition

Replace ff with sin⁡\sin:

ddxsin⁡x=lim⁡h→0sin⁡(x+h)−sin⁡xh\frac{d}{dx}\sin x=\lim_{h\to0}\frac{\sin(x+h)-\sin x}{h}

We can't simply plug in h=0h=0. The top becomes sin⁡x−sin⁡x=0\sin x-\sin x=0, the bottom becomes 00, and 0/00/0 has no value. We have to rewrite the expression until the limit is something we can evaluate. The obstacle is sin⁡(x+h)\sin(x+h): the xx and the hh are stuck together inside one sine.

Step 2: break sin(x + h) apart

This is where the angle addition formula comes in. For any two angles aa and bb:

sin⁡(a+b)=sin⁡acos⁡b+cos⁡asin⁡b\sin(a+b)=\sin a\cos b+\cos a\sin b

With a=xa=x and b=hb=h, it pulls the two apart: sin⁡(x+h)=sin⁡xcos⁡h+cos⁡xsin⁡h\sin(x+h)=\sin x\cos h+\cos x\sin h. Every term is now something that depends only on xx times something that depends only on hh. That separation is the whole trick. Substitute it in:

lim⁡h→0sin⁡xcos⁡h+cos⁡xsin⁡h−sin⁡xh\lim_{h\to0}\frac{\sin x\cos h+\cos x\sin h-\sin x}{h}

Step 3: regroup

Put the two sin⁡x\sin x terms next to each other, factor out sin⁡x\sin x, then divide each piece by hh:

lim⁡h→0[sin⁡x⋅cos⁡h−1h+cos⁡x⋅sin⁡hh]\lim_{h\to0}\left[\sin x\cdot\frac{\cos h-1}{h}+\cos x\cdot\frac{\sin h}{h}\right]

Look at what happened. sin⁡x\sin x and cos⁡x\cos x don't change when hh changes, so here they are just fixed multipliers. All the hh has gathered into two small fractions, (cos⁡h−1)/h(\cos h-1)/h and (sin⁡h)/h(\sin h)/h, with no xx in them at all. Once we know what those two fractions approach, we're done. Step through the whole derivation below, one move at a time. Red marks what changed in each step.

Derivative of sin x, step by step
  1. 1
    f′(x)=lim⁡h→0f(x+h)−f(x)hf'(x)=\lim_{h\to0}\frac{f(x+h)-f(x)}{h}
Step 1 of 9: Start from the definition. The slope between the points at xx and x+hx+h, as the gap hh shrinks towards zero.

Step 4: why sin h / h goes to 1

Try small values and a pattern shows up: h=0.5h=0.5 gives 0.95890.9589, h=0.1h=0.1 gives 0.99830.9983, and h=0.01h=0.01 gives 0.999980.99998. But a few numbers are not a proof. The proof is a picture on a circle of radius 11.

Draw an angle hh at the centre OO, measured in radians. It marks a point PP on the circle, at height sin⁡h\sin h. Extend the line from OO through PP until it meets the upright line through A=(1,0)A=(1,0). Call that point TT; its height is tan⁡h\tan h. Now compare three shapes that all have a corner at OO:

Unit circle with angle h. The small triangle OAP fits inside the circle slice, which fits inside the big triangle OAT, so sin h is at most h, which is at most tan h.OAPTh1sin htan hsmall triangle: 1/2 sin hcircle slice: 1/2 hbig triangle: 1/2 tan hareas, smallest firstsin h ≤ h ≤ tan hThe slice sits between the two triangles, so its area is squeezed between theirs

The small triangle OAPOAP has base 11 and height sin⁡h\sin h, so its area is 12sin⁡h\tfrac12\sin h. The slice of the circle between OAOA and OPOP has area 12h\tfrac12h. That's what measuring in radians buys you: the whole circle is 2π2\pi radians and has area π\pi, so each radian of slice is worth 12\tfrac12. The big triangle OATOAT has base 11 and height tan⁡h\tan h, so its area is 12tan⁡h\tfrac12\tan h. Each shape fits inside the next one, so after doubling:

sin⁡h≤h≤tan⁡h\sin h\le h\le\tan h

Divide everything by sin⁡h\sin h (which is positive for small positive hh), then flip each fraction over. Flipping reverses the inequalities:

cos⁡h≤sin⁡hh≤1\cos h\le\frac{\sin h}{h}\le1

As h→0h\to0, cos⁡h→1\cos h\to1. So (sin⁡h)/h(\sin h)/h is trapped between two walls, cos⁡h\cos h and 11, that both close in on 11. It has nowhere else to go. This argument is called the squeeze theorem. Negative hh gives the same answer, because sin⁡(−h)/(−h)=(sin⁡h)/h\sin(-h)/(-h)=(\sin h)/h.

This is also why calculus uses radians. In degrees, the slice would have area (π/360) h(\pi/360)\,h instead of 12h\tfrac12h, the limit would come out as π/180≈0.01745\pi/180\approx0.01745 instead of 11, and the derivative of sin⁡x\sin x would be (π/180)cos⁡x(\pi/180)\cos x. Radians are the unit that makes this constant exactly 11.

Step 5: why (cos h − 1) / h goes to 0

This one reuses the limit we just proved. Multiply the top and bottom by cos⁡h+1\cos h+1, and use cos⁡2h−1=−sin⁡2h\cos^2h-1=-\sin^2h (from sin⁡2h+cos⁡2h=1\sin^2h+\cos^2h=1):

cos⁡h−1h=cos⁡2h−1h (cos⁡h+1)=−sin⁡hh⋅sin⁡hcos⁡h+1\frac{\cos h-1}{h}=\frac{\cos^2h-1}{h\,(\cos h+1)}=-\frac{\sin h}{h}\cdot\frac{\sin h}{\cos h+1}

As h→0h\to0, the first fraction goes to 11 (Step 4), and the second goes to 0/(1+1)=00/(1+1)=0. So the whole thing goes to −1⋅0=0-1\cdot0=0. The numbers agree: h=0.1h=0.1 gives −0.04996-0.04996 and h=0.01h=0.01 gives −0.0050-0.0050. In plain words, near h=0h=0 the cosine curve is flat at its peak, so cos⁡h−1\cos h-1 shrinks much faster than hh does.

Step 6: put it together

ddxsin⁡x=sin⁡x⋅lim⁡h→0cos⁡h−1h⏟0+cos⁡x⋅lim⁡h→0sin⁡hh⏟1=cos⁡x\begin{aligned}\frac{d}{dx}\sin x&=\sin x\cdot\underbrace{\lim_{h\to0}\frac{\cos h-1}{h}}_{0}\\&\quad+\cos x\cdot\underbrace{\lim_{h\to0}\frac{\sin h}{h}}_{1}\\&=\cos x\end{aligned}

The sin⁡x\sin x term is multiplied by zero and disappears. The cos⁡x\cos x term is multiplied by one and survives. That's where cos⁡x\cos x comes from: it was sitting in the angle addition formula all along, as the partner of sin⁡h\sin h.

A quick check with a calculator. Take x=π/3x=\pi/3, where cos⁡x=0.5\cos x=0.5. The secant slope (sin⁡(x+h)−sin⁡x)/h(\sin(x+h)-\sin x)/h is 0.26740.2674 for h=0.5h=0.5, 0.45590.4559 for h=0.1h=0.1, 0.49570.4957 for h=0.01h=0.01 and 0.49960.4996 for h=0.001h=0.001. It closes in on 0.50.5, as promised.

Try it yourself: the derivative of cos x

The same method works for cosine. You need cos⁡(a+b)=cos⁡acos⁡b−sin⁡asin⁡b\cos(a+b)=\cos a\cos b-\sin a\sin b. Expand cos⁡(x+h)\cos(x+h), group the cos⁡x\cos x terms, split the fraction, and use the same two limits:

ddxcos⁡x=lim⁡h→0[cos⁡x⋅cos⁡h−1h−sin⁡x⋅sin⁡hh]=cos⁡x⋅0−sin⁡x⋅1=−sin⁡x\begin{aligned}\frac{d}{dx}\cos x&=\lim_{h\to0}\Big[\cos x\cdot\frac{\cos h-1}{h}\\&\qquad-\sin x\cdot\frac{\sin h}{h}\Big]\\&=\cos x\cdot0-\sin x\cdot1=-\sin x\end{aligned}

The minus sign comes straight from the minus in the cosine formula. Work through it on paper once and it will stick.

The method in three moves

Write the definition. Use an identity to separate xx from hh. Reduce what's left to limits that don't depend on xx. That's first principles, and every derivative rule you have memorised was proved this way at some point.