ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Calculus Fundamentals for Machine Learning
Chapter 1: Why Calculus for Machine Learning?
The Role of Math in Machine Learning
Introducing Functions: Inputs and Outputs
Visualizing Functions: Graphs
What is a Limit?
Intuition Behind Limits
Connecting Functions and Limits to ML
Quiz for Chapter 1
Chapter 2: Derivatives: Measuring Change
Rate of Change: Average vs Instantaneous
The Derivative: Slope of a Tangent Line
Derivative Notation (Leibniz and Lagrange)
Calculating Derivatives: The Power Rule
Calculating Derivatives: Constants and Sums
Introduction to Higher-Order Derivatives
Practice: Calculating Simple Derivatives
Quiz for Chapter 2
Chapter 3: Optimization with Derivatives
Finding Maximum and Minimum Points
Optimization: Why Minimize or Maximize?
Cost Functions in Machine Learning
Goal: Minimizing the Cost Function
Introduction to Gradient Descent
How Derivatives Guide Gradient Descent
Visualizing Gradient Descent
Quiz for Chapter 3
Chapter 4: Handling Multiple Inputs: Partial Derivatives
Functions of Multiple Variables
Partial Derivatives: The Concept
Calculating Partial Derivatives
Partial Derivative Notation
The Gradient Vector
Geometric Meaning of the Gradient
Practice: Calculating Partial Derivatives and Gradients
Quiz for Chapter 4
Chapter 5: Calculus in Action: Simple Optimization
Recap: Optimization Goal and Gradient Descent
Example: Simple Linear Regression Model
Defining a Cost Function for Linear Regression
Calculating Gradients for the Cost Function
Performing a Gradient Descent Step
The Learning Rate Parameter
Putting It All Together: The Optimization Process
Hands-on Practical: Manual Gradient Calculation
Quiz for Chapter 5

Finding Maximum and Minimum Points

The derivative of a function, f′(x)f'(x)f′(x), describes the instantaneous rate of change or the slope of the tangent line at any given point xxx. This concept of slope is fundamental for identifying specific points of interest on a function's graph, such as peaks and valleys.

Think about walking along a hilly path represented by a function f(x)f(x)f(x). When you reach the very top of a hill (a maximum point) or the very bottom of a valley (a minimum point), for a brief moment, the path under your feet is level, or horizontal. A horizontal path has a slope of zero.

This intuition directly translates to calculus. If a smooth function f(x)f(x)f(x) reaches a local maximum or a local minimum at a point x=cx = cx=c, and the derivative exists at that point, then the slope of the tangent line at that point must be zero. Mathematically, we write this as:

f′(c)=0f'(c) = 0f′(c)=0

Points where the derivative is zero (or undefined, though we'll focus on zero for now) are called critical points. These critical points are the candidates for where local maximums or minimums might occur.

Visualizing the Flat Slope

For example, the function f(x)=x2−4x+5f(x) = x^2 - 4x + 5f(x)=x2−4x+5. This is a parabola. Let's find its derivative using the power rule and sum/constant rules from the previous chapter:

f′(x)=ddx(x2−4x+5)=2x−4+0=2x−4f'(x) = \frac{d}{dx}(x^2 - 4x + 5) = 2x - 4 + 0 = 2x - 4f′(x)=dxd​(x2−4x+5)=2x−4+0=2x−4

Now, let's find where the slope is zero by setting the derivative equal to zero:

f′(x)=0f'(x) = 0f′(x)=0 2x−4=02x - 4 = 02x−4=0 2x=42x = 42x=4 x=2x = 2x=2

This tells us that at x=2x = 2x=2, the slope of the function is zero. Let's look at the graph:

The plot shows the parabola f(x)=x2−4x+5f(x) = x^2 - 4x + 5f(x)=x2−4x+5. The red dot marks the minimum point at (2,1)(2, 1)(2,1). The dashed red line is the tangent line at this point, which is horizontal, indicating a slope of f′(2)=0f'(2) = 0f′(2)=0.

The Process: Finding Candidates for Maxima and Minima

So, the general process to find potential locations of maximum or minimum values (the critical points) for a function f(x)f(x)f(x) involves these steps:

  1. Calculate the Derivative: Find the derivative function, f′(x)f'(x)f′(x).
  2. Set Derivative to Zero: Set the derivative equal to zero: f′(x)=0f'(x) = 0f′(x)=0.
  3. Solve for x: Solve the resulting equation for xxx. The values of xxx you find are the critical points.

It's important to remember that finding f′(x)=0f'(x) = 0f′(x)=0 only gives you the candidates. While these points often correspond to local maxima or minima, they could occasionally be other types of points (like inflection points where the curve flattens out momentarily before continuing in the same general direction). For our purposes in machine learning optimization, we are usually searching for a minimum, and the condition f′(x)=0f'(x) = 0f′(x)=0 is the fundamental starting point for finding it.

Why is this Important for Machine Learning?

This procedure of finding where the derivative is zero is not just a mathematical exercise. It forms the basis of how many machine learning algorithms are "trained".

Imagine you have a machine learning model, and you define a cost function (also called a loss function). This function measures how "bad" the model's predictions are compared to the actual data. A high value means the model is performing poorly; a low value means it's doing well.

The goal of training the model is to adjust its internal parameters to make the cost function as small as possible, ideally reaching its minimum value. If we can represent the cost as a function of the model's parameters, we can use calculus to find the parameter values that minimize this cost. Finding where the derivative of the cost function equals zero helps us locate this minimum error state, leading to the best possible model performance according to our chosen cost measure.

In the upcoming sections, we'll explore cost functions and the specific algorithm, Gradient Descent, which uses derivatives iteratively to find these minimum points, even when solving f′(x)=0f'(x)=0f′(x)=0 directly is difficult or impossible.

  • Calculus, James Stewart, Daniel K. Clegg, Saleem Watson, 2020 (Cengage Learning) - A standard undergraduate calculus textbook that provides a comprehensive treatment of derivatives and their applications, including finding local and absolute maxima and minima.
  • Mathematics for Machine Learning, Marc Peter Deisenroth, A. Aldo Faisal, and Cheng Soon Ong, 2020 (Cambridge University Press) DOI: 10.1017/9781108679901 - Provides a rigorous yet accessible introduction to the mathematical foundations essential for machine learning, including a dedicated chapter on optimization that clearly explains derivatives in the context of finding minima for cost functions.
  • Deep Learning, Ian Goodfellow, Yoshua Bengio, Aaron Courville, 2016 (MIT Press) - Chapter 4, "Numerical Computation," covers optimization algorithms and the role of derivatives in finding minima for cost functions, offering a foundational understanding relevant to machine learning.
  • Single Variable Calculus, Prof. Dr. David Jerison, 2010 (MIT OpenCourseWare) - This free online course from MIT provides lectures and materials covering fundamental concepts of single-variable calculus, including finding maxima and minima using derivatives.

© 2026 ApX Machine Learning