Starlight Tools

Directional Derivative Calculator

Find an exact directional derivative with steps and a configurable decimal answer. Calculate the gradient, choose a vector, a second point, or an angle, and explore what the result means—all locally in your browser.

Enter the function and vectors

Try x², x**2, 2x, sin(x), sqrt(x), pi or e. Use x*y between letters. ln is natural log; log is base 10. Function angles are radians.

Math keypad

Inserts into the most recently selected expression or component field.

Coordinate order: x, y (inferred from the function).

Evaluation point P

Exact values welcome: 1/3, pi/3, sqrt(2)/2. Paste may use x=1,y=2.

Unit-vector convention: the direction is normalized, so the result is change per unit distance.

Direction vector v

Advanced options and precision

Try an example

Keyboard shortcut: Ctrl/⌘ + Enter.

Gradient and directional derivative

Symbolic gradient
The gradient will appear here.
Gradient at the point
Enter valid coordinates to evaluate the gradient.
Directional derivative
The unit direction and dot-product result will appear here.

What this result means

Report a calculation error

Step-by-step calculation

Gradient, normalization, and dot-product steps will appear here.

Explore a 2D contour plot

Level curves join points with equal function values. The blue solid arrow is the unit direction u; the orange dashed arrow is the gradient (scaled to fit). P marks your evaluation point.

At a differentiable point with nonzero gradient, a perpendicular direction is tangent to a level curve and has zero directional derivative. Curves are sampled approximations; gaps may indicate an undefined region. This plot does not test differentiability.

Accuracy, validation and limitations

Author / publisher
Starlight Robotics
Last updated
Mathematics review
No named independent mathematics reviewer is credited for this version.
Accuracy methodology
Symbolic rule transformations, exact rational arithmetic and symbolic constants precede decimal evaluation. The six worked examples below are hand-worked validation cases; automated checks compare their outputs and exercise domain errors.
Input limits
Two to six single-letter variables; 300-character functions; 100-character component expressions; up to 15 significant digits per numeric literal and scientific exponents from −100 to 100. Exact expressions may remain unsimplified. Decimal answers use floating-point arithmetic.
Unsupported syntax
No free parameters in coordinates, piecewise definitions, inequalities, complex values, factorials or unevaluated integrals. Write x*y, not xy. Use sqrt(2), not √2; log(x) means base 10.
Differentiability
The gradient formula assumes differentiability in a neighborhood of P. Undefined expressions and common singularities are rejected, but this tool cannot certify differentiability or handle every removable singularity. A zero gradient alone does not prove a maximum or minimum.
Privacy
Calculations and plot sampling run on your device. Permalinks include the inputs in the URL; share them only when intended.
Report a calculation error

Copy a report containing your inputs, computed result and this page's URL. Add the expected answer and the step that appears incorrect when sharing it with the site maintainer. This control prepares a report; it does not send it automatically.

How to use the directional derivative calculator

  1. Enter a function such as x^2*y + y^3. Use explicit multiplication between different variables.
  2. Check the inferred coordinate order, or override it in Advanced options. Enter exact point coordinates using labeled fields or compact paste mode.
  3. Choose vector components, a target point Q, or an angle (2D only). Select Calculate gradient and derivative; nonzero vectors are normalized automatically.
  4. Review rule-by-rule derivatives, exact substitution, the exact answer and its decimal approximation. Explore the interpretation and optional 2D plot.

Gradient and directional derivative formulas

For a scalar function of n variables, the gradient collects its first partial derivatives:

\[\nabla f=\left\langle \frac{\partial f}{\partial x_1},\frac{\partial f}{\partial x_2},\ldots,\frac{\partial f}{\partial x_n}\right\rangle\]

If v is a nonzero direction vector, first form the unit vector u = v/‖v‖. For a differentiable function at point p:

\[D_{\mathbf u}f(\mathbf p)=\nabla f(\mathbf p)\cdot\mathbf u\]

The gradient points in the direction of fastest increase when it is nonzero, and ‖∇f(p)‖ is the maximum directional derivative. This formula and the normalization of arbitrary direction vectors follow the standard treatment in OpenStax Calculus, Volume 3, section 4.6.

Limit definition and the normalization convention

\[D_{\mathbf u}f(P)=\lim_{h\to0}\frac{f(P+h\mathbf u)-f(P)}{h},\qquad \|\mathbf u\|=1\]

The limit measures change in f per unit distance along u. For the parameterized path r(t)=P+tv, the chain rule instead gives (f∘r)′(0)=∇f(P)·v=‖v‖Dᵤf(P). This rate is per unit t, so sources using an unnormalized v can differ by its magnitude. The advanced path option displays both rates with distinct labels.

