On Aug 20, 2009, at 4:20 PM, Vinzent Steinberg wrote:

> Interesting behavior (not very creative, but hey, I'm an ODE noob):
>
> >>> dsolve(f-f.diff(x, 1), f)
> f(x) == exp(C1 + x)
> >>> dsolve(f-f.diff(x, 2), f)
> f(x) == C1*exp(x) + C2*exp(-x)
> >>> dsolve(f-f.diff(x, 3), f)
> f(x) == C1*exp(x) + (C2*sin(x*3**(1/2)/2) + C3*cos(x*3**(1/2)/ 
> 2))*exp(-x/2)
> >>> dsolve(f-f.diff(x, 5), f)
> f(x) == C1*exp(-x/4 + x*5**(1/2)/4)*sin(x*(5/8 + 5**(1/2)/8)**(1/2))  
> + C2*exp(-x/4 + x*5**(1/2)/4)*sin(x*(5/8 + 5**(1/2)/8)**(1/2)) +  
> C3*exp(-x/4 - x*5**(1/2)/4)*sin(x*(5/8 - 5**(1/2)/8)**(1/2)) +  
> C4*exp(-x/4 - x*5**(1/2)/4)*sin(x*(5/8 - 5**(1/2)/8)**(1/2)) +  
> C5*exp(x) + C6*cos(x*(5/8 + 5**(1/2)/8)**(1/2))*exp(-x/4 +  
> x*5**(1/2)/4) + C7*cos(x*(5/8 + 5**(1/2)/8)**(1/2))*exp(-x/4 +  
> x*5**(1/2)/4) + C8*cos(x*(5/8 - 5**(1/2)/8)**(1/2))*exp(-x/4 -  
> x*5**(1/2)/4) + C9*cos(x*(5/8 - 5**(1/2)/8)**(1/2))*exp(-x/4 -  
> x*5**(1/2)/4)
When you have an ode of the form a_n*f^(n) + a_n-1*f^(n-1) + ...  
a_1*f' + a_0*f = 0, where a_i is constant for all i, the solution is  
based on the roots of the characteristic equation a_n*m**n +  
a_n-1*m**(n-1) + ... + a_1*m + a_0 = 0.  So you are getting that crazy  
result because
of the result of solve(-x**5 + 1, x), as well as doing re() and im()  
on the roots.

> Don't know whether it makes sense to add this trivial special case.
I don't see how that is a special case, but I don't like adding  
special cases anyway.  I think that every ode that you want it to  
solve should be done with a general method.  That way the code is  
cleaner and more robust.  For example, we used to have a special case  
code (see ODE_1 in the current master), but I replaced it with the  
Liouville ODE method, and now it can do more and is much cleaner.
> The other ODEs I "invented" were mostly not solvable. :(
>
> Do you think solve should recognize ODEs?
>
> >>> dsolve(f-f.diff(x), f)
> f(x) == exp(C1 + x)
> >>> solve(f-f.diff(x), f)
> [0]
>
solve() should stick to algebraic solving, because sometimes you want  
to actually solve for f.  I wonder though if it should return  
f.diff(x) in that second one.  Every CAS that I know of has a separate  
solver for algebraic solving and differential equation solving.

Aaron Meurer
> Vinzent
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to