Euler-Lagrange Equation
Euler-Lagrange Equation
The calculus of variations asks: which function extremizes the functional
where is the Lagrangian density? The answer is the Euler-Lagrange equation:
Classic Examples
Shortest path: . The E-L equation gives , i.e., a straight line.
Brachistochrone: The curve of fastest descent under gravity is a cycloid, found by minimizing the travel time functional.
Simple pendulum: The Lagrangian gives the equation of motion:
In the small-angle approximation (), this becomes simple harmonic motion with angular frequency .
Pendulum Period
The small-angle period is:
The small-angle solution is .
Numerical Action
Given discrete sample points , approximate numerically:
- Estimate (forward difference).
- Evaluate at the midpoint of each interval.
- Sum: .
Your Task
Implement action(L_func, y_values, x_values) using the midpoint-rectangle rule above. Implement pendulum_period_s(l_m, g=9.81) for the small-angle period. Implement pendulum_angle_rad(t_s, theta0_rad, l_m, g=9.81) for the small-angle trajectory .
All constants must be computed inside the function bodies.