Lecture 20
University of Arizona
INFO 511 - Spring 2025
Optimization Algorithms: Calculus is essential for understanding and implementing optimization algorithms like gradient descent, which are used to minimize error functions in machine learning models.
Modeling Change: Derivatives help in modeling and understanding the rate of change in various phenomena, which is crucial for predictive analytics and dynamic systems in data science.
Integral Applications: Integrals are used in calculating areas under curves, which is fundamental for probability distributions, statistical inference, and understanding cumulative effects in data analysis.
A function is a relation between a set of inputs and a set of permissible outputs, where each input is related to exactly one output.
Mathematical notation: f(x) denotes a function named f with x as the input variable.
Linear function: f(x)=2x+3
Quadratic function: f(x)=x2−4x+4
Exponential function: f(x)=ex
Logarithmic function: f(x)=log(x)
Using matplotlib
Using SymPy
Using matplotlib
import matplotlib.pyplot as plt
import numpy as np
# Define the function
def f(x):
return 2 * x + 3
# Generate x values
x = np.linspace(-10, 10, 400)
y = f(x)
# Plot the function
plt.plot(x, y, label='f(x) = 2x + 3')
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title('Graph of the Linear Function')
plt.legend()
plt.grid(True)
plt.show()
Predictive Modeling:
Functions predict outputs from inputs, essential for machine learning.
Example: Linear regression predicts continuous outcomes.
Descriptive Analysis:
Functions describe relationships, revealing patterns and trends.
Example: Growth functions model population or business growth.
Decision Making:
Functions formulate decision rules and optimization problems.
Example: Cost functions minimize expenses or maximize profits.
Branch of mathematics that studies continuous change.
Differential (rates of change & slopes of curves)
Integral (accumulation of quantities & areas under curves)
Measures the rate at which a quantity changes.
Example: In machine learning, the derivative of the loss function with respect to model parameters helps in finding the optimal parameters.
Symbol: dydx of f′(x)
Practical Application: Gradient Descent Algorithm
Measures the accumulation of quantities and the area under a curve.
Example: Used to compute the area under probability distribution functions, which is essential in statistics and data analysis.
Symbol: ∫f(x)dx
Practical Application: Calculating Cumulative Distribution Functions (CDFs)
slope=riserun
slope=change in distance(Δx)change in time(Δt)
slope=x(15)−x(10)t(15)−t(10)
slope=202m−122m15s−10s
slope=80m5s=16m/s
Calculating derivatives using SymPy
Differentiation rules
Constant rule: ddx(c)=0
Power rule: ddx(xn)=nxn−1
Constant multiple rule: ddx[c⋅f(x)]=c⋅f′(x)
Sum rule: ddx[f(x)+g(x)]=f′(x)+g′(x)
Difference rule: ddx[f(x)−g(x)]=f′(x)−g′(x)
Function: f(x)=7
Derivative: f′(x)=0
Function: f(x)=x3
Derivative: f′(x)=ddx(x3)=3x2
Function: f(x)=5x2
Derivative: f′(x)=5⋅ddx(x2)=5⋅2x=10x
Function: f(x)=x3+4x−5
Derivative: f′(x)=ddx(x3)+ddx(4x)−ddx(5)=3x2+4−0=3x2+4
Complex Derivatives:
Involves functions composed of multiple less complex functions.
Requires application of rules like the chain rule and product rule for differentiation.
Example Function: h(x)=(ln(x)⋅eax)k
(f(g(x)))′=f′(g(x))⋅g′(x)
Function: f(x)=(3x2+2)5
Outer function: u5
Inner function: u=3x2+2
f′(x)=5(3x2+2)4⋅ddx(3x2+2)
Function: f(x)=(3x2+2)5
ddx(3x2+2)=6x
f′(x)=5(3x2+2)4⋅6x
f′(x)=30x(3x2+2)4
Function: g(x)=sin(x3+4x)
Outer function: sin(u)
Inner function: u=x3+4x
g′(x)=cos(x3+4x)⋅ddx(x3+4x)
Function: g(x)=sin(x3+4x)
ddx(x3+4x)=3x2+4
g′(x)=cos(x3+4x)⋅(3x2+4)
Function: h(x)=(ex2⋅ln(x))2
Outer function: u2
Inner function: u=ex2⋅ln(x)
h′(x)=2(ex2⋅ln(x))⋅ddx(ex2⋅ln(x))
Function: h(x)=(ex2⋅ln(x))2
Inner function: u=ex2⋅ln(x)
Product rule: (u⋅v)′=u′⋅v+u⋅v′
Let u=ex2 and v=ln(x)
u′=ddx(ex2)=2xex2
v′=ddx(ln(x))=1x
Function: h(x)=(ex2⋅ln(x))2
ddx(ex2⋅ln(x))=(2xex2)⋅ln(x)+ex2⋅1x
=2xex2ln(x)+ex2x
Function: h(x)=(ex2⋅ln(x))2
h′(x)=2(ex2⋅ln(x))⋅(2xex2ln(x)+ex2x)
Simplify:
h′(x)=2ex2ln(x)(2xex2ln(x)+ex2x)
h′(x)=2ex2ln(x)(2xex2ln(x)+ex2⋅x−1)
Definition:
A partial derivative represents the rate of change of a function with respect to one variable while keeping other variables constant.
Notation: ∂f∂x denotes the partial derivative of f with respect to x.
Significance:
Essential in understanding functions of multiple variables.
Crucial for optimization in multivariable calculus.
Used in various fields such as physics, engineering, and economics to model complex systems.
Multi-variable functions:
Gradient:
The vector of all partial derivatives in a function.
Indicates the direction of the steepest ascent
Notation: ∇f=(∂f∂x,∂f∂y)
Given the function f(x,y)=x3+3xy+y3, calculate the partial derivatives with respect to x and y:
You’ll learn more about this in INFO 521: Introduction to Machine Learning
ae-13-derivation
Derivations (you will be tested on this in Exam 2)