It looks like the bug has been fixed in SymPy master:

In [94]: print(sympy.dsolve([DE1, DE2], [α(t), β(t)]))
[Eq(\alpha(t), sqrt(2)*\kappa*(C1*sin(sqrt(3)*\kappa*t/2) +
C2*cos(sqrt(3)*\kappa*t/2))*exp(-\kappa*t/2)/2), Eq(\beta(t),
((-C1*\kappa/2 - sqrt(3)*C2*\kappa/2)*sin(sqrt(3)*\kappa*t/2) +
(sqrt(3)*C1*\kappa/2 -
C2*\kappa/2)*cos(sqrt(3)*\kappa*t/2))*exp(-\kappa*t/2))]

Aaron Meurer

On Tue, Aug 16, 2016 at 12:06 PM, Michael Goerz <[email protected]> wrote:
> I'm having a lot of problems trying to solve a system of linear differential
> equations (which somehow looks like it should have an easy solution, but I
> might
> be wrong):
>
>     #!/usr/bin/env python
>     import sympy
>
>     α, β = sympy.symbols(r'\alpha, \beta', cls=sympy.Function)
>     κ = sympy.symbols(r'\kappa', positive=True)
>     t = sympy.symbols(r't', positive=True)
>     c1 = κ / sympy.sqrt(2)
>     c2 = κ * sympy.sqrt(2)
>
>     DE1 = sympy.Eq(α(t).diff(t), c1 * β(t))
>     DE2 = sympy.Eq(β(t).diff(t), -κ * β(t) - c2 * α(t))
>
>     sympy.dsolve([DE1, DE2], [α(t), β(t)], hint='1st_linear')
>     sympy.dsolve([DE1, DE2])
>
> The first attempt gives me a backtrace because it fails to determine the
> order
> for each function when the function names are given explicitly
>
>     Traceback (most recent call last):
>     File "./test_sympy.py", line 14, in <module>
>         sympy.dsolve([DE1, DE2], [α(t), β(t)], hint='1st_linear')
>     File
> "/Users/goerz/anaconda/envs/python34/lib/python3.4/site-packages/sympy/solvers/ode.py",
> line 579, in dsolve
>         match = classify_sysode(eq, func)
>     File
> "/Users/goerz/anaconda/envs/python34/lib/python3.4/site-packages/sympy/solvers/ode.py",
> line 1366, in classify_sysode
>         if not order[func]:
>     KeyError: \alpha(t)
>
> This looks like a bug to me.
>
> The second attempt gives me the following:
>
>     Traceback (most recent call last):
>     File "./test_sympy.py", line 13, in <module>
>         sympy.dsolve([DE1, DE2])
>     File
> "/Users/goerz/anaconda/envs/python34/lib/python3.4/site-packages/sympy/solvers/ode.py",
> line 612, in dsolve
>         sols = solvefunc(match)
>     File
> "/Users/goerz/anaconda/envs/python34/lib/python3.4/site-packages/sympy/solvers/ode.py",
> line 6394, in sysode_linear_2eq_order1
>         sol = _linear_2eq_order1_type1(x, y, t, r)
>     File
> "/Users/goerz/anaconda/envs/python34/lib/python3.4/site-packages/sympy/solvers/ode.py",
> line 6485, in _linear_2eq_order1_type1
>         l1 = RootOf(l**2 - (r['a']+r['d'])*l + r['a']*r['d'] -
> r['b']*r['c'], 0)
>     File
> "/Users/goerz/anaconda/envs/python34/lib/python3.4/site-packages/sympy/polys/rootoftools.py",
> line 70, in __new__
>         raise PolynomialError("only univariate polynomials are allowed")
>     sympy.polys.polyerrors.PolynomialError: only univariate polynomials are
> allowed
>
> Not sure what to do with that.
>
> I'm a little surprised this is so difficult. I was somehow assuming that
> this
> would be a core feature (trying to replace Mathematica with SymPy).
>
> The current documentation on systems of differential equations isn't overly
> helpful :-/
>
> Best,
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/f1d13f21-c43b-4ac6-a75f-f74d0b8376c5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6KhP35YQnm%2Bo4_EdW_78dH5jPsY-75o9qYRBuVuz1Bq9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to