P01.09 · Lesson 09 of 18
Gradients, Directional Derivatives & Optimization
The gradient points uphill. Everything else in optimization is deciding how far to walk the other way.
Build it Minimum-drag speed by gradient search
- Learning outcomes
- Derive the gradient of the drag of an aircraft in level flight with respect to speed and aspect ratio, the directional derivative, the Hessian and the second-derivative test, the unconstrained optimum in closed form, and the Lagrange-multiplier solution of minimum drag subject to lift equals weight.
- Implement and test steepest descent and Newton's method with analytic and finite-difference gradients and Hessians, and compare them with
scipy.optimize.minimize. - Measure, by computational experiment, how the step size and the scaling of the variables change the number of iterations, and relate it to the Hessian's eigenvalues.
- Decide, from the Lagrange multiplier, what a newton of extra weight costs in drag, and from the span constraint what a metre of span is worth.
- Prerequisites
P01.08(partial derivatives, tangent plane),P01.07(dot product, projection),P01.02(Newton's method, optimization in one variable),P00.09(SymPysolve). Skill check: you can find the minimum of by setting a derivative to zero, and you know what the eigenvalues of a symmetric matrix are.- Engineering question
At what cruise speed and with what wing aspect ratio does a light aircraft have the least drag, when a higher aspect ratio reduces induced drag but makes the wing heavier; and how much drag does each extra newton of weight, or each metre of span, buy or cost?
Full lesson specification (11 more items)
- Assumptions and limits
Steady level flight (lift equals weight); the parabolic drag polar with and constant , ; incompressible flow; a wing-weight surrogate that stands in for a structural analysis; fixed wing area. The surrogate is the weakest link: real wing weight depends on span, loading, taper and materials, and here is chosen so the optimum lands in a plausible place, not derived. The drag polar fails above Mach 0.3, near stall, and for that varies with Reynolds number. Minimum drag is the right objective for maximum glide range and for the maximum range of a jet only after a factor of is included; for a piston aircraft maximum range is at a different speed again (Phase 10).
- Analytical work
by hand; directional derivatives and the steepest-descent direction; at fixed weight; and ; the Hessian at the optimum in closed form (, , zero cross term) and the second-derivative test; Lagrange multipliers for subject to in the plane, giving and .
- Computational deliverable
starter/main.py:induced_factor,weight,drag,drag_gradient,gradient_fd,hessian_fd,directional_derivative,classify_critical_point,gradient_descent,newton_minimize,scaled_drag,minimum_drag_speed,optimum_analytic,lagrange_min_drag,lagrange_sympy. Tests prove: parasite and induced parts scale as and ; the analytic gradient equals central differences at second order; the gradient vanishes at where the two drag parts are equal; the directional derivative is maximal along the gradient and zero along the level curve; the analytic optimum is a critical point with a positive-definite Hessian and lower drag than fifty random neighbours; steepest descent and Newton converge to it, Newton quadratically; the Lagrange conditions hold with by finite difference and the SymPy solution matches the closed forms.- Practical activity
computational experiment: iteration count of steepest descent against step size in raw and scaled variables, against the stability limit from the Hessian; and the drag cost of a span limit through the constrained optimum.
- Equipment
None. A computer with the environment from
P00.01.- Safety
None beyond normal computer use.
- Evidence
Completed
main.py, passing tests,drag_landscape.png, the hand calculation of at (35 m/s, AR 6) and of the optimum with its comparison to the code, the step-size table with the Hessian eigenvalues, and the Lagrange interpretation in one paragraph.- Assessment
assessments/phase-01/grading-rubric.md; competencies 1–4. Pass: the gradient, the optimum and the Lagrange conditions derived with every held-fixed variable named; all public tests pass; the hand calculation agrees with the code to four figures; the step-size experiment reports the stability limit with a number and compares it to .- References
@openstax-calculus-volume-3§4.6 "Directional Derivatives and the Gradient" (required-free); §4.7 "Maxima/Minima Problems" (required-free); §4.8 "Lagrange Multipliers" (required-free);@openstax-calculus-volume-3§4.4 "Tangent Planes and Linear Approximations" for the Hessian as the second-order term (supplementary-free).- Extensions
★ Replace the fixed-step descent by a line search that minimises along at each step and compare iteration counts. ★ Minimise (jet range) and (power, piston endurance) instead of and show the three optimum speeds are , and .
- Time
unmeasured
1. The engineering problem
A light aircraft's drag in level flight has two parts. Parasite drag, from skin friction and pressure, grows with the square of the speed. Induced drag, the price of making lift with a finite wing, falls with the square of the speed and is smaller for a wing of higher aspect ratio (span squared over area), because a long slender wing sheds weaker tip vortices. There is therefore a speed of least drag, and the designer can push the drag lower still by stretching the wing. But a longer wing is heavier, and weight raises the lift required and with it the induced drag. Somewhere in the plane of (cruise speed, aspect ratio) the drag is least, and the design team wants that point, how flat the drag surface is around it, and two prices: how many newtons of drag an extra newton of weight costs, and how many a metre of span saves. Those prices decide whether a lighter battery or a longer wing is the better investment.
The mathematics is a function of two variables and its gradient, the vector of partial derivatives from P01.08. The gradient points in the direction of steepest ascent; walking against it is the simplest optimization algorithm there is, and the Hessian, the matrix of second partials, tells us whether a point where the gradient vanishes is a valley bottom, a hilltop or a saddle. Constraints such as "lift must equal weight" are handled by Lagrange multipliers, which not only find the constrained optimum but hand back the price of relaxing the constraint. This lesson is the one-variable optimization of P01.02 grown up, and it is also a preview of Phase 03, where the same algorithms run on functions that cost hours to evaluate.
Success criteria, written before we start: the analytic gradient agrees with central differences to and converges at second order; the optimum found by steepest descent, by Newton's method and by scipy.optimize.minimize agrees with the closed form to ; the Hessian at the optimum is positive definite with the entries predicted in §2.5; and the Lagrange multiplier equals by finite difference to .
2. Understand and derive
2.1 The drag landscape
Assumption 1 (parabolic drag polar): with , the span-efficiency factor (Phase 10 derives from lifting-line theory; here it is given). Assumption 2 (level flight): , so . Then, with ,
Assumption 3 (weight surrogate): . Our aircraft: m², , , N, N, kg/m³. At the wing penalty is 4000 N, a quarter of the total; a crude but not absurd share for a long wing on a small aircraft.
Units of (1): Pa · m² = N for the first term; N²/(Pa · m²) = N²/N = N for the second ✓. A level curve $D = $ const in the plane is a contour of the drag landscape; main() draws them and they look like a tilted valley.
2.2 The gradient
The gradient is the vector of partials (@openstax-calculus-volume-3 §4.6):
Differentiate (1) with AR held fixed (so and are constants):
Now with fixed; and :
The first bracketed term is negative (more AR, less induced drag per unit of lift squared), the second positive (more AR, more weight). Hand calculation at m/s, AR = 6: ; N; Pa; parasite N; induced N; N. N/(m/s). : , N; N. So : at this point both more speed and more aspect ratio reduce drag, and the drag falls fastest in the direction , mostly toward higher AR.
The gradient has two geometric properties that the tests check (§4.6): it is perpendicular to the level curve through the point (moving along a contour changes nothing, so the rate of change in that direction is zero), and its length is the largest rate of change in any direction.
2.3 Directional derivatives
The rate of change of per unit distance in the direction of a unit vector is the directional derivative
the projection of the gradient on the direction (P01.07). It is largest () along the gradient, smallest () against it, and zero perpendicular to it. "Per unit distance" in the plane mixes m/s with a dimensionless number, which is a warning sign we return to in §2.6: depends on the units you chose for the axes, and so does "steepest". At (35, 6): along alone the slope is ; along alone ; along the steepest-descent direction .
2.4 Critical points and the one-variable optimum
A minimum in the interior has (@openstax-calculus-volume-3 §4.7). Set (2) to zero at fixed AR:
At the minimum-drag speed the parasite and induced drags are equal, and , so the best lift-to-drag ratio is . Now minimise over AR: . Its derivative vanishes when , i.e. :
For our numbers , N (the wing penalty is exactly at the optimum, a quarter of the total), , m/s, N, . A 12.9 m span on 16 m² at 1.8 tonnes: a motor-glider.
2.5 The Hessian and the second-derivative test
Whether a critical point is a minimum, a maximum or a saddle is decided by the Hessian, the symmetric matrix of second partials (§4.7):
The second-order Taylor term is (P01.08, equation (8)): the point is a minimum if that quadratic form is positive for every , i.e. if both eigenvalues of are positive; a maximum if both are negative; a saddle if they differ in sign; undecided if one is zero. (The textbook's test is the same statement: the determinant is the product of the eigenvalues.) At our optimum the entries have closed forms. Write with ; , and at , , so N/(m/s)². Along AR, , whose second derivative at (use ) is times the prefactor, giving N. The cross term vanishes at the optimum because is exactly the condition (6). So , both positive: a minimum, and a very shallow one in : moving 5 m/s off costs N, 2 % of the drag.
2.6 Walking downhill: steepest descent and Newton
If you cannot solve by hand, walk: from , step against the gradient,
with a step small enough that decreases (our code halves until it does). For a quadratic bowl with Hessian eigenvalues , (7) converges if and the error shrinks each step by a factor no better than : a long narrow valley (large ) means zig-zagging and thousands of steps. In raw units N, so must be below 0.27 (m/s)²/N and the best fixed step is near 0.1; choosing because "small is safe" costs 6943 iterations where 0.1 costs 74. Scaling the variables, and , makes the step dimensionless and the gradient components comparable; it does not by itself improve the conditioning (here the scaled eigenvalue ratio is 6.6 against 3.8 raw), but it lets you choose without thinking about units, and in a real design code with ten variables of wildly different magnitudes it is the difference between converging and not.
Newton's method uses the Hessian to jump straight to the minimum of the local quadratic model:
the multivariable version of P01.02's Newton step. It converges quadratically near a minimum (six iterations here against 97 for scaled descent) and in one step on an exact quadratic, but each step needs the Hessian, which hessian_fd builds from function evaluations, and it will happily converge to a saddle or a maximum if started badly, since it only seeks . scipy.optimize.minimize with BFGS builds an approximate Hessian from the gradients it has already seen: 14 iterations, no second derivatives.
2.7 Lagrange multipliers: minimum drag subject to lift equals weight
In §2.1 we eliminated the constraint by substituting . The method of Lagrange multipliers (@openstax-calculus-volume-3 §4.8) handles the constraint without eliminating it, in the plane where
At the constrained minimum the level curve of is tangent to the constraint curve, so their gradients are parallel: . Components:
The second gives ; substituting in the first, , so
is exactly of (5), as it must be. The multiplier is the useful extra: , the drag cost of one more newton of weight, and for our aircraft. Each newton of weight costs 0.062 N of drag at the optimum; a 100 N heavier battery costs 6.2 N of drag, 0.6 %. SymPy solves the three equations (9) plus the constraint symbolically and returns the same three expressions, which is a test.
2.8 Where the model stops being valid
- The weight surrogate. encodes "longer wings are heavier" and nothing else. Change by 20 % and moves 10 %. The optimum is only as good as the structural model behind , which is Phase 06's job.
- Constant . A higher-AR wing at fixed area has a smaller chord, a lower Reynolds number and slightly higher skin-friction coefficient; a sweep of with AR would shift the optimum a little toward lower AR.
- Objective. Minimum drag is the maximum-glide-range condition and the maximum-range condition for a piston aircraft; a jet's range is best at minimum and a piston aircraft's endurance at minimum power (Phase 10). The algorithm is identical; only the function changes.
- Discrete reality. Aspect ratio is not continuously adjustable: spars come in sizes, spans must fit hangars (Problem 6), and certification fixes much of .
3. Build the computational model
Open starter/main.py. The aircraft lives in a frozen Aircraft dataclass; drag broadcasts over grids for the contour plot.
Step 1: the function and its gradient
def drag(V, AR, ac=DEFAULT_AIRCRAFT):
q = 0.5 * ac.rho * V**2
return q * ac.S * ac.cd0 + induced_factor(AR, ac) * weight(AR, ac) ** 2 / (q * ac.S) # (1)
def drag_gradient(V, AR, ac=DEFAULT_AIRCRAFT):
K, W = induced_factor(AR, ac), weight(AR, ac)
dK, dW = -K / AR, 2.0 * ac.c_w * AR
q = 0.5 * ac.rho * V**2
dD_dV = ac.rho * V * ac.S * ac.cd0 - 4.0 * K * W**2 / (ac.rho * V**3 * ac.S) # (2)
dD_dAR = (dK * W**2 + 2.0 * K * W * dW) / (q * ac.S) # (3)
return np.array([dD_dV, dD_dAR])
Step 2: gradient and Hessian of anything, by finite differences
def gradient_fd(f, x, h):
g = np.empty_like(x)
for i in range(x.size):
e = np.zeros_like(x); e[i] = h[i]
g[i] = (f(x + e) - f(x - e)) / (2.0 * h[i])
return g
def hessian_fd(f, x, h):
... # diagonal: (f(x+e_i) - 2 f(x) + f(x-e_i)) / h_i**2
... # off-diagonal: (f(++) - f(+-) - f(-+) + f(--)) / (4 h_i h_j), then symmetrise
h may be one step per coordinate, because 1 m/s and 1 unit of AR are not the same size; the tests use [1e-3, 1e-4] for the drag.
Step 3: directions and classification
def directional_derivative(grad, direction):
d = np.asarray(direction, float)
return float(np.dot(grad, d / np.linalg.norm(d))) # (4)
def classify_critical_point(H):
w = np.linalg.eigvalsh(0.5 * (H + H.T))
... # all > 0: "minimum"; all < 0: "maximum"; any ~0: "degenerate"; else "saddle"
Step 4: the two searches
def gradient_descent(f, grad, x0, step=0.1, tol=1e-8, max_iter=10000):
x = x0.copy(); path = [x.copy()]; fx = f(x)
for _ in range(max_iter):
g = grad(x)
if np.linalg.norm(g) < tol: break
s = step
while True: # backtracking: halve s until f decreases
x_new = x - s * g
f_new = f(x_new) # (7); a ValueError (V <= 0) counts as "no good"
if np.isfinite(f_new) and f_new < fx: break
s *= 0.5
x, fx = x_new, f_new; path.append(x.copy())
return x, np.array(path)
def newton_minimize(f, grad, hess, x0, tol=1e-10, max_iter=50):
... # x <- x - solve(hess(x), grad(x)) # (8)
scaled_drag wraps drag and drag_gradient in the dimensionless variables of §2.6 (the chain rule multiplies each gradient component by its reference value). minimum_drag_speed, optimum_analytic, lagrange_min_drag are (5), (6), (10); lagrange_sympy hands the three equations to sp.solve and keeps the positive root.
Verify
Run python -m pytest curriculum/phase-01/lesson-09-gradients-and-optimization from the repo root. The tests, in order of how much they would hurt if wrong:
- The function. Parasite part , induced part and ; zero weight kills the induced part; broadcasting; and raise.
- Gradient three ways. Analytic against central differences at three points, rates above 1.9;
gradient_fdandhessian_fdon against the hand Hessian, symmetric. - Critical points. at for three aspect ratios with parasite = induced and ; negative slope below, positive above; ; the analytic optimum has zero gradient, a positive-definite Hessian classified "minimum", lower drag than fifty random neighbours, , and halves when quadruples; known Hessians classify correctly.
- Directions. is along the gradient, against, 0 along the contour, no larger in fifty random directions, and matches a finite difference along four lines through the point.
- Searches. Scaled descent reaches the optimum to with monotone decrease; descent and Newton solve a quadratic bowl exactly (Newton in one step); Newton on the scaled drag converges in at most 12 iterations with a final error ratio below .
- Lagrange. , and the stationarity conditions (9); by central difference to and ; the SymPy solution equals the closed forms symbolically.
- Interface.
main()writes the figure.
Compare
main() runs the same minimisation five ways:
Analytic optimum: V* = 46.767 m/s, AR* = 10.4083, D* = 1071.696 N (W = 17333 N, L/D = 16.17)
raw-variable descent, step 0.001: 6943 iterations -> V = 46.767, AR = 10.4083, |grad| = 1.9e-05
raw-variable descent, step 0.1: 74 iterations -> V = 46.767, AR = 10.4083, |grad| = 1.0e-06
scaled descent: 97 iterations -> V = 46.767, AR = 10.4083
Newton: 6 iterations -> V = 46.767, AR = 10.4083
Hessian at optimum: [[1.96, 0.0], [0.0, 7.4194]], eigenvalues [1.96 7.41943] -> minimum
scipy.optimize.minimize (BFGS): V = 46.767, AR = 10.4083, 14 iterations
All five agree to the printed digits. scipy.optimize.minimize is the established tool and what you will call in Phase 03 and beyond; BFGS needs no Hessian and takes 14 iterations because it learns the curvature from the gradients it has seen. The point of writing your own descent and Newton steps once is to know what those 14 iterations are doing and why a badly scaled problem can turn 14 into 14 000. The Hessian entries 1.96 and 7.419 match the closed forms and of §2.5 to four figures, and the off-diagonal is zero to , as predicted.
4. Experiment at home, or investigate real data
Mode: computational experiment.
Experiment A: step size and scaling. From run gradient_descent on the raw drag with fixed steps and record the iteration count to . Prediction, written before running: the count falls roughly as until approaches , where the backtracking starts halving steps and the count rises again. Repeat in the scaled variables with (limit ). Tabulate, and compute in both scalings from hessian_fd at the optimum. Then answer: which scaling has the better conditioning, and is "scaled" the same as "well-conditioned"?
Experiment B: the price of span. A hangar limits the span to m, so . Compute at and at , and the slope at the limit (by finite difference of optimum-style evaluation at fixed AR, or from the closed form of §2.5). Convert to newtons of drag per metre of span using . Prediction: the constrained optimum sits on the constraint, the drag penalty is of order 100 N, and each extra metre of span would save of order 60 N. Problem 6 turns this into a second Lagrange multiplier.
Raw data format: two tables, and , kept in your lesson notes.
5. Validate and improve
Hand (§2), code and the library side by side:
| quantity | hand | code | independent check | difference |
|---|---|---|---|---|
| (N) | 1451.9 | 1451.94 | 0 | |
| FD | relative | |||
| 10.41 | 10.4083 | descent 10.4083, Newton 10.4083, BFGS 10.4083 | ||
| (m/s) | 46.77 | 46.767 | all searches 46.767 | |
| (N) | 1071.7 | 1071.696 | 0 | |
| diag(1.96, 7.42) | diag(1.96, 7.419), off-diag | closed forms §2.5 | ||
| 0.0618 | 0.061829 | FD 0.061829; |
Every residual has a cause. The on the gradient is the truncation of the central difference with m/s and in AR. The on the searches is the stopping tolerance on , not an error in the optimum: a gradient of in scaled units corresponds to a position error of about , and the test asks for relative. The off-diagonal Hessian entry is rather than 0 because the finite-difference optimum is itself off by and the cross term grows linearly away from it.
What is still unverified when everything agrees: the model. Five algorithms finding the same minimum of the same function proves the arithmetic, not that an aspect ratio of 10.4 is the right wing for this aircraft. That depends on , which we invented, on and , which Phase 10 computes, and on what the aircraft is for: minimum drag is the glide-range optimum and not the fuel-burn optimum. A sensitivity sweep of against (it goes as ) is the honest companion to the optimum, and it costs one line.
Improvements worth making: a line search along (extension), which removes the step-size guess entirely; a trust region around the Newton step so it cannot leap to a saddle. Improvements worth not making: tightening the tolerance below on a function whose inputs are known to two figures.
6. Defend your work
Submit: the completed starter/main.py with all tests passing; drag_landscape.png; the hand calculation of at (35, 6), of the optimum and of with the comparison table; the two experiment tables with one paragraph each; and a one-page note (sections 1, 2, 5, 6 and 7 of projects/_template/report-template.md) stating what the drag model and the weight surrogate assume and what means for the design.
Adversarial self-checks
- What if the weight doubles? At fixed AR, rises by 41 % and doubles; is unchanged. In the surrogate, doubling raises by 41 %. Check both with
optimum_analytic(Aircraft(W0=26000)). - What if ? What if ? With no weight penalty : the surrogate is what makes the problem well posed. With no parasite drag, and : induced drag alone has no interior minimum in . Both are limits the code must handle without
nan, andminimum_drag_speedraises rather than dividing by zero. - Which assumption fails first in the real world? The weight surrogate, always: a real wing's weight scales roughly with span cubed divided by chord, with load factor and with material, and hides all of that.
- What measurement could falsify the model? A glide test gives and directly; if the measured differs from (5) by more than 5 %, either or is wrong, and the two are separable because and .
- Does the result survive a change in solver? Steepest descent, Newton and BFGS must agree to ; if they do not, one of them has stopped at a saddle (check the Hessian) or has hit the domain boundary (, caught by the
ValueError). - Which decision changes if the uncertainty doubled? Suppose is uncertain by ±40 % instead of ±20 %. is then instead of , but the drag surface is so flat near the optimum ( N) that an AR anywhere between 8 and 13 costs under 30 N (3 %). The decision that changes is not the wing but the structures programme: with ±40 % on the first thing to fund is a better weight model, because that is where the 3 % lives.
Check yourself
- Write for with and say in words what each component measures.
- At the minimum-drag speed, what is the ratio of parasite to induced drag?
- The directional derivative of along is . In which direction is it zero, and what does that say about the gradient and the level curves?
- A critical point has Hessian eigenvalues and . What kind of point is it, and what does the determinant test give?
- Why does steepest descent with a fixed step diverge when the step exceeds ? (Think of a one-variable parabola .)
- State the Lagrange condition for minimising subject to and the meaning of .
- At the lesson's optimum, . How much drag does a 50 N heavier instrument panel cost, and what is ?
- Newton's method converged in 6 iterations and steepest descent in 97. Name one reason to prefer steepest descent anyway.
Problem set
Attempt every problem before opening solutions/. Record what you tried. State units on every numerical answer, and for every gradient say which variables it is taken with respect to and in what units.
Several problems use your personal seed s: the day of the month you were born (1–31). kg/m³ unless stated.
1. (Warm-up: minimum drag at fixed weight)
A fixed-weight aircraft has N, m², , and a wing of aspect ratio 8 that is not going to change. Model it as Aircraft(S=14, cd0=0.028, e=0.8, W0=W, c_w=0.0).
Find: (a) , the minimum-drag speed , and ; (b) the lift coefficient at and a check that it equals ; (c) at , the drag, its parasite and induced parts, and the gradient with units; (d) the directional derivative of at that point along the direction in the plane, and the largest directional derivative available there. Check everything against minimum_drag_speed, drag, drag_gradient and directional_derivative. Answer form: numbers with units, four significant figures.
2. (Derivation: the drag landscape in closed form)
For of equation (1) with and :
(a) Derive both components of , equations (2) and (3), naming the variable held fixed in each. (b) Show that at the parasite and induced drags are equal and . (c) Minimise over AR and show ; show the wing penalty is exactly . (d) Show that at the optimum , and , and evaluate all three for the lesson's aircraft. Apply the second-derivative test. (e) In the plane, set up with and derive and . Then show directly, by differentiating with respect to , that .
Answer form: derivations; (d) with numbers.
3. (Unfamiliar scenario: a glider hunting a thermal)
A thermal's updraft near the ground is modelled as m/s with m/s and m, east and north of the core. A glider is at m flying on a heading of north-east.
(a) Compute , and at the glider, with units. In which compass direction does the updraft increase fastest, and at what rate per metre? (b) Compute the directional derivative of along the glider's current heading. Is it climbing into stronger or weaker lift? (c) Which way, and by how many degrees, should the pilot turn to follow the steepest ascent? Why is this not the same as "turn toward the core"? (It is, here; explain why, and give a field for which it would not be.) (d) Compute the Hessian of at the core and at the glider. Classify both points. Why is the glider's position neither a maximum nor a critical point and yet has a Hessian with eigenvalues of opposite sign? (e) A real pilot cannot measure ; the variometer reads alone. Describe, in one paragraph, how circling lets the pilot estimate the direction of the gradient from a scalar reading, and what the directional derivative has to do with it.
Answer form: numbers with units; (c) and (e) in words.
4. (Uses your code: step size, scaling and conditioning)
Using gradient_descent from on the lesson's aircraft with tol=1e-6:
(a) Record the iteration count for fixed steps in raw variables. Plot count against on log–log axes.
(b) Repeat with scaled_drag (variables , , drag in kN) for and tol=1e-9.
(c) Compute the Hessian at the optimum in both scalings with hessian_fd, its eigenvalues, the condition number and the stability limit . Mark the limit on each plot. Explain why the count first falls as , and what happens at and above the limit given that the code halves the step when the function fails to decrease.
(d) The scaled problem has the worse condition number. Explain why scaling was still worth doing, and propose a scaling (different reference values) that makes the scaled Hessian's condition number exactly 1. Verify it.
(e) Run newton_minimize from the same start and report the sequence of values. Fit the convergence order from the last three.
Answer form: two tables, two plots, the Hessian numbers, and a paragraph for (c)–(d).
5. (Judgment: is the optimum worth having?)
The lesson's optimum is , m/s, N. Suppose the wing-weight coefficient is uncertain by ±20 % and by ±10 %.
(a) Propagate both uncertainties into and , using the closed forms (the log-derivative trick of P01.08 Problem 3 is enough).
(b) Evaluate at and and compare with . Given (a), is there any engineering content in the second decimal place of ?
(c) The structures group says each unit of AR above 9 adds €4000 to the wing's cost. Each newton of cruise drag costs €15 over the aircraft's life in fuel. Where is the cost optimum? Set it up as a one-variable problem and solve it by Newton's method or scipy.optimize.minimize_scalar.
(d) Write five sentences for a design review: the recommended AR, the two numbers that drive it, the one uncertainty that matters most, and the measurement that would reduce it.
Answer form: numbers for (a)–(c), prose for (d).
6. (Unfamiliar scenario: a hangar door as a constraint)
The aircraft of the lesson must fit a hangar with a 10 m door, so the span is limited to m; with m², .
(a) Compute the constrained optimum: and at , and the weight. By how many newtons does the door cost the aircraft in drag, compared with ? (b) Compute at the limit, by finite difference and from the closed form of Problem 2(c), and convert it to newtons per metre of span. (c) Set the problem up as subject to , write the Lagrange condition at the active constraint, and identify the multiplier with (b). What is the sign of the multiplier, and what does that sign mean? (d) A folding wing-tip adds 0.5 m of span per side (so m) at a cost of 150 N of weight ( N). Using only the two multipliers you now have ( and ), estimate whether it pays. Then compute the exact answer and compare.
Answer form: numbers with units; (c) a short derivation.
Get the code
Clone the repository once, write your code in starter/main.py, then run the tests from the repository root.
pytest curriculum/phase-01/lesson-09-gradients-and-optimization
To run the same tests against the reference solution instead:
AEFS_IMPL=solution pytest curriculum/phase-01/lesson-09-gradients-and-optimization
Found a mistake? Every page is built from the Markdown in the repository; edit it on GitHub.