0% found this document useful (0 votes)
3 views

Calculus bootcamp

The document outlines a calculus course for the MSDA Bootcamp 2024 Summer, covering topics such as functions, limits, derivatives, optimization, integrals, and constraint optimization. It emphasizes the importance of derivatives in various fields including economics and machine learning, and introduces the concept of Lagrange multipliers for solving optimization problems with constraints. The document includes exercises and theoretical explanations to facilitate understanding of these mathematical concepts.

Uploaded by

809876700qq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Calculus bootcamp

The document outlines a calculus course for the MSDA Bootcamp 2024 Summer, covering topics such as functions, limits, derivatives, optimization, integrals, and constraint optimization. It emphasizes the importance of derivatives in various fields including economics and machine learning, and introduces the concept of Lagrange multipliers for solving optimization problems with constraints. The document includes exercises and theoretical explanations to facilitate understanding of these mathematical concepts.

Uploaded by

809876700qq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

8/28/24, 9:29 AM Maths - Calculus

Maths - Calculus
MSDA - Bootcamp 2024 Summer

KT Wong
Faculty of Social Sciences, HKU
2024-08-27

The materials in this topic are drawn from Simon and Blume (1994) and Chiang and
Wainwright (2005)

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 1/26


8/28/24, 9:29 AM Maths - Calculus

Outline
1. Functions
2. Limits
3. Derivatives
4. Optimization
5. Higher-order derivatives
6. Some common rules
7. Partial derivatives
8. Integrals
9. Constraint optimization

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 2/26


8/28/24, 9:29 AM Maths - Calculus

Functions

What is a function?
▶ domain
▶ range
▶ mapping

What is not a function?

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 3/26


8/28/24, 9:29 AM Maths - Calculus

Limits

What is a limit?
▶ idea of a slope

Does it always exist?

Is it unique?

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 4/26


8/28/24, 9:29 AM Maths - Calculus

Derivatives

What is Derivative?
▶ slope of a function
▶ rate of change

why learning it?


▶ optimization
▶ economics
▶ statistics
▶ machine learning
▶ deep learning

reminder about notation


▶ df (x)
dx

▶ df
dx
▶ ′
f (x)
file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 5/26
8/28/24, 9:29 AM Maths - Calculus

▶ d
dx
f (x)
▶ d
dx
f

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 6/26


8/28/24, 9:29 AM Maths - Calculus

Optimization

How to find the maximum or minimum of a function?


▶ let us think about a quadratic function, y = ax2 + bx + c

How to find out the maximum or minimum of a function?


▶ first-order condition
▶ critical points

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 7/26


8/28/24, 9:29 AM Maths - Calculus

Higher-order derviatives

second-order derivative
▶ concave
▶ convex
▶ inflection point

third-order derivative

n-th order derivative

local vs global maximum/minimum

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 8/26


8/28/24, 9:29 AM Maths - Calculus

Some common rules of derivatives

How to calculate Derivative?


▶ power rule

▪ dxn
dx
= nxn−1
▶ product rule

▪ d
dx
f (x)g(x) = f ′ (x)g(x) + f (x)g′ (x)
▶ quotient rule

▪ d f (x)
dx g(x)
=
f ′ (x)g(x)−f (x)g′ (x)
(g(x))2

▶ chain rule

▪ d
dx
f (g(x)) = f ′ (g(x))g′ (x)
▶ special rules for logs and exponents

▪ d
dx
ln(x) = 1
x
file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 9/26

8/28/24, 9:29 AM Maths - Calculus

d x
dx
e = ex

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 10/26


8/28/24, 9:29 AM Maths - Calculus

Exercises:
d 3
1. dx
(6 x + 5)
2. d
dx
√ (5x3 ‾‾‾‾‾‾‾‾‾‾‾‾
+ 3x + 5)‾
df (x)
3. let h(x) = 2x + 3; g(x) = 5x2 + 3x, let f (x) = h(x) ∗ g(x), dx
h(x) dp(x)
4. let p(x) = g(x)
, dx
d(g(h(x)))
5. dx
d 6
6. dx
ln( x + 8)
d 6x+3
7. dx
e
d 3 x
8. dx
x e

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 11/26


8/28/24, 9:29 AM Maths - Calculus

Partial derviatives

What is a partial derivative?


▶ Let z = f (x, y)
▶ ∂f
∂x

▶ ∂f
∂y

Exercise:
▶ let f (x, y) = x2 y3 + 3x + 2y
▶ find
∂f
∂x
and
∂f
∂y

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 12/26


8/28/24, 9:29 AM Maths - Calculus

Integrals

What is an integral?
▶ area under the curve
▶ anti-derivative

Notation
▶ b
∫ a f (x)dx
▶ ∫ X f (x)dx

We are most interested in the concept rather than actual (hand) calculation of the
integrals

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 13/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

What is constraint optimization?


▶ optimization with constraints
▶ Lagrange multiplier

The idea is to optimize a function subject to some constraints

The problem can be stated as:


