All problems
Euler-Lagrange Acceleration
Problem
For the Lagrangian density F(y, y', x) = a*y'^2 + b*y^2 + c*y*x, the Euler-Lagrange equation requires the x-derivative of 2*a*y' to equal 2*b*y + c*x.
Solving for the acceleration gives y'' = (2*b*y + c*x) / (2*a). Given a != 0, b, c, the current value y, and the coordinate x, return y''.
Hint
The Euler-Lagrange equation balances d/dx of the momentum against the force term.
Test cases
case 1
in: [1,0,0,5,3]
expected: 0
case 2
in: [1,1,0,2,0]
expected: 2
case 3
in: [2,1,3,1,2]
expected: 2
case 4
in: [1,0,4,0,1]
expected: 2
Starter codePython
def euler_lagrange_acceleration(a, b, c, y, x):
# Your code here
pass4 test cases · run your code against them in the editor