You are on page 1of 82

Level-up!

Calculus
Morris Alper

Morris Alper – ITC Level-up December 2020 cohort


Agenda

● Motivation
● Limits
● Continuity
● Derivatives
● Integrals (Antiderivatives)
● Bonus: Taylor Series
● Bonus: Partial Derivatives
● Further Reading
Motivation
Motivation

Example: Joe decides to leave home, so he enters his car and begins driving.
Motivation

Example: Joe decides to leave home, so he enters his car and begins driving.
Motivation

Example: Joe decides to leave home, so he enters his car and begins driving.

At time 𝑡, Joe’s speed is 𝑓 𝑡 = 𝑡.


Q: What is his distance from home 𝑔(𝑡) at time 𝒕?
Motivation

A: We can calculate position from speed or vice versa using


calculus. 𝑡
1 2
𝑔 𝑡 = න 𝑓 𝑥 𝑑𝑥 = 𝑡
𝑓 𝑡 = 𝑔′(𝑡) = 𝑡 0 2
Motivation

Calculus is the branch of mathematics that studies continuous change, and


helps us answer questions like:

● How can we calculate an object’s velocity given its position over time?
(derivative)

● How can we calculate an object’s position given its velocity over time?
(integral / antiderivative)

This is useful for almost any problem which deals with changing quantities,
which is common in data science.
Limits
Limits

Example 1: Consider the function


5𝑥 + 1
𝑓 𝑥 =
𝑥−1

𝑓 5 = 6.5
𝑓 10 = 5.66 …
𝑓 25 = 5.25

Q: What happens as x gets larger and larger?


Limits
Limits

lim 𝑓 𝑥 = 5
𝑥→∞
Limits

Example 2: Consider the function


sin 𝑥
𝑓 𝑥 =
𝑥

𝑓 1 = 0.841 …
𝑓 0.5 = 0.958 …
𝑓 0.1 = 0.998 …

Q: What happens as x gets closer and closer to 0?


Limits

lim 𝑓 𝑥 = 1
𝑥→0
Limits

Formal definition: (“epsilon-delta” definition of the limit)

lim 𝑓 𝑥 = 𝐿 (“the limit of f as x goes to a is L”) if for every 𝜖


𝑥→𝑐
> 0, there exists a 𝛿 > 0 such that whenever x − c < 𝛿, then
f(x) − 𝐿 < 𝜖.

Informally:

𝑓 𝑥 will be arbitrarily (𝜖) close to 𝐿, as long as we choose 𝑥


that is close enough (𝛿) to 𝑐.
Limits

Illustration of
lim 𝑓 𝑥 = 𝐿
𝑥→𝑐

𝑓 𝑥 will be arbitrarily (𝜖) close to


𝐿, as long as we choose 𝑥 that is
close enough (𝛿) to 𝑐.
Limits

Examples:

lim 𝑥 2 + 5 = ?
𝑥→2
Limits

Examples:

lim 𝑥 2 + 5 = 22 + 5 = 9
𝑥→2
Limits

Examples:

lim 𝑥 2 + 5 = 22 + 5 = 9
𝑥→2

𝑥 2 +𝑥
lim =?
𝑥→0 𝑥
Limits

Examples:

lim 𝑥 2 + 5 = 22 + 5 = 9
𝑥→2

𝑥 2 +𝑥
lim = lim (𝑥 + 1) = 1
𝑥→0 𝑥 𝑥→0
Limits

Examples:

lim 𝑥 2 + 5 = 22 + 5 = 9
𝑥→2

𝑥 2 +𝑥
lim = lim (𝑥 + 1) = 1
𝑥→0 𝑥 𝑥→0

1
lim =?
𝑥→0 𝑥
Limits

Examples:

lim 𝑥 2 + 5 = 22 + 5 = 9
𝑥→2

𝑥 2 +𝑥
lim = lim (𝑥 + 1) = 1
𝑥→0 𝑥 𝑥→0

1
lim = (undefined)
𝑥→0 𝑥

goes to ±∞ at 𝑥 = 0
Limits

A similar definition lets us define lim 𝑓 𝑥 and lim 𝑓 𝑥


𝑥→∞ 𝑥→−∞
(see this link for a formal definition)
1
lim =?
𝑥→∞ 𝑥
Limits

A similar definition lets us define lim 𝑓 𝑥 and lim 𝑓 𝑥


𝑥→∞ 𝑥→−∞
(see this link for a formal definition)
1
lim =0
𝑥→∞ 𝑥
Limits

