SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 2.3.1 Power, constant and sum rulesConcept · 25 min
      2. 2.3.2 Product and quotient rulesConcept · 25 min
      3. 2.3.3 The chain ruleConcept · 30 min
      4. 2.3.4 Derivatives of exponentials and logarithmsConcept · 30 min
      5. 2.3.5 Derivatives of sine and cosineConcept · 35 min
      6. 2.3.6 Practice set: differentiationPractice set · 25 min
      7. 2.3.7 Case study: modified duration and elasticityCase study · 30 min

Level 2, Single-variable calculus 2.3 Differentiation rules Lesson 5 of 7

ConceptLesson 2.3.5 in Level 2, Single-variable calculus. About 35 minutes.

Derivatives of sine and cosine

Two slopes at 0

Every rule in this lesson grows from two numbers: the slopes of sine and cosine at 0. Both come from chord slopes (lesson 2.2.1), with the gap hh in radians.

Sine at 0. Since sin⁡0=0\sin 0 = 0, the chord slope of sin⁡x\sin x from 0 to hh is sin⁡hh\frac{\sin h}{h}, the limit of lesson 2.1.1.

gap hh±0.1\pm 0.1±0.01\pm 0.01±0.001\pm 0.001
chord slope sin⁡hh\frac{\sin h}{h}0.9983340.9999831.0

Both sides give the same numbers, because sin⁡(−h)=−sin⁡h\sin(-h) = -\sin h (lesson 1.7.1). So the slope at 0 is 1, and near 0 sine hugs the line y=xy = x: sin⁡0.02≈0.019999\sin 0.02 \approx 0.019999.

Cosine at 0. Cosine is at the top of its wave at 0, where cos⁡0=1\cos 0 = 1. So its chord slope is cos⁡h−1h\frac{\cos h - 1}{h}.

gap hh0.10.010.001
from the right, hh−0.049958-0.049958−0.005-0.005−0.0005-0.0005
from the left, −h-h0.0499580.0050.0005

The chords slope down to the right and up to the left, and both shrink to 0. The tangent at the top is flat.

Rule: Two limits at 0

lim⁡h→0sin⁡hh=1lim⁡h→0cos⁡h−1h=0\begin{gathered} \lim_{h \to 0} \frac{\sin h}{h} = 1 \\[4pt] \lim_{h \to 0} \frac{\cos h - 1}{h} = 0 \end{gathered}

With hh in radians, these are the slopes of sine and cosine at 0. This lesson takes them from the tables; the Proof Gym proves them.

In degrees the slope is not 1

Measure the gap in degrees and the chord slope becomes sin⁡(h°)h\frac{\sin(h°)}{h}. One degree is only π180≈0.017453\frac{\pi}{180} \approx 0.017453 radians, so the slope shrinks by that factor.

gap in degrees10.10.01
chord slope per degree0.0174520.0174530.017453

In degrees, every rule below would carry that factor. Radians make the slope at 0 exactly 1, as ee makes the slope of its exponential 1 at 0 (lesson 2.3.4).

Try it

The first loop prints the chord slope of sine at 0, from the right and from the left. The second does the same for cosine, whose two sides have opposite signs.

The last loop measures the gap in degrees, converted by math.radians (lesson 1.7.1).

⌘/Ctrl + Enter runs the cell

The slope of sine is cosine

Read the slope of sin⁡x\sin x off its graph and you trace out cos⁡x\cos x.

  • At 0, sine crosses zero going up, at its steepest: slope 1.
  • At π2\frac{\pi}{2} it is at its top: slope 0.
  • At π\pi it crosses zero going down, at its steepest: slope −1-1.
  • At 3π2\frac{3\pi}{2} it is at its bottom: slope 0. At 2π2\pi the wave starts again.

These slopes, 1, 0, −1-1, 0, are the values of cos⁡x\cos x at the same points. Sine is steepest where it crosses zero, which is where cosine peaks.

Tangents to y=sin⁡xy = \sin x where it crosses zero and at its top and bottom. Plotted at the same xx, their slopes 1, 0, −1-1, 0, 1 sit on y=cos⁡xy = \cos x.

Between those points the match holds too. Central differences (lesson 2.2.2) with h=0.001h = 0.001 give:

xx0π6\frac{\pi}{6}π3\frac{\pi}{3}π2\frac{\pi}{2}π\pi
slope of sin⁡x\sin x1.00.8660250.50.0−1.0-1.0
cos⁡x\cos x10.8660250.50−1-1

Rule: Derivative of sine

ddx sin⁡x=cos⁡x\frac{d}{dx}\,\sin x = \cos x

With xx in radians. Sine rises where cos⁡x>0\cos x > 0, falls where cos⁡x<0\cos x < 0, and is flat where cos⁡x=0\cos x = 0, at its tops and bottoms.

