Thanks!  It worked!  Now I'm trying to get used to the 'ics' conditions
syntax I guess it makes sense but it is kind of hard to write.

Thanks a lot.

-Filipe


On Sat, Mar 8, 2014 at 9:52 PM, Aaron Meurer <[email protected]> wrote:

> This is in some sense a bug. The solution is correct mathematically.
> The biggest issue with it is actually that there are four constants,
> not two. This is because the solver currently outputs four terms and
> relies on the constant simplification to reduce them to two. But the
> terms don't simplify in this case because they are so complicated.
>
> If you want something simpler, you should assume that f is real, like
>
> f = symbols('f', real=True)
>
> If you do that, you will get
>
> In [8]: print(dsolve(d2udt2, u(t)))
> u(t) == C1*sin(t*Abs(f)) + C2*cos(t*Abs(f))
>
> if you don't like the Abs you can assume f is positive instead.
>
> Ideally, dsolve would return a solution in terms of complex
> exponentials in these sorts of cases, which would be a lot less
> complicated.  Any potential GSoC students out there, especially those
> interested in the ODE module, this is a nice little project for your
> patch requirement.
>
> Aaron Meurer
>
> On Sat, Mar 8, 2014 at 2:24 PM, Filipe Pires Alvarenga Fernandes
> <[email protected]> wrote:
> > Hi,
> > I'm new to sympy and I'm trying to understand how to use dsolve.  (I'm
> > creating an ipython notebook for a class.)
> >
> > I'm creating my DE like this:
> > de = Eq(u(t).diff(t, t) + 4*u(t), 0)
> > print(de)
> >
> > 4*u(t) + Derivative(u(t), t, t) == 0
> >
> >
> > soln = dsolve(de, u(t))
> > print(soln)
> >
> > u(t) == C1*sin(2*t) + C2*cos(2*t)
> >
> >
> > So far now everything is perfect.  But if I try to change the number 4
> for a
> > "generic" symbol (f**2) I do not get
> >
> > u(t) == C1*sin(f*t) + C2*cos(f*t) as I expected, insted I get a more
> > "comprehensive" solution below.
> >
> >
> > What am I doing wrong?
> >
> >
> >>>> d2udt2 = Eq(u(t).diff(t, t) - f*(-f*u(t)), 0)
> >>>> print(d2udt2)
> > f**2*u(t) + Derivative(u(t), t, t) == 0
> >
> > u(t) == (C1*sin(t*((-re(f)**2 + im(f)**2)**2 +
> > 4*re(f)**2*im(f)**2)**(1/4)*Abs(sin(atan2(-2*re(f)*im(f), -re(f)**2 +
> > im(f)**2)/2))) + C2*cos(t*((-re(f)**2 + im(f)**2)**2 +
> > 4*re(f)**2*im(f)**2)**(1/4)*sin(atan2(-2*re(f)*im(f), -re(f)**2 +
> > im(f)**2)/2)))*exp(-t*((-re(f)**2 + im(f)**2)**2 +
> > 4*re(f)**2*im(f)**2)**(1/4)*cos(atan2(-2*re(f)*im(f), -re(f)**2 +
> > im(f)**2)/2)) + (C3*sin(t*((-re(f)**2 + im(f)**2)**2 +
> > 4*re(f)**2*im(f)**2)**(1/4)*Abs(sin(atan2(-2*re(f)*im(f), -re(f)**2 +
> > im(f)**2)/2))) + C4*cos(t*((-re(f)**2 + im(f)**2)**2 +
> > 4*re(f)**2*im(f)**2)**(1/4)*sin(atan2(-2*re(f)*im(f), -re(f)**2 +
> > im(f)**2)/2)))*exp(t*((-re(f)**2 + im(f)**2)**2 +
> > 4*re(f)**2*im(f)**2)**(1/4)*cos(atan2(-2*re(f)*im(f), -re(f)**2 +
> > im(f)**2)/2))
> >
> >
> > Thanks,
> >
> > -Filipe
> >
> > --
> > 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 http://groups.google.com/group/sympy.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/sympy/1395f3d9-f6ea-4167-bc0c-3a9b7e1e1e5d%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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BKeqD5E8oghS0fw%2BxSzpG%3D94PSOv0LN%2BAfNYcSqZR9Xg%40mail.gmail.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 http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAH2VmmDQkAQcWSfH9DnTCy%2BZTEf3EG9T_JmsUVSor4ovtUikQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to