AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

Introduction to Multivariate Calculus

📚 Programming & Coding⏱️ 29 min read🎓 Grade 10
✍️ AI Computer Institute Editorial Team Updated: August 2026 CBSE-aligned · Peer-reviewed · 29 min read
Content curated by subject matter experts with IIT/NIT backgrounds. All chapters are fact-checked against official CBSE/NCERT syllabi.

Open a trekking app for the Roopkund trail in Uttarakhand and look at the elevation overlay. At any point on that map, "how steep is it here?" is not one number — it depends on which direction you start walking. Walk due east along a ridge and you might climb gently; walk due north from the same spot and you might be staring at a cliff. Single-variable calculus, the calculus you already know, has no way to talk about this. It only knows how to differentiate a function of one variable, which describes a curve, not a landscape. To describe how a quantity changes when it depends on two or more independent inputs at once — elevation depending on both east-west and north-south position, a game's frame rate depending on both resolution and texture quality, a neural network's loss depending on thousands of weights simultaneously — you need a genuinely different toolkit. That toolkit is multivariate calculus, and this chapter builds it from the ground up.

A function of two variables, and how to see it

A single-variable function like f(x) = x² takes one number in and gives one number out; its graph is a curve in a 2D plane. A two-variable function f(x, y) takes a pair of numbers in and gives one number out. Its graph lives in three dimensions: for every point (x, y) on a flat plane, the graph has a height z = f(x, y) above (or below) it — exactly like the trekking app, where (x, y) is your location and z is the elevation there.

Take the concrete example we will return to throughout this chapter: f(x, y) = x² + y². Plug in a few points: f(0,0) = 0, f(1,0) = 1, f(0,1) = 1, f(3,4) = 25. The surface this traces out is a bowl (a paraboloid), lowest at the origin and rising in every direction as you move away from it.

Drawing a 3D surface on paper is awkward, so cartographers and meteorologists use a trick you have already seen without necessarily naming it: level curves (also called contour lines). A level curve is the set of all points (x, y) where the function takes one fixed value — it's what you get by slicing the 3D surface horizontally and looking straight down at the slice. The India Meteorological Department's monsoon rainfall maps and the contour lines on a trekker's topographic sheet are both level-curve diagrams of a two-variable function (rainfall as a function of location, or elevation as a function of location). For our bowl f(x,y) = x² + y², the level curve where f = 9 is the set of points satisfying x² + y² = 9 — a circle of radius 3. The level curve for f = 4 is a smaller circle of radius 2, and for f = 16, a bigger circle of radius 4. Concentric circles, tighter together where the bowl is steeper — this single picture will do a lot of work for us later in the chapter.

Partial derivatives: differentiating one variable while freezing the rest

Back to the trekking app. "The slope walking due east" is really asking: if I hold my north-south position (y) completely fixed and only let my east-west position (x) change, how fast does elevation change? That is precisely what a partial derivative measures. The definition mirrors the single-variable derivative you already know, with one crucial addition — everything except the variable you're differentiating with respect to is frozen as a constant:

∂f/∂x = lim (h→0) [f(x+h, y) − f(x, y)] / h      (y held fixed)
∂f/∂y = lim (h→0) [f(x, y+h) − f(x, y)] / h      (x held fixed)

In practice you almost never use this limit directly — you use the ordinary differentiation rules from single-variable calculus, treating the "other" variable exactly like you would treat the number 5 or 7. Let's compute one carefully, term by term, so the mechanics are completely explicit.

Worked example. Let f(x, y) = x²y + 3xy² − 2x. Find ∂f/∂x and ∂f/∂y, then evaluate both at the point (1, 2).

For ∂f/∂x, treat y as a constant:

  • x²y — differentiate and carry the constant y along: gives 2xy.
  • 3xy² — here 3y² is the constant multiplying x, so this term differentiates like (3y²)·x: gives 3y².
  • −2x — differentiates to −2.

So ∂f/∂x = 2xy + 3y² − 2.

For ∂f/∂y, treat x as a constant:

  • x²y — here is the constant multiplying y: gives .
  • 3xy² — here 3x is the constant multiplying , so this differentiates like (3x)·y²: gives 6xy.
  • −2x — has no y in it at all, so with respect to y it is purely a constant: derivative 0.

So ∂f/∂y = x² + 6xy.

Now evaluate at (1, 2): ∂f/∂x(1,2) = 2(1)(2) + 3(2)² − 2 = 4 + 12 − 2 = 14, and ∂f/∂y(1,2) = (1)² + 6(1)(2) = 1 + 12 = 13. Read this as: standing at (1,2) on the surface, moving one small step in the pure-x direction increases f at rate 14; moving one small step in the pure-y direction increases f at rate 13.