A similar definition lets us define lim 𝑓 𝑥 and lim 𝑓 𝑥


𝑥→∞ 𝑥→−∞
(see this link for a formal definition)
1
lim =0
𝑥→∞ 𝑥

2𝑒 𝑥
lim =?
𝑥→∞ 𝑒 𝑥 +1
Limits

A similar definition lets us define lim 𝑓 𝑥 and lim 𝑓 𝑥


𝑥→∞ 𝑥→−∞
(see this link for a formal definition)
1
lim =0
𝑥→∞ 𝑥

2𝑒 𝑥 2
lim = lim =2
𝑥→∞ 𝑒 𝑥 +1 𝑥→∞ 1+𝑒 −𝑥
Limits

Properties: In general, if lim 𝑓(𝑥) and lim 𝑔 𝑥 both exist, then


𝑥→𝑐 𝑥→𝑐

lim𝑥→𝑐 𝑓 𝑥 + 𝑔 𝑥 = lim 𝑓(𝑥) + lim 𝑔 𝑥


𝑥→𝑐 𝑥→𝑐
lim𝑥→𝑐 𝑓 𝑥 𝑔(𝑥) = lim 𝑓(𝑥) lim 𝑔 𝑥
𝑥→𝑐 𝑥→𝑐
Limits

𝑓(𝑥) 0 ±∞
L'Hôpital's rule: If approaches or as 𝑥 approaches 𝑐,
𝑔(𝑥) 0 ±∞

𝑓(𝑥) 𝑓′(𝑥)
then lim = lim (using the derivative, which we will define soon)
𝑥→𝑐 𝑔(𝑥) 𝑥→𝑐 𝑔′(𝑥)

Examples:
3𝑥 2 + 4 (3𝑥 2 + 4)′ 6𝑥
lim = lim = lim = lim 3 = 3
𝑥→∞ 𝑥 2 − 1 𝑥→∞ (𝑥 2 −1)′ 𝑥→∞ 2𝑥 𝑥→∞
Limits

𝑓(𝑥) 0 ±∞
L'Hôpital's rule: If approaches or as 𝑥 approaches 𝑐,
𝑔(𝑥) 0 ±∞

𝑓(𝑥) 𝑓′(𝑥)
then lim = lim (using the derivative, which we will define soon)
𝑥→𝑐 𝑔(𝑥) 𝑥→𝑐 𝑔′(𝑥)

Examples:
3𝑥 2 + 4 (3𝑥 2 + 4)′ 6𝑥
lim = lim = lim = lim 3 = 3
𝑥→∞ 𝑥 2 − 1 𝑥→∞ (𝑥 2 −1)′ 𝑥→∞ 2𝑥 𝑥→∞

sin(𝑥) (sin 𝑥 )′ cos(𝑥)


lim = lim = lim = cos 0 = 1
𝑥→0 𝑥 𝑥→0 (𝑥)′ 𝑥→0 1
Continuity
Continuity

Idea: A continuous function is one whose graph can be drawn


continuously, without raising the pen (no holes or jumps)
Continuity

Definition: A function 𝑓 is continuous at 𝒄 if


lim 𝑓(𝑥) = 𝑓(𝑐)
𝑥→𝑐

We say that 𝑓 is a continuous function if it is continuous


everywhere.
Continuity

Examples:

Many basic functions are continuous everywhere: polynomials,


𝑒 𝑥 , sin(𝑥), cos 𝑥 , |𝑥| (absolute value)
1
is continuous everywhere except at 𝑥 = 0 (where it is
𝑥
undefined)

ln 𝑥 is continuous for 𝑥 > 0 (where it is defined)


Continuity

Intermediate value theorem:

If a function 𝑓 is continuous on
[𝑎, 𝑏], then it takes every value
between 𝑓(𝑎) and 𝑓(𝑏)
somewhere on [𝑎, 𝑏],.
Continuity

Intermediate value theorem – example:

𝑓 𝑥 = 𝑥 cos(𝑥)

Since 𝑓 0 = 0, 𝑓 2𝜋 = 2𝜋, and 𝑓 is continuous on [0, 2𝜋],


there is some 0 < 𝑡 < 2𝜋 such that 𝑓 𝑡 = 5 < 2𝜋.
Derivatives
Derivatives

The derivative gives us a way to 1 2


measure the rate of change of a 𝑔 𝑡 = 𝑡
2
function’s value at a point.

Consider our example of a car


driving away from home, at
distance 𝑔 𝑡 at time 𝑡…
Derivatives