The slope stays between −1-1 and 1, and sine has no corners or jumps (lesson 2.2.2). Negative inputs work the same way: at −π3-\frac{\pi}{3} the slope is cos⁡(−π3)=0.5\cos(-\frac{\pi}{3}) = 0.5.

Slide the point along sin⁡x\sin x and watch the slope graph underneath trace the cosine wave. Jump to π2\frac{\pi}{2}, where the tangent is flat, and to π\pi, where it falls most steeply.

Explore

Slide the point along the curve. Its tangent shows the slope there, and the lower graph plots that slope for every x: the derivative.

0246−101

The slope of y = sin x, which is cos x

0246−101
Point
(0.159π, 0.4794)
Slope there
0.8776
The curve is
rising: the slope is positive, so the slope graph is above zero

Try it

central is the central difference of lesson 2.2.2. Each line prints xx, the estimated slope of sin⁡x\sin x, and cos⁡x\cos x.

Adding 0.0 turns a -0.0 into 0.0, as in lesson 1.7.3.

⌘/Ctrl + Enter runs the cell

The slope of cosine is minus sine

Read the cosine wave the same way: at 0 it is at its top, and flat (the second limit). It falls most steeply as it crosses zero at π2\frac{\pi}{2}, with slope −1-1. It is flat again at its bottom, π\pi, and climbs most steeply at 3π2\frac{3\pi}{2}, with slope 1.

These slopes, 0, −1-1, 0, 1, are the values of −sin⁡x-\sin x. Central differences agree: at π6\frac{\pi}{6} they give −0.5-0.5, which is −sin⁡π6-\sin\frac{\pi}{6}.

Rule: Derivative of cosine

ddx cos⁡x=−sin⁡x\frac{d}{dx}\,\cos x = -\sin x

With xx in radians. The minus sign matters: cosine falls while sine is positive, from 0 to π\pi, and rises while sine is negative.

One picture for both rules

Lesson 1.7.1 put the point (cos⁡x,sin⁡x)(\cos x, \sin x) on the unit circle, an arc xx round from (1,0)(1, 0). In radians the arc grows as fast as the angle, so the point moves at speed 1.

It moves at right angles to the radius (lesson 1.7.3): in the direction of the radius turned a quarter turn. That turn takes (a,b)(a, b) to (−b,a)(-b, a) (lesson 1.7.2), giving (−sin⁡x,cos⁡x)(-\sin x, \cos x).

Per unit of angle the point moves 1 along the circle. Its height changes by cos⁡x\cos x: up at π6\frac{\pi}{6}, down at 2π3\frac{2\pi}{3}.

So the height sin⁡x\sin x changes at the rate cos⁡x\cos x, and the across coordinate cos⁡x\cos x at the rate −sin⁡x-\sin x. In degrees the point moves only π180\frac{\pi}{180} of a unit per degree.

Try it

The loop prints xx, the central difference of cos⁡x\cos x, and −sin⁡x-\sin x.

The last loop moves the point round the circle from π6\frac{\pi}{6} by an arc hh. Its rise and its change across, per unit of hh, head for cos⁡π6≈0.866025\cos\frac{\pi}{6} \approx 0.866025 and −0.5-0.5.

⌘/Ctrl + Enter runs the cell

Differentiating again: a cycle of four

Each rule turns sine into cosine, or cosine into minus sine. So repeated differentiation goes round a cycle of four.

times differentiated01234
sin⁡x\sin x becomessin⁡x\sin xcos⁡x\cos x−sin⁡x-\sin x−cos⁡x-\cos xsin⁡x\sin x

The fifth derivative is the first again, cos⁡x\cos x. Starting from cos⁡x\cos x, the same cycle begins one step along. Compare exe^x (lesson 2.3.4), which comes back after one step.

The second derivative pulls the wave back

Differentiating twice gives the second derivative f′′(x)f''(x), the slope of the slope; lesson 2.4.2 studies it. For f(x)=sin⁡xf(x) = \sin x it is −sin⁡x-\sin x: the function itself, with its sign flipped.

So above the axis the slope is falling and the wave bends back down; below the axis it bends back up. The bend always pulls the wave towards 0, so it overshoots and swings for ever.

Module 6.2 solves differential equations such as f′′=−ff'' = -f, whose solutions are waves like these.

Try it

SymPy differentiates sin⁡x\sin x eight times, round the cycle twice. sp.diff(f, x, 2) differentiates twice.

The last line checks a rule from the end of this lesson: −cos⁡x-\cos x has slope sin⁡x\sin x.

⌘/Ctrl + Enter runs the cell

Tangent, by the quotient rule