Worked examples and validation cases

Non-unit vector: exact fraction

f=x²y+y³, P=(1,2), v=⟨3,4⟩. Holding y constant gives fₓ=2xy; holding x constant gives fᵧ=x²+3y².

∇f(P)=⟨4,13⟩; ‖v‖=√(9+16)=5; u=⟨3/5,4/5⟩.

Dᵤf=4(3/5)+13(4/5)=64/5 ≈ 12.8000.

The function increases by 12.8 units per unit distance to first order.

Exact pi and radical coordinates

f=sin(x)+y², P=(pi/3,√2/2), v=⟨0,1⟩. The chain and power rules give ∇f=⟨cos(x),2y⟩.

∇f(P)=⟨1/2,√2⟩; ‖v‖=1; u=⟨0,1⟩.

Dᵤf=(1/2)(0)+√2(1)=√2 ≈ 1.41421.

The function increases in the positive y direction.

Toward a second point

f=x²+y², P=(1,2), Q=(4,6). The power rule gives ∇f=⟨2x,2y⟩, hence ∇f(P)=⟨2,4⟩.

v=Q−P=⟨3,4⟩; ‖v‖=5; u=⟨3/5,4/5⟩.

Dᵤf=2(3/5)+4(4/5)=22/5 ≈ 4.40000.

The function initially increases as you move from P toward Q.

Angle-defined direction

f=xy, P=(1,2), θ=45°=pi/4. Holding the other variable constant gives ∇f=⟨y,x⟩, hence ∇f(P)=⟨2,1⟩.

u=⟨cos(pi/4),sin(pi/4)⟩=⟨√2/2,√2/2⟩ with magnitude 1.

Dᵤf=2(√2/2)+1(√2/2)=3√2/2 ≈ 2.12132.

The function increases along a direction 45° counterclockwise from the positive x axis.

Three-variable function

f=xyz, P=(1,2,3), v=⟨−1,2,2⟩. Holding the other two variables constant for each derivative gives ∇f=⟨yz,xz,xy⟩.

∇f(P)=⟨6,3,2⟩; ‖v‖=√(1+4+4)=3; u=⟨−1/3,2/3,2/3⟩.

Dᵤf=6(−1/3)+3(2/3)+2(2/3)=4/3 ≈ 1.33333.

The function increases in this three-dimensional direction.

Zero gradient

f=x²+y², P=(0,0), v=⟨1,−1⟩. The power rule gives ∇f=⟨2x,2y⟩, so ∇f(P)=⟨0,0⟩.

‖v‖=√2; u=⟨1/√2,−1/√2⟩.

Dᵤf=0(1/√2)+0(−1/√2)=0 ≈ 0.00000.

The function is locally level to first order in every direction; the gradient has no angle or unique steepest direction.

Directional derivative and gradient FAQs

What is the formula for a directional derivative?

For a differentiable function f and a unit vector u, Dᵤf(P)=∇f(P)·u. It is the instantaneous change in f per unit distance in direction u.

How do I find the direction from one point to another?

Subtract the starting point P from the target point Q component by component: v=Q−P. Then divide by ‖v‖. Choose “Toward another point” to do this automatically. P and Q must be different.

Can I enter an angle instead of a vector?

Yes, for two variables choose “Angle” and select degrees or radians. The angle is measured counterclockwise from the positive first coordinate axis, and the unit direction is ⟨cos θ,sin θ⟩.

Why must the vector be normalized?

A unit vector makes the directional derivative a rate per unit distance. Otherwise scaling the same direction vector would scale the answer even though the direction has not changed.

Why is my answer different by the vector magnitude?

Some sources define the derivative along the path P+tv using ∇f(P)·v. That is change per unit t and equals ‖v‖ times the unit-direction answer. Enable the advanced path option to compare both conventions.

What does a negative directional derivative mean?

At a differentiable point, a negative value means the function initially decreases as you move in the chosen direction. Its magnitude gives the rate of decrease per unit distance.

When is it zero?

For a differentiable function, it is zero when a nonzero gradient is perpendicular to the direction, or when the gradient itself is zero. This means no first-order change; it does not imply the function stays constant as you continue moving.

What is the difference between a gradient and a directional derivative?

The gradient is the vector of partial derivatives. At a nonstationary differentiable point it points toward steepest increase. A directional derivative is a scalar obtained by taking the gradient’s dot product with one unit direction.

Can the gradient formula fail?

Yes. The formula assumes differentiability at the point. Undefined expressions are rejected, but the calculator cannot certify differentiability, resolve every removable singularity, or evaluate piecewise functions.

Explore more mathematical tools

Explore more tools