The rate of change between two 1 2


points in time is the slope of the 𝑔 𝑡 = 𝑡
2
secant line on the graph of 𝑔
between these times.

For example, between times 𝑡 = 1


slope: 2.5
and 𝑡 = 4 the rate of change is:
𝑔 4 − 𝑔(1) 8 − 1/2
= = 2.5
4−1 4−1
Derivatives

As the ends of the line approach 1 2


each other, it becomes a tangent 𝑔 𝑡 = 𝑡
2
line, and its slope is the
instantaneous rate of change of
the function, the derivative.
slope: 2.5
Derivatives

As the ends of the line approach 1 2


each other, it becomes a tangent 𝑔 𝑡 = 𝑡
2
line, and its slope is the
instantaneous rate of change of
the function, the derivative.
slope: 2
Derivatives

As the ends of the line approach 1 2


each other, it becomes a tangent 𝑔 𝑡 = 𝑡
2
line, and its slope is the
instantaneous rate of change of
the function, the derivative.
slope: 1.5
Derivatives

As the ends of the line approach 1 2


each other, it becomes a tangent 𝑔 𝑡 = 𝑡
2
line, and its slope is the
instantaneous rate of change of
the function, the derivative.
slope: 1 = derivative!
Derivatives

The derivative of a function 𝑓 is defined as


𝑓 𝑥 + ℎ − 𝑓(𝑥)
𝑓′ 𝑥 = lim
ℎ→0 ℎ
𝑑𝑓
The derivative can be either written as 𝑓 ′ or as (Leibniz
𝑑𝑥
notation). It represents the instantaneous rate of change of the
function.
Derivatives

1
Example: 𝑔 𝑡 = 𝑡 2
2
1 2 1 2
𝑔 𝑡 + ℎ − 𝑔(𝑡) 𝑡 + ℎ − 𝑡
𝑔′ 𝑡 = lim = lim 2 2
ℎ→0 ℎ ℎ→0 ℎ
1
𝑡ℎ+2ℎ2 1
= lim = lim (𝑡 + ℎ) =𝑡
ℎ→0 ℎ ℎ→0 2
Derivatives

Common derivatives:

1 ′ 1 1
𝑥𝑛 ′ = 𝑛𝑥 𝑛−1 = − 2 𝑥 ′ =
𝑥 𝑥 2 𝑥

1
𝑒𝑥 ′
= 𝑒𝑥 𝑏𝑥 ′
= ln 𝑏 𝑏 𝑥 ln 𝑥 ′
=
𝑥
′ ′
sin 𝑥 = cos 𝑥 cos 𝑥 = − sin 𝑥

For more common derivatives, see: Calculus Cheat Sheet


Derivatives

Product rule:

𝑓 𝑥 𝑔 𝑥 = 𝑓 ′ 𝑥 𝑔 𝑥 + 𝑓 𝑥 𝑔′(𝑥)
Derivatives

Product rule:

𝑓 𝑥 𝑔 𝑥 = 𝑓 ′ 𝑥 𝑔 𝑥 + 𝑓 𝑥 𝑔′ 𝑥

Examples:
𝑥 2 sin 𝑥 ′ = 𝑥 2 ′ sin 𝑥 + 𝑥 2 sin 𝑥 ′

= 2𝑥 sin 𝑥 + 𝑥 2 cos(𝑥)
Derivatives

Product rule:

𝑓 𝑥 𝑔 𝑥 = 𝑓 ′ 𝑥 𝑔 𝑥 + 𝑓 𝑥 𝑔′ 𝑥

Examples:
𝑥 2 sin 𝑥 ′ = 𝑥 2 ′ sin 𝑥 + 𝑥 2 sin 𝑥 ′

= 2𝑥 sin 𝑥 + 𝑥 2 cos 𝑥
′ ln 𝑥 ′
1
𝑥 ln 𝑥 = 𝑥 + 𝑥 ln 𝑥 = ln 𝑥 + 𝑥 = ln 𝑥 + 1
𝑥
Derivatives

Chain rule:
𝑓(𝑔 𝑥 ) ′ = 𝑔′ 𝑥 𝑓 ′ 𝑔 𝑥 = 𝑔′ 𝑥 𝑓 ′ (𝑔 𝑥 )
Derivatives

Chain rule:
𝑓(𝑔 𝑥 ) ′ = 𝑔′ 𝑥 𝑓 ′ 𝑔 𝑥

Examples:
sin(𝑒 𝑥 ) ′ = 𝑒 𝑥 ′ cos 𝑒 𝑥 = 𝑒 𝑥 cos 𝑒 𝑥
Derivatives