tan⁡x=sin⁡xcos⁡x\tan x = \frac{\sin x}{\cos x} (lesson 1.7.1), so the quotient rule of lesson 2.3.2, f′g−fg′g2\frac{f'g - fg'}{g^2}, applies with f=sin⁡xf = \sin x and g=cos⁡xg = \cos x:

cos⁡x⋅cos⁡x−sin⁡x⋅(−sin⁡x)cos⁡2x=cos⁡2x+sin⁡2xcos⁡2x=1cos⁡2x\begin{gathered} \frac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x} \\[4pt] = \frac{\cos^2 x + \sin^2 x}{\cos^2 x} = \frac{1}{\cos^2 x} \end{gathered}

The last step is the identity cos⁡2x+sin⁡2x=1\cos^2 x + \sin^2 x = 1 (lesson 1.7.1). Dividing it by cos⁡2x\cos^2 x gives a second form, 1+tan⁡2x1 + \tan^2 x.

Rule: Derivative of tangent

ddx tan⁡x=1cos⁡2x=1+tan⁡2xwhere cos⁡x≠0\begin{gathered} \frac{d}{dx}\,\tan x = \frac{1}{\cos^2 x} \\[4pt] = 1 + \tan^2 x \\[4pt] \text{where } \cos x \neq 0 \end{gathered}

The slope is never below 1, so every branch of tangent rises. Where tangent has no value, at π2\frac{\pi}{2} and every half turn from it, it has no slope.

At π4\frac{\pi}{4}, cos⁡2x=12\cos^2 x = \frac{1}{2}, so the slope is 2. Central differences agree:

gap hh0.10.010.001
central difference at π4\frac{\pi}{4}2.02712.0002672.000003

The slope is 1 at 0 and 4 at π3\frac{\pi}{3}. Near π2\frac{\pi}{2} it blows up: 199.85 at 1.5 and about 1.58 million at 1.57, where tangent itself shoots off (lesson 1.7.1).

Try it

The loop prints central differences of tan⁡x\tan x at π4\frac{\pi}{4}, then 1cos⁡2x\frac{1}{\cos^2 x} at 0, π4\frac{\pi}{4}, π3\frac{\pi}{3}, 1.5 and 1.57.

SymPy gives the slope as 1+tan⁡2x1 + \tan^2 x. Simplified, the quotient-rule form is cos(x)**(-2), the same function.

⌘/Ctrl + Enter runs the cell

With the chain rule: rates and periods

With sine or cosine outside, the chain rule of lesson 2.3.3 keeps the inside u=g(x)u = g(x) as it is and multiplies by its slope.

Rule: Sine and cosine of a function

ddx sin⁡u=cos⁡u⋅dudxddx cos⁡u=−sin⁡u⋅dudx\begin{gathered} \frac{d}{dx}\,\sin u = \cos u \cdot \frac{du}{dx} \\[4pt] \frac{d}{dx}\,\cos u = -\sin u \cdot \frac{du}{dx} \end{gathered}

Here u=g(x)u = g(x) is the inside. The outer slope is taken at uu, then multiplied by the slope of the inside.

A linear inside. sin⁡(3x)\sin(3x) has inside 3x3x, with slope 3, so its derivative is 3cos⁡(3x)3\cos(3x): 3 at x=0x = 0. Central differences agree:

gap hh0.10.010.001
central difference at 02.9552022.999552.999996

sin⁡(3x)\sin(3x) runs through its wave three times as fast, with period 2π3≈2.094395\frac{2\pi}{3} \approx 2.094395. Squeezed sideways by 3, the wave is 3 times as steep.

Frequency and phase

A wave in time is written y=cos⁡(ωt+φ)y = \cos(\omega t + \varphi), with tt in seconds. The angular frequency ω\omega (omega) is in radians per second; the phase φ\varphi (phi) shifts the wave along. The inside has slope ω\omega, so

dydt=−ωsin⁡(ωt+φ)\frac{dy}{dt} = -\omega \sin(\omega t + \varphi)

The period is 2πω\frac{2\pi}{\omega} seconds, and the slope swings between −ω-\omega and ω\omega, in units of yy per second. A frequency ω\omega makes slopes ω\omega times larger; the phase only moves the wave.

For y=cos⁡(2t+π6)y = \cos(2t + \frac{\pi}{6}), the slope at t=0t = 0 is −2sin⁡π6=−1-2\sin\frac{\pi}{6} = -1, and the period is π\pi. One cycle per second is ω=2π\omega = 2\pi, with slopes up to 2π≈6.2831852\pi \approx 6.283185 per second.

Curved insides, powers and degrees

A curved inside. sin⁡(x2)\sin(x^2) has inside x2x^2, with slope 2x2x, so its derivative is 2xcos⁡(x2)2x\cos(x^2). At x=1x = 1 that is 2cos⁡1≈1.0806052\cos 1 \approx 1.080605. Central differences give 1.056644, 1.080364 and 1.080602 for gaps 0.1, 0.01 and 0.001.

