Skip to content
DeepForgeby svx
All problems
EasyCalculusca-110

Noether Conserved Quantity Check

Problem

For a 1D conservative system with L = 0.5*m*v^2 - 0.5*k*x^2, time-translation symmetry yields the conserved energy:

E = 0.5*m*v^2 + 0.5*k*x^2

Given m, k, x, and v, return E.

Hint

Add the kinetic and potential energies; the sign on the potential flips relative to the Lagrangian.

Test cases

case 1
in: [1,1,1,0]
expected: 0.5
case 2
in: [2,4,0,3]
expected: 9
case 3
in: [1,1,0,0]
expected: 0
case 4
in: [1,2,3,4]
expected: 17
case 5
in: [2,1,-1,-2]
expected: 4.5
Starter codePython
def conserved_energy(m, k, x, v):
    # Your code here
    pass

5 test cases · run your code against them in the editor