Explains partial derivatives, gradients, and introductory gradient descent for optimizing multivariable problems such as routing and travel time.
Welcome — it’s Justyna from KodeKloud.In this lesson we uncover how gradient descent helps machines make smarter decisions. We will define what a gradient is, show how partial derivatives compute it, and see how these tools guide models (like routing apps) to better solutions step by step.
This article explains gradients, partial derivatives, and the first steps toward gradient descent — practical math used in routing, machine learning, and optimization.
Why does this matter? Consider Susie, an Uber Eats driver: faster deliveries mean more orders and higher earnings. To optimize each delivery, her app must evaluate routes and update them as conditions change. Gradient-based methods help the app decide when and how to change the route.
Have you ever wondered how your phone’s map app finds the fastest route and then updates it as traffic changes?
AI-powered routing doesn’t just compute a single shortest path — it continuously improves route choices using gradient information.
Meet Susie again: she accepts an order, and her app quickly calculates the fastest route based on distance, speed, traffic, and more. The app evaluates many factors, and gradients help it decide which direction to change its route to reduce travel time.
Interested in solving real-world problems with math and AI? Careers that work on routing, autonomous driving, and logistics include:
Role
Focus
Why it matters
Machine Learning Engineer
Train models that predict and optimize routes
Turns data into adaptive routing strategies
Data Scientist
Analyze traffic, weather, and demand patterns
Finds signals to improve model performance
Software Engineer
Build the apps and systems users rely on
Integrates models into real-time products
Logistics Analyst
Plan efficient delivery networks
Reduces cost and improves service
These fields are growing rapidly and need problem-solvers who can blend math, data, and systems.
Now, back to the math.Derivatives describe the rate of change of a function. We often write the derivative of f with respect to x as df/dx (or f'(x)); both express how a small change in x affects f(x).
Example — a simple difficulty function that scores a route from 0 to 10. Let x be the distance (miles). One illustrative function is:
f(x) = x^4 - 3x^2 + 2.5
On the graph, a downward slope means difficulty is decreasing; an upward slope means difficulty is increasing. The best moment to consider changing routes is where the slope is zero (a local minimum/maximum or saddle point).
Take the derivative (using power rules; constants go to zero):
df/dx = 4x^3 - 6x
This derivative guides decisions: if df/dx is negative, the difficulty decreases with a small increase in x (good); if positive, difficulty increases (bad). For specific values:
x
df/dx calculation
df/dx
1
4(1)^3 - 6(1)
-2
2
4(2)^3 - 6(2)
20
A negative derivative at x = 1 means difficulty is decreasing there; a large positive derivative at x = 2 means difficulty rises quickly — the model should avoid staying in that region. In real-world systems we often have many variables, so we turn to multivariable functions.
Our earlier function used only x. To model travel time we add y (speed limit). A simple travel-time function might look like:
Note the interaction term -5xy: it links distance (x) and speed (y) to show they jointly affect travel time.This function exists in 3D: x (distance) on one axis, y (speed limit) on another, and t = T(x,y) vertical. In practice we consider only positive x and y (distance and speed are non-negative). The y axis could represent coarse speed categories (1 = 10 mph, 2 = 20 mph, etc.), while t is travel time.
Our goal is to minimize travel time, and with multiple variables we use partial derivatives to measure change with respect to each variable separately. Partial derivatives replace d with ∂ and, together, form the gradient — a vector pointing in the direction of greatest increase. For minimization we move opposite the gradient.Compute partial derivatives of T(x, y):
To reduce travel time, an optimization algorithm (like gradient descent) updates (x, y) in small steps opposite to ∇T, iteratively moving toward a local minimum.
Partial derivatives measure how the function changes along one variable while holding others constant. The gradient combines these rates to indicate the steepest ascent; moving opposite the gradient reduces the function value.
Where do we go from here? In the next part we’ll show how to use these partial derivatives in an iterative optimization algorithm (gradient descent), pick a learning rate, and watch how the route (or model parameters) converge toward an optimal solution.