Ask Your Question
0

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

asked 2015-12-20 16:56:36 +0100

howil gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-21 01:49:12 +0100

calc314 gravatar image

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[0].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)
edit flag offensive delete link more

Comments

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

howil gravatar imagehowil ( 2015-12-23 09:19:49 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-12-20 16:56:36 +0100

Seen: 821 times

Last updated: Dec 21 '15