2025 Week 6 - Optimization
Overview
Optimization methods are compared by their assumptions, convergence, and robustness, from one-dimensional bracketed search with Brent's method to multidimensional derivative-free methods such as Powell and Nelder-Mead, and gradient-based methods including Newton and stochastic gradient descent. The lecture then develops equality constraints through Lagrange multipliers and KKT systems, explains nonlinear least squares with Gauss-Newton and Levenberg-Marquardt, and closes with a neural-network demonstration of fitting a function by adjusting weights.
Key takeaways
- Brent’s method is a strong default for one-dimensional minimization because it combines golden-section bracketing with inverse quadratic interpolation, but an initial bracket in SciPy is not necessarily a hard bound.
- A zero gradient identifies a stationary point, not necessarily a minimum; an indefinite Hessian has both positive and negative eigenvalues and indicates saddle-point curvature.
- Nelder-Mead and Powell avoid explicitly calculating gradients, which can help on nonsmooth or complicated objectives, but they are generally slower and do not guarantee a global minimum.
- Lagrange multipliers convert an equality-constrained problem into stationary equations for a Lagrangian, while penalty methods can become poorly conditioned when their penalty weight is too large.
- Gauss-Newton simplifies nonlinear least squares by approximating the Hessian near small residuals; Levenberg-Marquardt adds damping to make updates more robust when the initial fit is not close.
- Neural-network training is an optimization problem over weights and biases: the lecture’s small network uses repeated gradient-based updates to fit a sampled damped sine function.
Chapters
- The objective is to find a vector x that minimizes scalar f(x), optionally subject to equality constraints G(x)=0 and inequality constraints H(x)≤0.
- Maximizing f is equivalent to minimizing −f; finding a zero of the gradient identifies an extremum, which may be a minimum, maximum, or saddle point.
- Optimization often involves many variables, such as portfolio holdings, and gradients or Hessians can be costly or undefined.
- Local optimization can settle at a local minimum rather than the global minimum, especially for functions with trigonometric terms or many valleys.
- Global-search strategies include running multiple minimizers from varied initial guesses, perturbing candidate solutions, and using differential evolution or genetic algorithms.
- Simulated annealing, particle swarm, and watershed methods seek other optima through temperature, population-based exploration, or rising function levels.
- The egg holder surface illustrates a rugged objective with nested square roots and trigonometric functions, where a local search can miss the lowest basin.
- A constrained optimum may lie exactly on a bound, even while the gradient points outside the feasible region.
- Bounds can prevent invalid evaluations such as log(x) for x≤0; a plausible but incorrect numerical result is harder to detect than a crash or NaN.
- Unlike bisection for root finding, minimization cannot rely on a sign change, so a bracketed search tracks three points around a candidate optimum.
- A quadratic is fitted through the three points, a fourth point is evaluated, and the bracket is updated according to whether that point has a lower function value.
- Bracketed methods are most natural in one dimension; they can also serve as inner searches within multidimensional optimizers.
- Golden-section search chooses a point so either branch reduces the search interval by the same proportion.
- The self-similar spacing lets the method reuse function evaluations; each step retains approximately 0.618 of the previous interval.
- Golden-section search guarantees bracket contraction but converges sublinearly, motivating faster alternatives.
- Brent’s method combines the dependable interval reduction of golden-section search with inverse quadratic interpolation and, in some implementations, secant steps.
- Inverse quadratic interpolation estimates the minimizer’s x-coordinate from function values at three points, rather than merely fitting a parabola’s function value.
- The method selects steps using safeguards, aiming for superlinear convergence while retaining a reliable fallback.
- A SciPy Brent example finds a minimum near x=1.357 by updating its candidate bracket over successive iterations.
- Brent can handle nonsmooth objectives such as |x|, whose minimum is zero at x=0, as well as more complicated combinations of absolute values and trigonometric terms.
- Derivative-free search is useful when a gradient is unavailable or a function contains sharp corners.
- In SciPy’s Brent minimization interface, an initial bracket is a starting region, not necessarily a restriction on where the optimizer can go.
- An inverse-quadratic step can jump outside a bracket such as [−5, −1] and converge to a different local minimum.
- Use an explicit bounds option when the solution must remain in a fixed interval; neither a bracket nor bounds guarantee a global minimum.
- Powell’s method performs one-dimensional minimizations along selected directions, then uses the displacement between resulting points to construct a new search direction.
- The method aims to create conjugate directions, a generalization of orthogonality that reduces interference between successive search steps.
- It obtains directional information without explicitly calculating gradients, making it useful for complicated objectives.
- Under a transformation, directions orthogonal in output space correspond to conjugate directions in the original variable space.
- On a narrow valley, ordinary steps can repeatedly cross the valley and undo progress; conjugate directions can follow its floor more directly.
- Conjugate-gradient guarantees rely on conditions such as a symmetric positive-definite system, while Powell’s approach applies directional searches more generally.
- The two-dimensional demonstration shows Powell’s method moving from an initial guess along a curved valley toward a minimum.
- Following the valley floor avoids repeatedly climbing its steep walls, though finite precision can make very steep, shallow valleys difficult.
- The method uses no explicit gradient information, trading derivative requirements for additional function evaluations.
- Nelder-Mead, often called the amoeba method, moves a simplex: an interval in 1D, triangle in 2D, or tetrahedron in 3D.
- The algorithm compares objective values at simplex vertices and modifies the worst point to move the simplex toward lower values.
- It is derivative-free and broadly robust, but typically slower than methods that exploit gradient or conjugacy information.
- Nelder-Mead operations include reflecting the highest, worst vertex across the other vertices, expanding a promising reflection, or contracting when a smaller move is safer.
- If the best vertex is the point to replace, the simplex can contract toward the remaining vertices.
- The simplex’s expansion and contraction help it explore and narrow around an optimum without a gradient, but do not guarantee finding a global minimum.
- Newton optimization applies a root finder to ∇f(x)=0, using the Hessian H and gradient to compute an update.
- For a scalar objective, the gradient is a vector and the Hessian is a matrix; solving the Newton step requires a linear system.
- The Hessian is symmetric for a sufficiently smooth scalar function, but is not necessarily positive definite, so the stationary point may not be a minimum.
- For a quadratic objective such as x²+y², the Hessian is constant, so Newton’s method reaches the minimum in one step from the example’s initial guess.
- A quadratic with a cross term can have a saddle: its gradient is zero even though curvature is positive in one direction and negative in another.
- The Hessian’s definiteness distinguishes a bowl-shaped minimum from an indefinite saddle, which is common in equality-constrained optimization.
- Gradient descent follows the negative gradient, but can zigzag across narrow valleys and require many iterations.
- Line searches choose how far to move along a proposed descent direction; more elaborate step-length calculations can improve progress at added computational cost.
- Newton conjugate-gradient methods reuse search directions to reduce redundant movement, while higher-order derivatives can be too expensive to justify.
- For extremely high-dimensional models, stochastic gradient descent estimates a direction from a sampled subset of dimensions or data rather than processing everything at once.
- A learning rate scales the update; a sufficiently small value can stabilize training when the estimated direction is imperfect.
- The lecture connects neural-network training to optimization of a large set of model parameters, while noting that the exact training details of commercial language models are not specified.
- A positive-definite Hessian has positive eigenvalues and bowl-shaped curvature; a negative-definite Hessian has negative curvature, while an indefinite Hessian has both signs.
- A semidefinite Hessian can have a zero eigenvalue, indicating a flat direction or null space and potentially a singular system.
- The assignment asks students to implement Newton-Raphson for intersecting circles, minimize wire temperature over a radius, and fit a nonlinear Arrhenius-style curve.
- A trust-region method approximates the objective near the current point and searches within a limited radius where the approximation is considered reliable.
- If the trial step performs as predicted, the trust region can expand; if not, it can shrink and the step may be rejected.
- Trust regions trade extra iterations for robustness against bad steps, discontinuities, and invalid evaluations such as log of a negative number.
- A line search fixes a direction and optimizes distance along it; a trust-region method fixes a local radius and searches within that neighborhood.
- SciPy methods include trust-region Newton conjugate-gradient and SLSQP, while Powell and Nelder-Mead are direct methods that do not explicitly calculate gradients.
- Derivative-free methods can be robust but slow, and the lecture’s demonstrations show that individual algorithms can still overstep or behave erratically.
- Equality-constrained optimization minimizes an objective while enforcing G(x)=0, such as minimizing a quantity on the unit circle x²+y²=1.
- A penalty method adds a large multiple of G(x)² to the objective, creating a steep cost for violating the constraint.
- Choosing the penalty weight is difficult: too small weakly enforces the constraint, while too large can create poor conditioning and destabilize numerical methods.
- For a quadratic objective with linear constraints, combining the Hessian and constraint matrix produces a block KKT system.
- The KKT matrix is generally indefinite, with positive and negative eigenvalues, so derivative-free downhill methods can fail on its saddle-point structure.
- Lagrange multipliers connect optimization to duality, shadow prices in economics, and conjugate state variables in thermodynamics.
- For each data point, a residual measures the difference between the model prediction and the observed value; stacking residuals creates a vector r(β).
- Nonlinear least squares minimizes r(β)ᵀr(β), the sum of squared residuals, over model parameters β.
- The residual Jacobian is typically rectangular when there are more observations than parameters, so the problem uses least-squares or pseudoinverse methods rather than an ordinary matrix inverse.
- Newton’s method applied to the sum of squared residuals uses both the residual Jacobian and second-derivative terms.
- Gauss-Newton drops the second-derivative terms when residuals are small, approximating the Hessian with a product of the Jacobian and its transpose.
- The resulting least-squares step uses a pseudoinverse and works well near a solution, but can be unreliable when the initial parameter estimate is poor.
- Levenberg-Marquardt blends Gauss-Newton with gradient descent through a damping parameter: small damping favors Gauss-Newton, while large damping produces more conservative steps.
- The method is widely used for nonlinear curve fitting; the lecture identifies SciPy curve_fit and Excel Goal Seek as examples of tools using it or related implementations.
- A demonstration fits a nonlinear function to sampled data, with the estimated curve closely following the generating function.
- A feed-forward neural network has input and output layers plus hidden layers; layer count defines depth and neurons per layer define width.
- Each connection has a trainable weight, neurons combine weighted inputs and apply an activation function, and biases provide additional adjustable parameters.
- Training minimizes a loss based on prediction errors by updating weights, often with stochastic gradient descent and a learning rate.
- An interactive demonstration trains a shallow, three-neuron-wide network to approximate a diminishing sine function.
- Repeated updates reduce the prediction error and bring the network output closer to the sampled target function.
- The example illustrates the universal-function-approximator idea and why neural-network training relies on large numbers of algebraic operations suited to GPUs and TPUs.
Transcript excerpt
0:00 So, ironically, today is about optimization. Um, that was a gong show. Uh, Google managed to steer me off the highway because there was a slowdown onto um, what is it? Olympic or York or something that goes above Coots. And as soon Yeah. Right. As soon as you turn onto it, it's like surprise 20 minute delay. Yeah. Isn't it great? Fantastic. I love it. Yeah. Okay. Um, I actually had a few things I needed to ask you guys beforehand. Give me a second. Uh, where would that be? Yeah. Okay. Um, from now on, if you want to do the uh the written alternative oral instead of the the oral oral, let's
0:50 go with alternative oral. If you want to do the alternative oral, please let us know. Please let Yuru know know uh when you're submitting the assignment. So Thursday night, right, Friday 8:30, just let her know. And also just write it on the top of your assignment. That way everybody knows beforehand if you want to do it that way. Um that's actually all I got. Yeah. [laughter] Okay. Uh let's see. Optimization. Optimization seems trivial. It seems pretty familiar to the whole idea of like root finding and it is related. The magic with optimization comes in a few ways. First of all is constrained optimization. We're going to get to that one kind of at the end of this week. We're going to talk about equality constraints. Inequality constraints are too advanced for this course. It's a it's a higher level course. Um the other part is that uh a lot of optimization
1:39 functions will not be continuous and therefore you can't always rely on gradient methods to get you all the way there. Whereas root finding typically you you do have at least some kind of
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Numerical Methods for Engineering.