from sympy import (Symbol, Function, Derivative, Eq, cos, sin)
from sympy.calculus.euler import euler_equations

def test_euler_pendulum():
    x = Function('x')
    t = Symbol('t')
    L = (x(t).diff(t))**2/2 + cos(x(t))
    assert euler_equations(L, x(t), t) == \
        set([Eq(-sin(x(t)) - Derivative(x(t), t, t), 0)])


def test_euler_henonheiles():
    x = Function('x')
    y = Function('y')
    t = Symbol('t')
    L = sum((z(t).diff(t))**2/2 - z(t)**2/2 for z in [x, y])
    L += -x(t)**2*y(t) + y(t)**3/3
    assert euler_equations(L, [x(t), y(t)], t) == \
        set([Eq(-x(t)**2 + y(t)**2 - y(t) - Derivative(y(t), t, t), 0),
             Eq(-2*x(t)*y(t) - x(t) - Derivative(x(t), t, t), 0)])


def test_euler_sineg():
    psi = Function('psi')
    t = Symbol('t')
    x = Symbol('x')
    L = (psi(t, x).diff(t))**2/2 - (psi(t, x).diff(x))**2/2 + cos(psi(t, x))
    assert euler_equations(L, psi(t, x), [t, x]) == \
        set([Eq(-sin(psi(t, x)) - Derivative(psi(t, x), t, t) + \
             Derivative(psi(t, x), x, x), 0)])

@@ -71,45 +71,456 @@
 mpy.
-calculus.euler import euler_equations
+utilities.pytest import raises%0Afrom sympy.calculus.euler import euler_equations%0A%0Adef test_euler_interface():%0A    x = Function('x')%0A    y = Symbol('y')%0A    t = Symbol('t')%0A    raises(TypeError, lambda: euler_equations())%0A    raises(TypeError, lambda: euler_equations(x(t).diff(t)*y(t), %5Bx(t), y%5D))%0A    raises(ValueError, lambda: euler_equations(x(t).diff(t)*x(y), %5Bx(t), x(y)%5D))%0A    raises(TypeError, lambda: euler_equations(x(t).diff(t)**2, x(0)))%0A
 %0A%0Ade

Test euler_equations interface