Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2736 by [email protected]: Dsolve failure with Derivative(x*f(x),x)
http://code.google.com/p/sympy/issues/detail?id=2736

Hi

I've searched and not found any existing comments on the following behaviour of dsolve and ode_order in the sympy group, issues or documentation. Sorry if I've missed it...

The documentation examples for dsolve frequently uses input of the form "Derivative(f(x),x)" as in ode1 below. However, dsolve fails if the apparently simple change to "Derivative(x*f(x),x)" is made, as in ode3. This can be fixed by including a "doit()" call.

I'm unsure if this is a code issue (should dsolve contain a call doit()?), or perhaps a documentation issue (i.e. the user should be told to call "doit()" themselves or not use this syntax)?

I've picked up Sympy after a long break. Many thanks for all your efforts. I'm glad to see the project is thriving - I'll be interested in any replies.

Thanks,
Andy

C:\Users\Andrew\Documents\Python>python
Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
from sympy import diff, Derivative, ode_order, Function, dsolve
from sympy.abc import x

f=Function("f")

#Ode 1 uses Derivative on f(x) only and works:
... ode1=Derivative(f(x),x)-1
print dsolve(ode1,f(x))
f(x) == C1 + x

#Ode 2 uses diff on x*f(x) and works:
... ode2=diff(x*f(x),x)-1
print dsolve(ode2,f(x))
f(x) == C1/x + 1

#Ode 3 uses Derivative on x*f(x) and fails:
... ode3=Derivative(x*f(x),x)-1
print dsolve(ode3,f(x))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
File "C:\Users\Andrew\Documents\Python\sympy\sympy\solvers\ode.py", line 422,
in dsolve
raise ValueError(str(eq) + " is not a differential equation in " + str(func)
)
ValueError: Derivative(x*f(x), x) - 1 is not a differential equation in f(x)

#Note ode_order fails for Ode 3.
... print ode_order(ode3,f(x))
0

#Adding .doit() to Ode 3 makes it work:
... print dsolve(ode3.doit(),f(x))
f(x) == C1/x + 1


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to