Skip to main content
This guide continues the practical exploration of partial derivatives and how the gradient drives gradient descent. We keep the original sequence of examples and diagrams to clarify each concept and show real-world applications like route optimization.

1. Simple example: f(x, y) = x^2 + y^2

When computing a partial derivative, treat all other variables as constants.
  • ∂f/∂x: treat y as constant → derivative of x^2 is 2x, derivative of y^2 is 0. So ∂f/∂x = 2x.
  • ∂f/∂y: treat x as constant → derivative of y^2 is 2y, derivative of x^2 is 0. So ∂f/∂y = 2y.
Together these partials form the gradient vector, which points in the direction of the steepest increase of the function.
The image features a presentation slide titled "Why Gradient?" with a cartoon character, a mountainous landscape with a sunrise, and a person speaking next to it.
Gradient (in vector form):
\nabla f = \left[\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}\right]
\nabla f = [2x, 2y]
Evaluate at (1, 1):
f(x,y) = x^2 + y^2
\nabla f = [2x, 2y]

\text{At }(1,1):
\nabla f = [2(1), 2(1)] = [2, 2]
Interpretation: both components are positive, so moving in +x or +y increases f. To decrease f (i.e., go “downhill”), move opposite the gradient: in direction -∇f.

2. A slightly more complex function: f(x, y) = x^3 + y^3 + xy

Next example introduces higher powers and an interaction term.
The image shows a presentation about partial derivatives with a mathematical function ( f(x, y) = x^3 + y^3 + xy ), alongside a person gesturing as if explaining the concept.
Compute partial derivatives term-by-term:
  • ∂f/∂x: derivative of x^3 is 3x^2; y^3 is constant → 0; derivative of xy w.r.t. x is y.
    So ∂f/∂x = 3x^2 + y.
  • ∂f/∂y: derivative of y^3 is 3y^2; x^3 is constant → 0; derivative of xy w.r.t. y is x.
    So ∂f/∂y = 3y^2 + x.
Gradient:
\nabla f = [3x^2 + y, \; 3y^2 + x]
Evaluate at (1, 1):
\nabla f(1,1) = [3(1)^2 + 1, \; 3(1)^2 + 1] = [4, 4]
This [4, 4] indicates the steepest increase direction at (1,1). To reduce the function value, move opposite this vector.

3. Travel-time model: Susie’s delivery route

We now apply partial derivatives to a travel-time model. Let T(x, y) be Susie’s travel time depending on distance x and speed-limit-related variable y. Example model: T(x,y) = x^4 + 3x^2 + 2.5 + y^3 - 5xy
The image shows a woman in front of a black background with mathematical equations and a 3D graph. Labels like "Travel Time," "Speed Limit," and "Starting Distance" are on the graph.
Differentiate term-by-term:
  • ∂T/∂x:
    • d/dx(x^4) = 4x^3
    • d/dx(3x^2) = 6x
    • d/dx(2.5) = 0
    • d/dx(y^3) = 0 (y constant)
    • d/dx(-5xy) = -5y => ∂T/∂x = 4x^3 + 6x - 5y
  • ∂T/∂y:
    • d/dy(y^3) = 3y^2
    • d/dy(-5xy) = -5x All other terms are constant in y => ∂T/∂y = 3y^2 - 5x
Gradient:
\nabla T = [4x^3 + 6x - 5y, \; 3y^2 - 5x]
Evaluate at (1, 1):
\text{At }(1,1):
\nabla T = [4(1)^3 + 6(1) - 5(1), \; 3(1)^2 - 5(1)]
\nabla T = [4 + 6 - 5, \; 3 - 5] = [5, -2]
Interpretation: the gradient [5, -2] points to the direction that increases travel time most rapidly. A positive first component means increasing x (distance) tends to increase time; a negative second component means increasing y (speed-limit variable) tends to reduce time. Thus, to reduce travel time, move opposite the gradient.
Gradient descent update (one step): new_position = current_position - learning_rate * gradient. Recompute partial derivatives at the new position and repeat until convergence.
The app uses this iterative process: recompute partial derivatives with updated conditions (traffic, speed, closures), step opposite the gradient to reduce travel time, and refine the route in real time.

4. Real-time routing example (Susie on a scooter)

Susie trusts the app’s computed route. If traffic changes, the app updates variables and recomputes the gradient to adapt the route.
The image shows a person on a scooter with Uber Eats branding, holding a phone, alongside a map and app interface graphics. A woman is also present, gesturing as if speaking or explaining something.
Quick recap (how the app minimizes travel time):
  • Model travel time as a multivariable function (distance, speed, traffic, signals).
  • Compute partial derivatives to measure local sensitivity of time to each variable.
  • Combine partials into the gradient: the direction of greatest increase.
  • Use gradient descent: iteratively step in the negative-gradient direction to decrease travel time.
The image shows a summary of how math helps find the fastest route, with three points listed on a black background. A woman stands to the right, speaking, with the text "KodeKloud" on her shirt.

5. Where this math is used

Gradient-based optimization is foundational in many modern systems:
  • Recommendation engines (Netflix, Spotify) — minimize prediction error.
  • Self-driving vehicles — continuous control optimization with sensor inputs.
  • Logistics (Amazon, Uber Eats) — routing and fuel/time minimization.
  • Machine learning — neural network training via variants of gradient descent.
The image features a presentation slide explaining the use of machine learning in Netflix, Spotify, self-driving cars, and delivery services, alongside a person in a black shirt.

Quick reference: common derivative rules

RuleExample
Power ruled/dx(x^n) = n x^{n-1}
Constantd/dx(c) = 0
Treat other variables as constants for partialsFor f(x,y), ∂/∂x (y^3) = 0
Product with one variabled/dx(xy) w.r.t. x = y (y treated as constant)

Final takeaway

  • Partial derivatives quantify how each independent variable affects the output locally.
  • The gradient bundles partials into the direction of steepest ascent.
  • Gradient descent follows the negative gradient to find minima, making it a powerful tool for optimization in routing, ML, control systems, and more.
Further reading:

Watch Video