On Thu, Jun 16, 2011 at 5:58 AM, Nin <[email protected]> wrote:
> Hi everybody,
>
> To become familiar with ODEs with Sage, I am trying to solve a very simple
> ODE with the Laplace method implemented in Sage
> In concrete, i want to solve
> dy(t)/dt = -k*y(t)
>
> with for example, initial conditions y(0)=1
>
> For that:
>
>>>> t = var('t')
>>>> k = var('k')
>>>> y = function('y',t)
>
>>>> myODE = diff(y,t)+k*y==0
>>>> mysol = desolve_laplace(de=myODE, ivar=t, dvar=y, ics=[1,0])
>
> mysol gets the value:
>>>> e^(-k*t)*y(0)
>
> Works fine, but I am not able to set the initial condition y(0) to 1. The

You meant

sage: t = var('t')
sage: k = var('k')
sage: y = function('y',t)
sage: myODE = diff(y,t)+k*y==0
sage: desolve_laplace(de=myODE, ivar=t, dvar=y, ics=[0,1])
e^(-k*t)

You can type type desolve_laplace? for more details on the syntax.


> documentation say that the argument "ics" is a list of numbers which
> correspond the solution to the function when the independent value is zero.
> Am i missing something???
>
> I would like to obtain the solution in the form
>
>>> mysol(t) = e^(-k*t)
>
> So that I can plot the solution with different values of k
>
>>>> fig1 = plot(mysol.subs(k=1/5.), 0, 10)
>>>> fig2 = plot(mysol.subs(k=1/2.), 0, 10)
>
> Of course, for more complex ODEs
>
> Thanks a lot in advance.
>
> Nin
>
> --
> 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/sage-support
> URL: http://www.sagemath.org
>

-- 
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/sage-support
URL: http://www.sagemath.org

Reply via email to