▶ maximize f (x, y) subject to g(x, y) = 0
▶ minimize f (x, y) subject to g(x, y) = 0

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 14/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

let us learn some economics

in economics, a consumer faces the problem of maximizing her utility subject to the
income constraint:

max u(x1 , x2 ) s. t. p1 x1 + p2 x2 = y
x1 ,x2

we can visualize and “solve” the problem using graph

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 15/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

the optimal solution is at the point where the budget line is tangent to the indifference
curve
MU1 p1
=
MU2 p2
where MU1 and MU2 are the marginal utilities of good 1 and good 2 respectively

we can solve this problem using the “identity”

u(x1 , x2U (x1 )) = ū

we need to solve two equations simultaneously

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 16/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

the Lagrange multiplier is a method to solve the optimization problem with


constraints

the Lagrange function is defined as:

L(x1 , x2 , λ) = u(x1 , x2 ) + λ(y − (p1 x1 + p2 x2 ))

the first-order conditions are


∂u
− λp1 = 0
∂x1
∂u
− λp2 = 0
∂x2
y − (p1 x1 + p2 x2 ) = 0

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 17/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

the Lagrange multiplier could be interpreted as the “marginal utility of income” in our
example

in economics, the Lagrange multiplier could be interpreted as the “shadow price” of


the constraint
▶ e.g. the Lagrange multiplier could be interpreted as the “marginal cost” in
production optimization

Reminder: the Lagrange multiplier could be zero, positive or negative

the Lagrange multiplier could be used in very general optimization problems

max f (x1 , … , xn ) s. t. gi (x1 , … , xn ) = ci , i = 1, … , m


x1 ,…,xn

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 18/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

Inequality-Constrained Optimization

max f (x1 , … , xn ) s. t. gi (x1 , … , xn ) ≤ ci , i = 1, … , m


x1 ,…,xn

let us think about a (very) simple situation first

max f (x) s. t. x ≥ 0
x

if x∗ > 0, what the necessary condition should be?

the FOC for the problem is

(x ) {
df ∗ ≤0 if x∗ = 0
dx =0 if x∗ > 0

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 19/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

Here we have the following theorem

Theorem
Suppose that f :  →  is a C 1 function. Then, if x∗ maximizes f (x) for all x ≥ 0 ,
then x∗ satisfies
df ∗
(x ) ≤ 0
dx
df
x∗ (x∗ ) = 0
dx
x∗ ≥ 0

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 20/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

when we form the Lagrange function, we have

L(x, λ) = f (x) + λx

the FOC is
dL ∗ ∗ df ∗
(x , λ ) = (x ) + λ∗ = 0
dx dx
dL ∗ ∗
(x , λ ) = x∗ ≥ 0

dL ∗ ∗
λ∗ ≥ 0, λ∗ (x , λ ) = 0

the first and second equation is the same as the FOC for the equality-constrained
optimization problem

the third equation is the complementary slackness condition

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 21/26


8/28/24, 9:29 AM Maths - Calculus

these FOCs are called Kuhn-Tucker conditions

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 22/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization
Mixed Constraints Problem

the mixed constraints problem is


max f (x1 , … , xn )
x1 ,…,xn
s. t. gi (x1 , … , xn ) ≥ ci , i = 1, … , m
hj (x1 , … , xn ) = dj , j = 1, … , k

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 23/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization
Theorem of Kuhn-Tucker Conditions

Suppose that f : RN → R, g : Rn → Rm , and h : Rn → Rk are C 1 functions.


Let x∗ be a local maximum of f (x) subject to the constraints g(x) ≥ c and h(x) = d .
Then there exist λ∗ ∈ Rm and μ∗ ∈ Rk such that
df ∗ dg dh
(x ) + λ∗ (x∗ ) + μ∗ (x∗ ) = 0
dx dx dx
λ∗ ≥ 0, λ∗ ⋅ (g(x∗ ) − c) = 0
μ∗ ≥ 0, μ∗ ⋅ (h(x∗ ) − d) = 0

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 24/26


8/28/24, 9:29 AM Maths - Calculus

Constraint optimization

Exercise 1 — Kuhn-Tucker Conditions

max f (x1 , x2 ) = x1 s. t. x13 + x22 ≤ 0


x1 ,x2

Exercise 2 — Kuhn-Tucker Conditions

max U(x, y) s. t. px x + py y ≤ M and x, y ≥ 0


x,u

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 25/26


8/28/24, 9:29 AM Maths - Calculus

References
Chiang, Alpha, Chung-i, and Kevin. Wainwright. 2005. Fundamental Methods of
Mathematical Economics. 4th ed. / [rev. by] Kevin Wainwright. New York:
McGraw-Hill.
Simon, Carl P., and Lawrence. Blume. 1994. Mathematics for Economists. 1st ed.
New York ; W.W. Norton.

file:///Users/leslie/Library/Containers/com.microsoft.Outlook/Data/tmp/Outlook Temp/Maths - Calculus_student.html#/constraint-optimization-1 26/26

You might also like