Session 4: Optimization – Making Math Decide
Discuss
Aero engineers optimize (e.g., best wing shape). Tie to Ukubona: "Like personalizing risk models."
Code
from scipy.optimize import minimize_scalar
import numpy as np
def objective(angle):
return -np.sin(angle) # Maximize sine for range (simplified)
res = minimize_scalar(objective, bounds=(0, np.pi/2), method='bounded')
print(f'Optimal angle: {np.rad2deg(res.x):.2f} degrees')
Use scipy.optimize to find max range for a trajectory (e.g., ideal launch angle).
Excite
Run "what if" loops—graph how fuel changes affect distance.
Homework
Optimize for a constraint (e.g., max altitude under weight).