Exemplo n.º 1
0
def test_ODE_first_order():
    f = Function('f')
    x, C1 = symbols('x C1')
    assert dsolve(3*f(x).diff(x) -1, f(x)) == x/3 + C1
    assert dsolve(x*f(x).diff(x) -1, f(x)) == log(x) + C1
    assert dsolve(x*f(x).diff(x)+f(x)-f(x)**2,f(x)) == 1/(x*(C1 + 1/x))
    assert dsolve(f(x).diff(x)+x*f(x)-f(x),f(x)) == C1*exp(x - x**2/2)
Exemplo n.º 2
0
def test_ODE_1():
    l = Function('l')
    r = Symbol('r')

    e = Derivative(l(r),r)/r+Derivative(l(r),r,r)/2- \
        Derivative(l(r),r)**2/2
    sol = dsolve(e, [l(r)])
    assert (e.subs(l(r), sol)).expand() == 0

    e = e*exp(-l(r))/exp(l(r))
    sol = dsolve(e, [l(r)])
    assert (e.subs(l(r), sol)).expand() == 0
Exemplo n.º 3
0
def test_ODE_second_order():
    f = Function('f')
    x, C1, C2 = symbols('x C1 C2')
    assert dsolve(Derivative(f(x),x,x) + 9*f(x), [f(x)]) in \
        [sin(3*x)*C1 + cos(3*x)*C2, sin(3*x)*C2 + cos(3*x)*C1]
Exemplo n.º 4
0
def test_ODE_second_order():
    f = Function('f')
    x, C1, C2 = map(Symbol, ['x', 'C1', 'C2'])
    assert dsolve(Derivative(f(x),x,x) + 9*f(x), [f(x)]) in \
        [sin(3*x)*C1 + cos(3*x)*C2, sin(3*x)*C2 + cos(3*x)*C1]
Exemplo n.º 5
0
def test_ODE_first_order():
    f = Function('f')
    x = Symbol('x')
    assert dsolve(3*f(x).diff(x) -1, f(x)) == x/3 + Symbol("C1")
    assert dsolve(x*f(x).diff(x) -1, f(x)) == log(x) + Symbol("C1")
    assert dsolve(x*f(x).diff(x)+f(x)-f(x)**2,f(x)) == 1/(x*(Symbol("C1") + 1/x))