Chain rule:
𝑓(𝑔 𝑥 ) ′ = 𝑔′ 𝑥 𝑓 ′ 𝑔 𝑥

Examples:
sin(𝑒 𝑥 ) ′ = 𝑒 𝑥 ′ cos 𝑒 𝑥 = 𝑒 𝑥 cos 𝑒 𝑥
2 ′ ′
2 ln 𝑥
ln 𝑥 = ln 𝑥 (2 ln 𝑥) =
𝑥
Derivatives

We can take the derivative of a derivative; this is called the


second derivative.

It represents the rate of change of the rate of change (e.g.


acceleration, which is the instantaneous change in speed).

Notation:

𝒅𝟐 𝒇
𝒇′′(𝒙) or
𝒅𝒙𝟐
Derivatives

Example 1:

In our car example, the position of the car at time 𝑡 is given by


1 2
𝑔 𝑡 = 𝑡 .
2

The speed of the car at time 𝑡 is given by 𝑔′ 𝑡 = 𝑡.

The acceleration of the car at time 𝑡 is given by 𝑔′′ 𝑡 = 𝑡 ′ =1


(constant acceleration)
Derivatives

Example 2:
𝑓 𝑥 = 𝑥 ln(𝑥)

𝑓′ 𝑥 = ?
Derivatives

Example 2:
𝑓 𝑥 = 𝑥 ln(𝑥)

𝑓 ′ 𝑥 = 𝑥 ln 𝑥 ′ = 𝑥 ′ ln 𝑥 + 𝑥 ln 𝑥 ′ = ln 𝑥 + 1

𝑓 ′′ 𝑥 = ?
Derivatives

Example 2:
𝑓 𝑥 = 𝑥 ln(𝑥)

𝑓 ′ 𝑥 = 𝑥 ln 𝑥 ′ = 𝑥 ′ ln 𝑥 + 𝑥 ln 𝑥 ′ = ln 𝑥 + 1

1 ′
𝑓′′(𝑥) = ln 𝑥 + 1 =
𝑥
Derivatives

Optimization with derivatives:

In general at a local minimum/maximum of a (smooth, differentiable)


function 𝑓 ′ 𝑥 = 0, and the sign of 𝑓 ′′ 𝑥 tells us whether it is a minimum or
a maximum.

Example: 𝑓 𝑥 = 𝑥 ln 𝑥 + 1 − 𝑥 ln(1 − 𝑥)

1 1
𝑓 ′( ) = 0 𝑓 ′′ =4>0
2 2

1
So 𝑥 = is a local minimum of 𝑓 𝑥 .
2
Integrals (Antiderivatives)
Integrals

Motivation: We saw how to take the position of a car over time,


1 2
𝑔 𝑡 = 𝑡 , and derive its speed over time, 𝑔′ 𝑡 = 𝑡.
2

Q: How can we do the opposite? (Derive position from speed.)


Integrals

Motivation: We saw how to take the position of a car over time,


1 2
𝑔 𝑡 = 𝑡 , and derive its speed over time, 𝑔′ 𝑡 = 𝑡.
2

Q: How can we do the opposite? (Derive position from speed.)

A: Use an integral! (aka antiderivative)


Integrals

In fact, if 𝑓 𝑡 = 𝑡 is the speed of the car over time, its position


at time 𝑡 is the area under the curve of 𝑓 𝑡 .

𝑓 𝑡 =𝑡
Integrals

In fact, if 𝑓 𝑡 = 𝑡 is the speed of the car over time, its position


at time 𝑡 is the area under the curve of 𝑓 𝑡 .

𝑓 𝑡 =𝑡
Integrals

We call this the definite integral of a function. The area of a


function 𝑓 𝑥 from a to b is written as
𝑏
න 𝑓 𝑥 𝑑𝑥
𝑎

“(definite) integral of 𝑓 𝑥 from a to b”


Integrals

speed position
𝑡
1 2
𝑓 𝑡 =𝑡 න 𝑓 𝑥 𝑑𝑥 = 𝑡
0 2
Integrals

Riemann sum:
Approximation to definite
integral as sum of areas of
rectangles of shrinking
width
Integrals

Trapezoidal rule:

Technique for approximating


definite integral as sum of
trapezoids.

Each trapezoid from [a, b] has area


𝑓 𝑎 +𝑓 𝑏
(b − a)
2
Integrals

Indefinite integral (aka antiderivative):

Integral written without bounds, e.g.

