Compute the gradient (vector of partial derivatives) of any multivariate function. Enter your function, specify the variables, and optionally evaluate at a point. Uses the nerdamer symbolic engine – all calculations are done locally.
For a scalar function \( f(x_1, x_2, \dots, x_n) \), the gradient \( \nabla f \) is a vector of its partial derivatives:
Geometrically, the gradient points in the direction of the steepest ascent of the function, and its magnitude is the rate of increase in that direction. The gradient is always perpendicular to the level curves (or surfaces) of the function.
In optimization, we often seek to minimize a loss function \(L(\theta)\) where \(\theta\) represents parameters. Starting from an initial guess, gradient descent iteratively updates:
Here \(\eta\) is the learning rate. The negative gradient points downhill, leading to a (local) minimum. This algorithm is the foundation for training neural networks, linear regression, and countless other models.
In conservative force fields, the force \(\mathbf{F}\) is the negative gradient of potential energy \(U\): \(\mathbf{F} = -\nabla U\). For example, near Earth's surface, gravitational potential \(U = mgz\) gives \(\nabla U = (0,0,mg)\), so \(\mathbf{F} = (0,0,-mg)\) – the familiar downward force. Similarly, electric field \(\mathbf{E} = -\nabla V\) where \(V\) is electric potential.
| Function \(f(x,y)\) | Gradient \(\nabla f\) |
|---|---|
| \(x^2 + y^2\) | \((2x,\; 2y)\) |
| \(e^{x}\sin y\) | \((e^{x}\sin y,\; e^{x}\cos y)\) |
| \(\ln(x^2 + y^2)\) | \(\left(\frac{2x}{x^2+y^2},\; \frac{2y}{x^2+y^2}\right)\) |
| \(x^y\) (with \(x>0\)) | \(\left(y x^{y-1},\; x^y \ln x\right)\) |
| \(\sigma(x) = \frac{1}{1+e^{-x}}\) | \(\sigma(x)(1-\sigma(x))\) (scalar) |
Let's manually compute the gradient of \(f(x,y) = x^2 y + \sin(xy)\) and compare with the calculator.
Enter x^2*y + sin(x*y) in the tool, variables x,y, and point, say, \((1,\pi)\). The symbolic derivatives should match the formulas above, and the numerical result can be cross‑checked with a small Python script or finite differences. This tool passes such tests.
If you ever doubt a symbolic derivative, you can approximate it using the finite difference formula:
with a small \(h\) (e.g., \(10^{-5}\)). Our calculator's numerical evaluation matches this approximation to high precision when \(h\) is tiny, confirming correctness.
| Property | Description |
|---|---|
| Linearity | \(\nabla (af + bg) = a\nabla f + b\nabla g\) |
| Product rule | \(\nabla (f g) = f \nabla g + g \nabla f\) |
| Chain rule | \(\nabla (f \circ \mathbf{g}) = (J_{\mathbf{g}})^T \cdot (\nabla f \circ \mathbf{g})\) |
| Directional derivative | \(D_{\mathbf{u}} f = \nabla f \cdot \mathbf{u}\) (rate of change in direction \(\mathbf{u}\)) |
This tool uses the nerdamer symbolic mathematics library, which implements differentiation rules faithfully. The results have been cross‑checked with standard textbooks (e.g., Stewart’s Calculus, Apostol’s Mathematical Analysis). Reviewed by GetZenQuery’s mathematics team . Last updated March 2026.
x^2 * sin(y) + exp(z). Important: Always use explicit multiplication, e.g., 3*x not 3x.
x, y, z. The order determines the components of the gradient. The function must contain only these variables (constants like pi, e are allowed).
1, 2, 3). If left blank, only the symbolic gradient is shown.