Robotics
← Roadmap/Foundations

Calculus & Optimization

Gradients, Lagrangians, convexity — how robots decide.

Progress0/5 questions

Why it matters in robotics

Almost every decision a robot makes — a trajectory, a grasp, a control input, a sensor-fusion estimate — is the solution to an optimization problem: an objective to minimize subject to constraints. There are principled ways to handle those constraints directly, to tell whether a problem can be solved reliably or gets trapped in a bad partial answer, and to follow the slope of a function step by step toward the best solution. Turning a planning or control idea into a solvable formulation, and knowing which methods will actually converge, is the daily work of robotics.

What to study

  • Gradients, Jacobians, and Hessians; gradient descent and its convergence behavior (step size, conditioning, local vs. global minima)
  • Constrained optimization: Lagrange multipliers, the Lagrangian, and KKT conditions for equality/inequality constraints
  • Convexity: convex sets and functions, why convex problems have a global optimum, and recognizing LP/QP/SOCP/SDP standard forms
  • Applying it in robotics: formulating trajectory optimization and convex MPC, and solving problems with tools like CVXPY

Where to study

Cheatsheet

Symbols used below

f(x)f(x)objective (cost) function
f\nabla fgradient (vector of partial derivatives)
2f\nabla^2 f (or HH)Hessian matrix (second derivatives)
α\alphastep size / learning rate
gi,hjg_i, h_jinequality / equality constraints
λi,νj\lambda_i, \nu_jLagrange multipliers (dual variables)
LLLagrangian

Gradient descent

xk+1=xkαf(xk)x_{k+1} = x_k - \alpha \nabla f(x_k)

Steps downhill along the steepest local descent direction. On an ill-conditioned (elongated) cost surface it zig-zags, since it ignores curvature — convergence needs α\alpha small enough to not overshoot.

Newton's method

xk+1=xk[2f(xk)]1f(xk)x_{k+1} = x_k - [\nabla^2 f(x_k)]^{-1} \nabla f(x_k)

Rescales the step by the inverse Hessian, so it accounts for curvature and heads more directly at the minimum — far fewer iterations near a well-behaved optimum, but each step costs more (Hessian build + solve).

Lagrangian & KKT conditions

For minf(x)\min f(x) s.t. gi(x)0g_i(x) \le 0, hj(x)=0h_j(x) = 0: L(x,λ,ν)=f(x)+iλigi(x)+jνjhj(x)L(x,\lambda,\nu) = f(x) + \sum_i \lambda_i g_i(x) + \sum_j \nu_j h_j(x)

At an optimum: xL=0\nabla_x L = 0 (stationarity), gi(x)0g_i(x) \le 0, hj(x)=0h_j(x)=0 (feasibility), λi0\lambda_i \ge 0 (dual feasibility), and λigi(x)=0\lambda_i g_i(x) = 0 (complementary slackness — a constraint is either active or its multiplier is zero).

Convexity

A function is convex if the line segment between any two points on its graph lies on or above the graph — equivalently 2f0\nabla^2 f \succeq 0 everywhere.

For a convex problem (convex objective, convex feasible set) any local minimum is the global minimum — this is why casting a problem as LP/QP/SOCP/SDP is so valuable: solvers can certify the global optimum.

Saddle points stall first-order methods

Near a saddle the gradient nearly vanishes even though it isn't a minimum — gradient descent crawls through these flat regions. Second-order methods see the mixed curvature (positive in some directions, negative in others) and escape faster.

min−∇f zig-zags on an ill-conditioned bowl; Newton/Gauss–Newton rescale by curvature
Gradient descent steps downhill along −∇f. On an elongated (ill-conditioned) cost surface it zig-zags; second-order methods (Newton / Gauss–Newton) rescale by curvature and head more directly to the minimum.
 Gradient descentNewton's method
UsesGradient onlyGradient + Hessian
Cost per stepCheap: one gradient evalExpensive: build + solve/invert Hessian
Convergence near optimumLinear, sensitive to conditioningQuadratic — very fast
Behavior on ill-conditioned surfacesZig-zagsRescales by curvature, heads straight in
updownsaddle
Near a saddle the gradient nearly vanishes, so a first-order method crawls: it descends one direction while the flat/ascending directions stall progress, until the trajectory finally slips off along a descent direction.

Application focus

Select an application above.

Practice questions (5)