skip to content

For f(x, y) = x^2 + 3xy at (1, 2), what is the directional derivative along (1, 1)/sqrt(2)?

level: middleimportance: should knowfreq 55%

answer

  1. gradient first, direction second
  2. differentiate symbolically, substitute the point last
  3. the arrow must be scaled to length one
  4. the two components get combined, not concatenated
  5. cross-check against sqrt(73), the steepest rate there

basics

~20 s

The gradient of x^2 + 3xy is (2x + 3y, 3x), which is (8, 3) at (1, 2). Combining it with the unit direction gives (8 + 3)/sqrt(2) = 11/sqrt(2), about 7.78 per unit distance.

solid answer

~50 s

First compute the gradient symbolically: `df/dx = 2x + 3y` and `df/dy = 3x`, so `grad f = (2x + 3y, 3x)`. At `(1, 2)` that is `(2 + 6, 3) = (8, 3)`. The directional derivative along a unit vector `u` is `grad f . u`, and here `u = (1, 1)/sqrt(2)`, so the answer is `(8 + 3)/sqrt(2) = 11/sqrt(2)`, roughly `7.78`. Two sanity checks are worth voicing. The unit-length requirement is not decoration: had you used the raw arrow `(1, 1)`, you would have got `11`, a factor of `sqrt(2)` too large, because the answer would then scale with the arrow's length rather than describe a rate per unit distance. And the result must not exceed the gradient's own length, `sqrt(8^2 + 3^2) = sqrt(73)`, about `8.54` — the steepest possible rate at that point. Since `7.78 < 8.54`, the numbers are consistent.

go deeper

for a junior

Practise the mechanics until they are automatic: compute both partials, plug in the point, normalise the direction, combine componentwise, and report one number.

for a middle

Explain why normalisation is required rather than just doing it: the defining limit divides by distance travelled, so a non-unit arrow rescales the answer by its own length.

for a senior

Show the checks you run before trusting a number: the sign tells you uphill or downhill, and the magnitude can never exceed the gradient's length at that point.

for a principal

Be able to argue when a directional rate is the right summary at all: it answers 'how fast along this one bearing', which is only meaningful once the input scales make that bearing comparable across variables.

## What is being asked A directional derivative answers: standing at a specific point, if I walk along a specific bearing, how fast does the function change per unit of distance travelled? It reduces a whole surface to one number, given a point and a direction. ## Step 1 — the gradient, symbolically For `f(x, y) = x^2 + 3xy`, differentiate one variable at a time with the other held constant. - With respect to `x`: the term `x^2` contributes `2x`; the term `3xy` is a constant `3y` times `x`, contributing `3y`. So `df/dx = 2x + 3y`. - With respect to `y`: the term `x^2` is constant in `y`, contributing `0`; the term `3xy` is a constant `3x` times `y`, contributing `3x`. So `df/dy = 3x`. Hence `grad f(x, y) = (2x + 3y, 3x)`. ## Step 2 — evaluate at the point At `(x, y) = (1, 2)`: - `df/dx = 2*1 + 3*2 = 2 + 6 = 8` - `df/dy = 3*1 = 3` So `grad f(1, 2) = (8, 3)`. Substituting the point *after* differentiating is essential; substituting first would freeze the function into a constant and destroy the derivative. ## Step 3 — combine with the direction For a differentiable `f` and a direction `u` of length one, the directional derivative is `D_u f = grad f . u = (df/dx) * u1 + (df/dy) * u2` With `u = (1, 1)/sqrt(2)`, i.e. `u1 = u2 = 1/sqrt(2)`: `D_u f(1, 2) = 8 * (1/sqrt(2)) + 3 * (1/sqrt(2)) = 11/sqrt(2)` Rationalised, `11/sqrt(2) = 11*sqrt(2)/2`, numerically about `7.78`. It is positive, so this bearing goes uphill: moving a small distance `s` along it raises `f` by roughly `7.78 * s`. ## Why the direction must have length one The defining limit is `D_u f = lim_{h -> 0} [ f(a + h*u) - f(a) ] / h`. Here `h` is intended to be the distance travelled, which is only true when `u` has length one. Feed in the raw arrow `(1, 1)` instead and you get `8 + 3 = 11`, exactly `sqrt(2)` times the correct value — because `(1, 1)` reaches `sqrt(2)` units of distance for every unit of `h`. Double the arrow to `(2, 2)` and the number doubles again. Without normalisation you are not reporting a property of the bearing at all; you are reporting a property of the particular arrow someone happened to draw. This is the single most common slip on this question, and interviewers watch for whether you normalise unprompted. ## Sanity checks **Upper bound.** No directional derivative can exceed the gradient's magnitude, since `D_u f = |grad f| * cos(theta)` and the cosine is capped at 1. Here `|grad f(1, 2)| = sqrt(64 + 9) = sqrt(73)`, about `8.54`. Our answer `7.78` sits just below it, which is what you would expect: the bearing `(1, 1)/sqrt(2)` is close to, but not exactly, the direction `(8, 3)` in which the steepest rate `sqrt(73)` is achieved. **Sign.** A positive value means uphill along that bearing. Reversing to `(-1, -1)/sqrt(2)` flips the sign to `-11/sqrt(2)`: the same slope walked backwards. **Type.** The directional derivative is a single number, not a vector. If your answer has two components you have confused it with the gradient. **Zero directions.** Any unit direction perpendicular to `(8, 3)` — for instance `(3, -8)/sqrt(73)` — gives `24 - 24 = 0`, no first-order change. ## The shape of the answer Given a point and a direction, the recipe never changes: differentiate symbolically, evaluate at the point, normalise the direction, combine componentwise, then sanity-check the sign and the magnitude bound. Interviewers who ask this are checking arithmetic discipline and whether you understand what the number means, not exotic calculus.

  • What would you have got if you used the raw vector (1, 1) without normalising, and why is that wrong?
    You would get 8 + 3 = 11, which is sqrt(2) times too large. The defining limit divides by the step parameter and only equals distance travelled when the direction has length one. Without normalising, the answer scales with how long the arrow happens to be rather than describing the bearing.
  • What is the largest directional derivative at (1, 2), and along which bearing?
    The largest possible rate is the gradient's length, sqrt(8^2 + 3^2) = sqrt(73), about 8.54, achieved along the unit vector pointing the same way as (8, 3). Every other bearing gives less, which is why our 7.78 along (1, 1)/sqrt(2) must fall below it.
  • Can a directional derivative be negative, and what does that mean?
    Yes. Along (-1, -1)/sqrt(2) the value is -11/sqrt(2): the function decreases at that rate per unit distance. Sign simply reports whether the chosen bearing goes uphill or downhill, and reversing a bearing always flips the sign while preserving the magnitude.

saying these in an interview costs you the question

  • Uses the raw direction vector without scaling it to unit length
  • Reports 11 instead of 11/sqrt(2)
  • Substitutes the point before differentiating
  • Reports the directional derivative as a vector
  • Gives an answer larger than the gradient's own magnitude without noticing

context