# Setting the conditions at t=0 for laplace transform with sage (instead of maxima)

Hallo, I am trying to calculate the laplace transform for the following differential equation with sage instead of maxima. "m'diff(x_f(t)+x_d(t),t,2)+d'diff(x_d(t),t,1)+c*x_d(t)+Fext(t)=0"

But I do not find how to set the values in sage at t=0 for the functions x_d(t) and x_f(t). Before I did set it with maxima with  maxima.eval("atvalue(x_d(t), t=0, 0)$atvalue('diff(x_d(t),t), t=0, 0)$"); maxima.eval("atvalue(x_f(t), t=0, 0)$atvalue('diff(x_f(t),t), t=0, 0)$"); 

Basically, I am trying to use the sage laplace transfrom function instead of the sage-maxima function resulting in a nicer notebook without all the maxima.eval add maxima.-commands. I know that sage is using maxima for the transformation in the background.

BR Howil

edit retag close merge delete

Sort by » oldest newest most voted

You can use desolve_laplace to do this. The initial conditions are given as ics=[0,1,7] meaning $y(0)=1$ and $y'(0)=7$.

var('y,t,s')
y=function('y',t)
ode=diff(y,t,2)-6*diff(y,t)-27*y==0
desolve_laplace(ode,y,ics=[0,1,7])


For teaching purposes, II've often not set the conditions up front, but will substitute for them later in the computation. For example,

var('y,t,s')
y=function('y',t)
ode=diff(y,t,2)-6*diff(y,t)-27*y==0
transformed=laplace(ode,t,s)
ans=solve(transformed,laplace(y,t,s))
f=ans.rhs()
y0=1
yprime0=7
f=f.subs(y(t=0)==y0)
f=f.subs(diff(y,t)(t=0)==yprime0)
inverse_laplace(f,s,t)

more

Thank you calc314, that was exactly what I was looking for.