acalculator

What is the directional derivative of f?

Type a function of x and y (or x, y and z), a point, and a direction vector. The page gives the directional derivative at the point, the gradient, and the largest rate of change.

Your numbers

D_u f
8

The directional derivative of x^2 - x y + 3y^2 at the point in the direction (3, 4) is 8.

Exact D_u f
8
∇f =
(2x - y, -x + 6y)
∇f at the point
(-4, 13)
Largest D_u f
13.60147051

D_u f: 8. The directional derivative of x^2 - x y + 3y^2 at the point in the direction (3, 4) is 8.

How to calculate

Finds the directional derivative D_u f = ∇f · u of f(x, y) or f(x, y, z) at a point, in the direction of a vector, with the gradient.

Example with the default inputs (f(x, y, z) x^2 - x y + 3y^2, Point x -1, Point y 2, Direction, x part 3, Direction, y part 4): The directional derivative of x^2 - x y + 3y^2 at the point in the direction (3, 4) is 8.

Method: D_u f(P) = ∇f(P) · v/‖v‖, each partial derivative from a computer algebra system, checked numerically.

  • The direction v is scaled to length 1 first.
  • Angles in radians. An answer that fails its check is not shown.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. f(x, y, z) x^2 - x y + 3y^2, Point x -1, Point y 2, Direction, x part 3, Direction, y part 4 gives D_u f 8, Exact D_u f 8, ∇f = (2x - y, -x + 6y), ∇f at the point (-4, 13).Source: OpenStax, Calculus Volume 3, section 4.6 Directional Derivatives and the Gradient (https://openstax.org/books/calculus-volume-3/pages/4-6-directional-derivatives-and-the-gradient), Example 4.32 (u = (3/5, 4/5))
  2. f(x, y, z) 5x^2 - 2x y + y^2 - 4y z + z^2 + 3x z, Point x 1, Point y -2, Point z (for f in x, y, z) 3, Direction, x part -1, Direction, y part 2, Direction, z part 2 gives D_u f -8.333333, Exact D_u f -25/3.Source: OpenStax, Calculus Volume 3, section 4.6 Directional Derivatives and the Gradient (https://openstax.org/books/calculus-volume-3/pages/4-6-directional-derivatives-and-the-gradient), Example 4.37
  3. f(x, y, z) x y, Point x 1, Point y 1, Direction, x part 1, Direction, y part 1 gives D_u f 1.414214, Largest D_u f 1.414214.

How it works

f is a function of x and y, or of x, y and z when the point has a z coordinate. The point is P = (x₀, y₀) or (x₀, y₀, z₀) and the direction is v = (v₁, v₂) or (v₁, v₂, v₃) (an empty v₃ is 0).

  1. A computer algebra system (nerdamer, open source) finds each partial derivative, f_x, f_y and f_z, with the other letters held constant. Each is checked: at 15 fixed test points, a five-point central difference must match it to 10⁻⁶ of its size, as on the partial derivative calculator.
  2. ∇f(P) is the gradient at P.
  3. u = v/‖v‖, where ‖v‖ = √(v₁² + v₂² + v₃²). v must not be the zero vector.
  4. D_u f(P) = ∇f(P) · u = f_x(P) u₁ + f_y(P) u₂ + f_z(P) u₃.
  5. Largest D_u f = ‖∇f(P)‖.
  6. The exact value: when the partial derivatives hold no function or constant (no sin, e, π) and every typed number is 0 or has at most 10 digits and a size from 10⁻⁶ to 10⁶, the algebra simplifies (∇f(P) · v)/√(v₁² + v₂² + v₃²) from the typed numbers. It shows when it holds no rounded number and equals the decimal value to 10⁻⁹; the decimal value is then computed from it.

There is no answer when f, or one of its partial derivatives, is not defined at P, or when f uses z and no z coordinate is typed. Angles are in radians.

Worked examples by hand

f(x, y) = x² − xy + 3y² at (−1, 2), towards (3, 4) (OpenStax Calculus Volume 3, Example 4.32). f_x = 2x − y and f_y = −x + 6y, so ∇f(−1, 2) = (−4, 13). ‖(3, 4)‖ = 5 and u = (3/5, 4/5). D_u f = −4 × 3/5 + 13 × 4/5 = 8.

f(x, y, z) = 5x² − 2xy + y² − 4yz + z² + 3xz at (1, −2, 3), towards (−1, 2, 2) (Example 4.37). ∇f = (10x − 2y + 3z, −2x + 2y − 4z, 3x − 4y + 2z), so ∇f(1, −2, 3) = (23, −18, 17). ‖v‖ = 3. D_u f = (−23 − 36 + 34)/3 = −25/3.

f(x, y) = xy at (1, 1), towards (1, 1). ∇f = (y, x) = (1, 1) and u = (1, 1)/√2, so D_u f = 2/√2 = √2 ≈ 1.414213562, which is also ‖∇f‖, as u points along the gradient.

Other questions people ask

What is a directional derivative?

The rate at which f changes at a point as you move from it in the direction of a unit vector u. For f(x, y) and u = (a, b), D_u f(x, y) = f_x(x, y) a + f_y(x, y) b. The partial derivatives f_x and f_y are the directional derivatives along the x and y axes.

How do I find a directional derivative?

Find the gradient ∇f = (f_x, f_y, f_z), evaluate it at the point, and take its dot product with the unit vector u = v/‖v‖ in the chosen direction. For f = x² − xy + 3y² at (−1, 2) towards (3, 4): ∇f(−1, 2) = (−4, 13) and u = (3/5, 4/5), so D_u f = −12/5 + 52/5 = 8.

Do I need to type a unit vector?

No. Type any nonzero vector in the direction you want; the page divides it by its length first. (3, 4) and (0.6, 0.8) give the same answer.

What if the direction is given as an angle θ?

Type the direction vector (cos θ, sin θ). For θ = π/3 that is (0.5, 0.8660254038), or use (1, 1.732050808), since only the direction counts.

In which direction is the directional derivative largest?

In the direction of the gradient ∇f. The largest value is ‖∇f‖ at the point, shown as "Largest D_u f". Opposite the gradient f falls fastest, at −‖∇f‖, and at right angles to it D_u f is 0.

How is the answer checked?

Each partial derivative comes from a computer algebra system and must match a numeric difference quotient at 15 test points. The exact value is shown only when it equals the decimal value to 10⁻⁹.