What it means geometrically. Fixing y = y₀ and letting x vary slices the 3D surface with a vertical plane, and that slice is an ordinary curve — a single-variable function of x alone. ∂f/∂x at that point is exactly the slope of the tangent line to that sliced curve. ∂f/∂y is the same idea for the perpendicular slice. Two independent slopes, two independent slices — this is why a landscape genuinely needs two numbers to describe its local steepness, not one.

The misconception to kill immediately: partial derivative vs. total derivative

A very common error, made by students who have just learned partial derivatives, is to assume ∂f/∂x tells you how f changes as you move along any path through the point — including a path where y also happens to change with x. It does not. ∂f/∂x is specifically the rate of change with y pinned down.

Here is the concrete counterexample. Take f(x,y) = x² + y², so ∂f/∂x = 2x. At x = 3 (with y fixed at whatever it is), ∂f/∂x = 6. But suppose you instead walk along the diagonal path y = x — moving along x while y tags along equal to it. Along this path, f becomes a single-variable function of x alone: f(x,x) = x² + x² = 2x². Differentiating this total derivative with respect to x gives d/dx(2x²) = 4x, which at x=3 is 12 — exactly double the partial derivative's 6. The partial derivative and the total derivative along a path are genuinely different quantities that happen to share similar-looking notation. Whenever a problem says "holding the other variable fixed," it wants a partial derivative; whenever it describes motion along a specific path where both variables move together, you need the chain rule for paths (a topic that builds directly on partial derivatives, usually covered right after this chapter).

Second-order partial derivatives, and a theorem that looks like magic (but isn't)

Just as you can differentiate twice in single-variable calculus to get f''(x), you can take partial derivatives of partial derivatives. With two variables there are four second-order partials: differentiate ∂f/∂x again with respect to x to get f_xx, or with respect to y to get f_xy; differentiate ∂f/∂y again with respect to y to get f_yy, or with respect to x to get f_yx.

f_xy and f_yx look like they should be different — one differentiates x-then-y, the other y-then-x — but for essentially every function you will meet in this course, they turn out to be identical. This is Clairaut's theorem (also called Schwarz's theorem): if the mixed partials f_xy and f_yx are both continuous on an open region, they are equal there. It is not automatic for every conceivable function (pathological counterexamples exist in higher mathematics), but it holds for every polynomial, exponential, trigonometric, and logarithmic function you will differentiate at this level, so you can use it as a genuine computational shortcut and a check on your own arithmetic.

Verify it on our running example, f = x²y + 3xy² − 2x, where we already found f_x = 2xy + 3y² − 2 and f_y = x² + 6xy:

  • f_xy = differentiate f_x = 2xy + 3y² − 2 with respect to y = 2x + 6y.
  • f_yx = differentiate f_y = x² + 6xy with respect to x = 2x + 6y.

They match, exactly as Clairaut's theorem predicts. If you ever compute f_xy ≠ f_yx for an ordinary function like this, treat it as a signal to recheck your algebra, not as a discovery.

The gradient vector: combining both partials into one arrow

The two partial derivatives at a point are naturally packaged together as a vector called the gradient, written ∇f (read "grad f" or "del f"):

∇f(x, y) = (∂f/∂x, ∂f/∂y)

