Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 3780 by insertin...@gmail.com: Error in dsolve, possibly from
separatevars.
http://code.google.com/p/sympy/issues/detail?id=3780
The following raises a key error:
import sympy as sy
x=sy.symbols('x')
f=sy.Function('f')
eq=sy.Eq(sy.Derivative(f(x),x,2)-2*sy.Derivative(f(x),x)+f(x),sy.sin(x))
sy.dsolve(eq)
The equivalent
sy.dsolve(sy.Derivative(f(x),x,2)-2*sy.Derivative(f(x),x)+f(x)-sy.sin(x))
does not. From the traceback it appears that when dsolve tries the method
of undetermined coefficients, it ends up calling
sympy.simplify.separatevars which returns an incorrect intermediate value
when passed an Equation instead of an expression. I am using the latest
version of sympy off of Github.
The traceback is:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-1-dd906d09c7e7> in <module>()
3 f=sy.Function('f')
4
eq=sy.Eq(sy.Derivative(f(x),x,2)-2*sy.Derivative(f(x),x)+f(x),sy.sin(x))
----> 5 sy.dsolve(eq)
c:\Python27\lib\site-packages\sympy\solvers\ode.py in dsolve(eq, func,
hint, simplify, **kwargs)
477 # The key 'hint' stores the hint needed to be solved for.
478 hint = hints['hint']
--> 479 return _helper_simplify(eq, hint, hints, simplify)
480
481 def _helper_simplify(eq, hint, match, simplify=True):
c:\Python27\lib\site-packages\sympy\solvers\ode.py in _helper_simplify(eq,
hint, match, simplify)
497 # attempt to solve for func, and apply any other hint
specific
498 # simplifications
--> 499 rv = odesimp(solvefunc(eq, func, order, match), func,
order, hint)
500 return rv
501 else:
c:\Python27\lib\site-packages\sympy\solvers\ode.py in
ode_nth_linear_constant_coeff_undetermined_coefficients(eq, func, order,
match)
3124 returns='both')
3125 match.update(gensol)
-> 3126 return _solve_undetermined_coefficients(eq, func, order, match)
3127
3128
c:\Python27\lib\site-packages\sympy\solvers\ode.py in
_solve_undetermined_coefficients(eq, func, order, match)
3209 for i in Add.make_args(eqs):
3210 s = separatevars(i, dict=True, symbols=[x])
-> 3211 coeffsdict[s[x]] += s['coeff']
3212
3213 coeffvals = solve(coeffsdict.values(), coefflist)
KeyError: 2*(_a0*sin(x) - _a1*cos(x)) == sin(x)
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.