Optimization Calculator (Calculus) screenshot

Optimization Calculator (Calculus)

Run numeric gradient ascent or descent on f(x, y) with a stated step and iteration cap, and report the local optimum or refuse non-convergence.

Privacy First
0 Runs
Updated 2026-11-22
Runs in your browser
No sign-up, no upload
Local optimum stated

Optimization Calculator (Calculus)

Run numeric gradient ascent or descent on f(x, y) with a stated step and iteration cap, and report the local optimum or refuse non-convergence.

How this page computes

The page walks downhill or uphill by following the numeric gradient of f(x, y). Each step moves by the step size times the gradient, and the walk stops when the gradient is small enough or the iteration cap is reached.

On −(x−1)²−(y+2)² starting at the origin with step 0.2, the walk reaches (1, −2), where the gradient is below 1e-8 and f is 0. The page prints the path, so the approach is visible.

The gradient is a central difference with h = 1e-5 and O(h²) error. If the walk has not converged by the cap, the page refuses and names the last point and gradient rather than calling it an optimum.

The calculation runs entirely in this browser tab; nothing is uploaded.

The page finds a local optimum of f(x, y) numerically: it follows the gradient with a fixed step until the gradient is small. For −(x−1)²−(y+2)² it converges to (1, −2), a local maximum with f = 0.

The word local is the honest one. A gradient walk cannot see a basin it never enters, so the page prints the path and the stopping gradient and says that it found a local optimum, not the global one.

How to use Optimization Calculator (Calculus)

Type f(x, y), choose minimize or maximize, and set the starting point.

Set the step and the iteration cap. A larger step moves faster but can overshoot; a smaller step is slower but steadier.

Press Run. Read the printed path, the stopping point, the final gradient and f there. If it did not converge, the refusal names the last point and gradient.

How the method works

Gradient ascent takes a step proportional to the gradient, because the gradient points in the direction of steepest increase. Descent does the same with a minus sign. The step size trades speed against the risk of stepping past the basin.

Convergence is judged by the gradient's length, not by the change in f, because a flat region would let the latter stop too early. The page prints both the path and the final |∇f| so the stopping rule is visible.

What to Expect

Best for

  • A local optimum of a smooth two-variable expression
  • Seeing the gradient path and its stopping point
  • Checking a hand-computed descent by one or two steps

Not ideal for

  • A global optimum guarantee
  • A non-smooth function with a kink
  • A constrained problem with a boundary

What this tool keeps

  • The expression and every starting coordinate exactly as typed

What may need cleanup

  • Nothing when it converges; the refusal names the last point when it does not

Common errors

  • A step of zero or less is refused
  • A non-convergent walk is refused with the last point and gradient
  • A non-finite gradient is refused with the step at which it happened

Example use cases

  • Maximise −(x−1)^2−(y+2)^2
  • Minimise x^2+y^2 from (3, 3)
  • See the effect of a larger step

Sample input

f(x, y) = -(x-1)^2-(y+2)^2, maximise, start (0, 0), step 0.2

Sample output

converged at (0.999999997772, -1.99999999554) with |∇f| ≈ 9.96e-9 and f ≈ 0

Who this is for

  • Students meeting gradient methods
  • Readers checking a small optimisation by hand

Frequently asked questions

Why is this only a local optimum?

The walk follows the gradient from where it starts, so it settles in the nearest basin. A different starting point can reach a different optimum, and the page says local rather than claiming the best value overall.

What happens if it does not converge?

The page refuses and names the last point and its gradient, rather than printing a point that is not an optimum. Raising the cap or lowering the step is the usual fix.

Why is the gradient numeric?

Because the page accepts the same expression grammar as the derivative pages without requiring a symbolic form for every intermediate walk. The central difference uses h = 1e-5 and has O(h²) error, which the page states.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.