A power of sine. sin⁡2x\sin^2 x means (sin⁡x)2(\sin x)^2: the outer function is u2u^2 and the inside is sin⁡x\sin x. Its slope is 2sin⁡xcos⁡x2\sin x\cos x, which is 1 at π4\frac{\pi}{4}.

Degrees. Sine in degrees is sin⁡(πx180)\sin\left(\frac{\pi x}{180}\right). Its slope, π180cos⁡(πx180)\frac{\pi}{180}\cos\left(\frac{\pi x}{180}\right), carries the factor π180\frac{\pi}{180} at every point.

Try it

The loop prints central differences of sin⁡(3x)\sin(3x) at 0 and of sin⁡(x2)\sin(x^2) at 1. SymPy then differentiates each example of this section.

SymPy writes π180cos⁡(πx180)\frac{\pi}{180}\cos\left(\frac{\pi x}{180}\right) as pi*cos(pi*x/180)/180.

⌘/Ctrl + Enter runs the cell

Reading the rules backwards

The rules also answer the reverse question: which function has a given slope? sin⁡x\sin x has slope cos⁡x\cos x. Since cos⁡x\cos x has slope −sin⁡x-\sin x, the function with slope sin⁡x\sin x is −cos⁡x-\cos x, not cos⁡x\cos x.

Lesson 2.5.2 calls such a function an antiderivative, and lists both rules backwards. Lesson 2.6.2 uses both rules to integrate exsin⁡xe^x \sin x.

Common mistakes

  1. Use radians. In degrees every slope has an extra factor π180\frac{\pi}{180}. The slope of sine at 0 is then 0.017453 per degree.
  2. The minus sign belongs to cosine. ddxcos⁡x=−sin⁡x\frac{d}{dx}\cos x = -\sin x, but ddxsin⁡x=cos⁡x\frac{d}{dx}\sin x = \cos x.
  3. Keep the chain factor, and leave the inside alone. sin⁡(3x)\sin(3x) gives 3cos⁡(3x)3\cos(3x), not cos⁡(3x)\cos(3x) or 3cos⁡x3\cos x. cos⁡(ωt+φ)\cos(\omega t + \varphi) gives −ωsin⁡(ωt+φ)-\omega\sin(\omega t + \varphi).
  4. sin⁡2x\sin^2 x is not sin⁡(x2)\sin(x^2). Their slopes are 2sin⁡xcos⁡x2\sin x\cos x and 2xcos⁡(x2)2x\cos(x^2).
  5. Tangent has no slope at its gaps. At π2\frac{\pi}{2} there is no tan⁡x\tan x and no slope. Close by, the slope is huge.
  6. Backwards, mind the sign. The function with slope sin⁡x\sin x is −cos⁡x-\cos x.

Derivatives of sine and cosine

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • In radians, sin⁡hh→1\frac{\sin h}{h} \to 1 and cos⁡h−1h→0\frac{\cos h - 1}{h} \to 0: the slopes of sine and cosine at 0. In degrees the slope of sine at 0 is π180\frac{\pi}{180}.
  • ddxsin⁡x=cos⁡x\frac{d}{dx}\sin x = \cos x and ddxcos⁡x=−sin⁡x\frac{d}{dx}\cos x = -\sin x. Sine is steepest where it crosses zero and flat at its tops and bottoms.
  • Derivatives cycle every four steps: sin⁡x\sin x, cos⁡x\cos x, −sin⁡x-\sin x, −cos⁡x-\cos x. The second derivative of sin⁡x\sin x is −sin⁡x-\sin x.
  • ddxtan⁡x=1cos⁡2x=1+tan⁡2x\frac{d}{dx}\tan x = \frac{1}{\cos^2 x} = 1 + \tan^2 x, where cos⁡x≠0\cos x \neq 0.
  • Chain rule: ddxsin⁡(g(x))=g′(x)cos⁡(g(x))\frac{d}{dx}\sin(g(x)) = g'(x)\cos(g(x)). cos⁡(ωt+φ)\cos(\omega t + \varphi) has slope −ωsin⁡(ωt+φ)-\omega\sin(\omega t + \varphi), period 2πω\frac{2\pi}{\omega} and slopes up to ω\omega.
  • The function with slope sin⁡x\sin x is −cos⁡x-\cos x.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.

  • Derivatives

    Paul's Online Notes. Notes.

    The definition of the derivative and every differentiation rule, one page per rule.

  • 18.01SC Single Variable Calculus

    MIT OpenCourseWare. Course.

    Full lectures, recitation videos and problem sets with solutions.