𝐹 𝑥 = න 𝑓 𝑥 𝑑𝑥

This is any function 𝐹(𝑥) such that 𝐹 ′ 𝑥 = 𝑓(𝑥) (inverse of


derivative).
Integrals

The Fundamental Theorem of Calculus says that for a


continuous function 𝑓 𝑥 ,
𝑥
𝐹 𝑥 = න 𝑓 𝑡 𝑑𝑡
𝑐

is an antiderivative of 𝑓 (i.e. 𝐹′ 𝑥 = 𝑓(𝑥)), and that


𝑏
න 𝑓 𝑡 𝑑𝑡 = 𝐹 𝑏 − 𝐹(𝑎)
𝑎
Integrals

In general:

න 𝑎𝑓 𝑥 𝑑𝑥 = 𝑎 න 𝑓(𝑥) 𝑑𝑥

න 𝑓 𝑥 + 𝑔 𝑥 𝑑𝑥 = න 𝑓 𝑥 𝑑𝑥 + න 𝑔(𝑥) 𝑑𝑥

See also: Integration by Parts


Integrals

Common integrals:

𝑛 𝑥 𝑛+1
‫ 𝑥𝑎 = 𝑥𝑑𝑎 ׬‬+ 𝐶 ‫= 𝑥𝑑 𝑥 ׬‬ 𝑛+1
+𝐶

1
‫׬‬ 𝑒 𝑥 𝑑𝑥 = 𝑒𝑥 +𝐶 ‫𝑥𝑑 𝑥 ׬‬ = ln |𝑥| + 𝐶

‫ ׬‬sin(𝑥) 𝑑𝑥 = −cos(𝑥) + 𝐶 ‫ ׬‬cos(𝑥) 𝑑𝑥 = sin(𝑥) + 𝐶

For more common derivatives, see: Calculus Cheat Sheet


Integrals

Example:
5
න 𝑥 3 + 2𝑥 − 1 𝑑𝑥 = ?
1
Integrals

Example:
5 4
3
𝑥 2
5
න 𝑥 + 2𝑥 − 1 𝑑𝑥 = + 𝑥 − 𝑥቉
1 4 1
=?
Integrals

Example:
5 4
3
𝑥 2
5
න 𝑥 + 2𝑥 − 1 𝑑𝑥 = + 𝑥 − 𝑥቉
1 4 1
54 2
1
= +5 −5 − + 1 − 1 = 186
4 4
Bonus: Taylor Series
Taylor Series

For most common functions, we can express the function as an


infinite series using its derivatives at a point 𝑎. This is called the
Taylor series for the function about 𝑎.
𝑓 ′′ 𝑎
𝑓 𝑥 = 𝑓 𝑎 + 𝑓′ 𝑎 𝑥 − 𝑎 + 𝑥−𝑎 2
+⋯
2

𝑛
𝑓 𝑎 𝑛
=෍ 𝑥−𝑎
𝑛!
𝑛=0
Taylor Series

Idea: The Taylor series gives the 1st,


2nd, 3rd, etc. order approximations to
a function based on its derivatives.

On the right: approximations to a sin


curve of increasing degree.
Taylor Series

Example:
1
𝑓 𝑥 =
1 − 2𝑥

𝑓 0 = 1, 𝑓′ 0 = 2, 𝑓′′ 0 = 8, …

So 𝑓 𝑥 = 1 + 2𝑥 + 4𝑥 2 + ⋯ (higher order terms)


Taylor Series

For more information on Taylor Series, see:

● https://en.wikipedia.org/wiki/Taylor_series

● https://tutorial.math.lamar.edu/classes/calcii/taylorseries.a
spx

● https://www.mathsisfun.com/algebra/taylor-series.html
Bonus: Partial Derivatives
Partial Derivatives

A partial derivative is the derivative of a function of multiple


variables with respect to one of them.

Example:
𝑓 𝑥, 𝑦 = 𝑥 2 + 3𝑥𝑦 + 𝑒 𝑦
𝜕𝑓
(𝑥, 𝑦) = 2𝑥 + 3𝑦
𝜕𝑥
𝜕𝑓
(𝑥, 𝑦) = 3𝑥 + 𝑒 𝑦
𝜕𝑦
Further Reading
Further Reading

● Limits Cheat Sheet

● Calculus Cheat Sheet

● Lists of integrals (Wikipedia)

● The Most Important Derivatives and Antiderivatives to


Know

● Wolfram Alpha (search tool for performing derivatives,


integrals and more)

You might also like