This is more than notational tidiness — the gradient has a precise geometric meaning that we can actually derive, not just assert. Suppose you stand at a point and take a tiny step of size h in some direction described by a unit vector u = (u₁, u₂) (unit meaning u₁² + u₂² = 1, so it's a pure direction with no length of its own). Your new position is (x + hu₁, y + hu₂). For a small step, the change in f can be approximated by adding up the two partial contributions — moving hu₁ in x contributes approximately f_x · hu₁, and moving hu₂ in y contributes approximately f_y · hu₂:

f(x+hu₁, y+hu₂) − f(x,y)  ≈  f_x·(hu₁) + f_y·(hu₂)

Dividing by h and letting h → 0 gives the exact directional derivative — the true rate of change of f as you move in direction u:

D_u f = f_x·u₁ + f_y·u₂ = ∇f · u

That final expression is a dot product between the gradient vector and the direction you chose. Now recall from vector algebra that for any vector ∇f and unit vector u, ∇f · u = |∇f| · cos θ, where θ is the angle between them and |∇f| is the gradient's length. Since |∇f| doesn't depend on which direction you pick, this quantity is maximized exactly when cos θ = 1, i.e. when θ = 0 — when you walk in exactly the direction the gradient points. This proves two facts simultaneously, from first principles, rather than by assertion: the gradient points in the direction of steepest ascent, and its magnitude |∇f| equals the steepest possible rate of increase. Walking in the opposite direction, −∇f, gives the steepest descent — the fact the last section of this chapter is built on.

Compute it for our bowl f(x,y) = x² + y²: ∇f = (2x, 2y). At the point (2.4, 1.8) — which sits exactly on the f = 9 level circle, since 2.4² + 1.8² = 5.76 + 3.24 = 9 — the gradient is ∇f = (4.8, 3.6), with magnitude √(4.8² + 3.6²) = √(23.04+12.96) = √36 = 6. Notice the direction (4.8, 3.6) is just the point (2.4, 1.8) scaled by 2 — the gradient points straight outward from the centre, radially, which is exactly perpendicular to the circular level curve at that point. This is not a coincidence: the gradient is always perpendicular to the level curve passing through that point, because moving along a level curve keeps f constant (zero directional derivative), which forces the gradient to have zero component along the curve, leaving it pointing straight across.

x y f=4 f=9 f=16 ∂f/∂x direction ∂f/∂y direction ∇f = (4.8, 3.6) P = (2.4, 1.8)

Critical points: where the landscape goes flat

In single-variable calculus, you find the maxima and minima of f(x) by solving f'(x) = 0. The two-variable analogue is to find where the gradient vanishes entirely — both partials zero at once:

∇f(x,y) = (0, 0)   ⟺   f_x(x,y) = 0  and  f_y(x,y) = 0

Such a point is a critical point. But here two-variable calculus introduces something single-variable calculus never has to worry about: a flat point on a landscape does not have to be a summit or a valley floor. It can be a saddle point — like the middle of a mountain pass, where you're at a local minimum if you look along the ridge, but a local maximum if you look across it. Classifying which kind of critical point you've found needs a genuine test, not a guess.

The second-derivative test (Hessian test). At a critical point, compute the discriminant:

D = f_xx · f_yy − (f_xy)²

Then:

  • If D > 0 and f_xx > 0: local minimum (the bowl curves upward in every direction).
  • If D > 0 and f_xx < 0: local maximum (curves downward in every direction).
  • If D < 0: saddle point (curves up in one direction, down in another).
  • If D = 0: the test is inconclusive — the curvature information at this order isn't enough to decide, and you need a different argument (an example follows immediately below, because this case is exactly where students get tripped up).

Worked example A — a minimum. Let f(x,y) = x² + y² − 4x − 6y + 13. Setting f_x = 2x − 4 = 0 gives x = 2; setting f_y = 2y − 6 = 0 gives y = 3. Critical point: (2, 3). Second derivatives: f_xx = 2, f_yy = 2, f_xy = 0, so D = (2)(2) − 0² = 4 > 0 and f_xx = 2 > 0 — a local minimum. The value there is f(2,3) = 4 + 9 − 8 − 18 + 13 = 0. In fact this function is secretly (x−2)² + (y−3)² in disguise (expand it and check), which makes the minimum obvious by inspection — a useful sanity check on the algebraic test.

Worked example B — a saddle. Let f(x,y) = x² − y². f_x = 2x = 0 and f_y = −2y = 0 both force (0,0). Here f_xx = 2, f_yy = −2, f_xy = 0, so D = (2)(−2) − 0 = −4 < 0: a saddle. Walking along the x-axis from the origin, f = x² > 0 rises; walking along the y-axis, f = −y² < 0 falls. Same point, opposite behaviour in two directions — the definition of a saddle, confirmed directly.

Worked example C — why D = 0 genuinely needs care. Let f(x,y) = x⁴ + y⁴. Then f_x = 4x³ = 0 and f_y = 4y³ = 0 give the critical point (0,0). Second derivatives: f_xx = 12x², which is 0 at the origin; likewise f_yy = 0 and f_xy = 0. So D = 0 · 0 − 0² = 0 — the Hessian test is silent, telling us nothing. Yet the answer is not actually in doubt: for every point (x,y), x⁴ + y⁴ ≥ 0 = f(0,0), so the origin is obviously the global minimum — we just proved it directly instead of through curvature. What happened is that near the origin this surface is extremely flat (it grows like the fourth power of distance, not the second), so the second-derivative test, which only "feels" quadratic curvature, is too coarse an instrument to detect a minimum that shallow. The lesson: D = 0 is not a verdict, it's an instruction to look harder.

local minimum: f = x² + y² every level curve encloses the point saddle point: f = x² − y² level curves cross the point, opening both ways

Gradient descent: the algorithm that runs on everything above

Here is where partial derivatives stop being an abstract exercise and become the engine of a real algorithm you can run on a computer. Suppose you want to find the minimum of some function without solving ∇f = 0 algebraically — maybe because the function is too complicated, or because it's the loss function of a machine learning model with thousands of variables and no closed-form solution exists. Gradient descent exploits exactly the fact we proved earlier: −∇f points in the direction of steepest decrease. So starting from any point, repeatedly take a small step in the direction −∇f, and you must be moving downhill; do this enough times and you converge toward a minimum.

Let's minimise g(x, y) = (x − 3)² + (y + 2)² + 1, whose true minimum is obviously at (3, −2) with value 1 (by inspection, since both squared terms are zero there and nowhere below). Its gradient is ∇g = (2(x−3), 2(y+2)). Here is the algorithm in Python, starting from the origin with a step size (learning rate) of 0.1:

def f(x, y):
    return (x - 3)**2 + (y + 2)**2 + 1

def grad_f(x, y):
    return (2*(x - 3), 2*(y + 2))

x, y = 0.0, 0.0
lr = 0.1
for step in range(5):
    gx, gy = grad_f(x, y)
    x = x - lr * gx
    y = y - lr * gy
    print(step, round(x, 4), round(y, 4), round(f(x, y), 4))

Trace it by hand to see exactly what the computer does. At (0,0): grad_f returns (2(0−3), 2(0+2)) = (−6, 4). The update is x = 0 − 0.1(−6) = 0.6, y = 0 − 0.1(4) = −0.4. Then f(0.6, −0.4) = (0.6−3)² + (−0.4+2)² + 1 = 5.76 + 2.56 + 1 = 9.32. That's the first printed line: 0 0.6 -0.4 9.32.

Repeating the same arithmetic for the remaining iterations gives the full trace (Python's round drops trailing zeros, so step 4 prints 2.017, not 2.0170):

0 0.6 -0.4 9.32
1 1.08 -0.72 6.3248
2 1.464 -0.976 4.4079
3 1.7712 -1.1808 3.181
4 2.017 -1.3446 2.3959

Each row is closer to (3, −2) and each value of f is smaller than the last, converging toward the true minimum of 1. There's a clean reason the convergence is this well-behaved: for this particular quadratic function, one gradient-descent update multiplies the distance from the answer by a fixed factor (1 − 2·lr) = 1 − 0.2 = 0.8 every single step — check it yourself: x−3 starts at −3, and −3 × 0.8 = −2.4, matching x=0.6 exactly (0.6 − 3 = −2.4); the next step gives −2.4 × 0.8 = −1.92, matching x = 1.08 (1.08 − 3 = −1.92), and so on. This is the same core idea — descend along −∇f — that trains logistic regression models, neural networks, and most other machine learning systems you'll encounter if you continue in computer science: replace the two weights x and y here with thousands or millions of network weights, replace this toy g with a loss function measuring prediction error, and the loop above is structurally the same loop that runs, at far larger scale, whenever such a model is trained.

Where this sits in your exams

An honest note first: neither the CBSE Class 10–12 syllabus nor the JEE Main/Advanced or BITSAT syllabi include partial derivatives or multivariable calculus by name — your board exam and the major engineering-entrance exams stay entirely within single-variable calculus (limits, continuity, derivatives and their applications for a function of one variable). You will not be handed a CBSE question that says "find ∂f/∂x."

So why learn it now? Two honest reasons, not exam-shaped padding. First, GATE — the exam that matters after a B.Tech — splits sharply by stream on this exact topic. GATE Mechanical Engineering and GATE Electrical Engineering explicitly list "Partial Derivatives … Gradient, Divergence and Curl" under Engineering Mathematics, so everything in this chapter is directly examinable there. GATE CS/IT's published Engineering Mathematics syllabus, by contrast, stops at single-variable calculus — limits, continuity, differentiability, maxima and minima, the Mean Value Theorem, and integration — with no partial derivatives, gradient, or vector calculus on the paper. If your target is GATE CS specifically, treat this chapter as conceptual groundwork for the field you're entering, not as syllabus content you'll be tested on directly.

Second — and this is the reason it belongs in a programming chapter rather than a pure-mathematics one — the gradient is the mathematical object underneath gradient descent, the optimisation method behind most machine learning training today (a minority of setups use gradient-free approaches, like evolutionary or random search, but the overwhelming majority of models you've actually heard of, including virtually every deep neural network, are trained by descending a gradient). If computer science, data science, or ML is where you're headed, this chapter is where that machinery begins.

For olympiad-style enrichment, look to INMO/RMO-style problems rather than KVPY — the Kishore Vaigyanik Protsahan Yojana, once a common reference point for this kind of material, was discontinued by the Government of India after 2021 and is no longer a running exam. In INMO/RMO problem sets, two-variable optimisation shows up informally and often: AM-GM and Cauchy-Schwarz inequality problems in two variables are frequently critical-point arguments in disguise, even though the official solutions rarely use the word "gradient" to describe them.

Summary

  • A function of two variables f(x,y) has a graph that is a surface, and can be visualised through level curves (contour lines) — slices where f is constant.
  • A partial derivative ∂f/∂x differentiates with respect to one variable while every other variable is held fixed; it measures the slope of the surface sliced along that one direction. It is not the same as a total derivative along a path where variables move together.
  • Mixed second partials f_xy and f_yx are equal whenever both are continuous (Clairaut's theorem) — true for every function in this course.
  • The gradient ∇f = (f_x, f_y) is a vector; it points in the direction of steepest increase of f, and its magnitude is that steepest rate. This follows directly from the directional derivative formula D_u f = ∇f · u.
  • Critical points occur where ∇f = 0. The Hessian discriminant D = f_xx f_yy − f_xy² classifies them: D>0, f_xx>0 is a minimum; D>0, f_xx<0 is a maximum; D<0 is a saddle; D=0 is inconclusive and needs direct reasoning.
  • Gradient descent repeatedly steps in the direction −∇f to find a minimum numerically — the algorithmic core of how most machine learning models are trained.

Test yourself

Q1. Given f(x,y) = x³y − 2xy² + y, find f_x and f_y.

Answer. f_x = 3x²y − 2y² (differentiate x³y as y·x³ giving 3x²y; differentiate −2xy² as −2y²·x giving −2y²; the lone y term has no x, so contributes 0). f_y = x³ − 4xy + 1 (differentiate x³y as x³·y giving ; differentiate −2xy² as −2x·y² giving −4xy; differentiate the lone y giving 1).

Q2. Find and classify all critical points of f(x,y) = x² − 4x + y² − 2y + 5.

Answer. f_x = 2x − 4 = 0 ⟹ x = 2; f_y = 2y − 2 = 0 ⟹ y = 1. Critical point (2,1). f_xx = 2, f_yy = 2, f_xy = 0, so D = 4 > 0 and f_xx > 0: local minimum. Value: f(2,1) = 4 − 8 + 1 − 2 + 5 = 0.

Q3. For f(x,y) = xy, find ∇f at (2,3), then find the directional derivative of f at (2,3) in the direction of the vector (3,4).

Answer. f_x = y, f_y = x, so ∇f(2,3) = (3, 2). The vector (3,4) has length 5, so the unit direction is u = (0.6, 0.8). D_u f = ∇f · u = 3(0.6) + 2(0.8) = 1.8 + 1.6 = 3.4.

Q4. Classify the critical point of f(x,y) = xy at the origin using the Hessian test.

Answer. f_x = y, f_y = x, both zero only at (0,0). f_xx = 0, f_yy = 0, f_xy = 1, so D = (0)(0) − (1)² = −1 < 0: a saddle point (moving along the line y=x from the origin gives f = x² > 0, rising; moving along y=−x gives f = −x² < 0, falling).

Q5. Run two steps of gradient descent by hand on f(x,y) = (x−1)² + (y−4)², starting at (0,0) with learning rate 0.25. Give the coordinates and f-value after each step.

Answer. ∇f = (2(x−1), 2(y−4)). Step 1, at (0,0): gradient = (−2, −8); new point = (0 − 0.25(−2), 0 − 0.25(−8)) = (0.5, 2.0); f(0.5, 2.0) = 0.25 + 4 = 4.25. Step 2, at (0.5, 2.0): gradient = (2(−0.5), 2(−2)) = (−1, −4); new point = (0.5 + 0.25, 2.0 + 1.0) = (0.75, 3.0); f(0.75, 3.0) = 0.0625 + 1 = 1.0625. Both the coordinates and the value are converging toward the true minimum at (1, 4), where f = 0.

Think About It

Think about this: How would you explain introduction to multivariate calculus to a friend who has never seen a computer? What real-world analogy would you use? Imagine you had to build a system using these concepts — what would be your first step? Try this: before moving on, write down three things you learned and one question you still have.

← Bayesian Inference: Updating Beliefs with EvidenceTaylor Series — Local Linearization for ML →

Found this useful? Share it!

📱 WhatsApp 🐦 Twitter 💼 LinkedIn