ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 28 Nov 2018 07:39:21 +0100I'm trying to substitute a value in a Laplace transformhttps://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/ Hello, I'm trying to solve a DE by using Laplace transforms, but when I get the lapalce transfrom of my DE I get this part s*D[0](y)(0) and I don't know how can I substitute D[0], I tried D[0](y)(0) == -1) but I get an error that says that D is not defined, I can subs y(0) == 1 with no issues. So my question is how can I substitute the value for y'(0)=-1 in the Laplace transform.
thank you for your help !.
t = var('t')
s = var('s')
y = function('y')(t)
ED = diff(y,t,2)-2*diff(y,t)-3*y==4
ED_Lap = ED.laplace(t,s)
ED_Lap = solve(ED.laplace(t,s),laplace(y(t), t, s))
print(ED_Lap)
show(ED_Lap[0].rhs().subs(y(0)==1,D[0](y)(0)==-1).inverse_laplace(s,t)) # I don't know how to subs DTue, 27 Nov 2018 06:09:05 +0100https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/Answer by slelievre for <p>Hello, I'm trying to solve a DE by using Laplace transforms, but when I get the lapalce transfrom of my DE I get this part s*D<a href="y">0</a>(0) and I don't know how can I substitute D[0], I tried D<a href="y">0</a>(0) == -1) but I get an error that says that D is not defined, I can subs y(0) == 1 with no issues. So my question is how can I substitute the value for y'(0)=-1 in the Laplace transform.</p>
<p>thank you for your help !.</p>
<pre><code>t = var('t')
s = var('s')
y = function('y')(t)
ED = diff(y,t,2)-2*diff(y,t)-3*y==4
ED_Lap = ED.laplace(t,s)
ED_Lap = solve(ED.laplace(t,s),laplace(y(t), t, s))
print(ED_Lap)
show(ED_Lap[0].rhs().subs(y(0)==1,D[0](y)(0)==-1).inverse_laplace(s,t)) # I don't know how to subs D
</code></pre>
https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/?answer=44475#post-id-44475In fact, `D[0](y)` is one way to represent `diff(y, t)`.
So just do:
sage: ED_Lap[0].rhs().subs(y(0)==1,diff(y, t)(0)==-1).inverse_laplace(s,t)
1/3*e^(3*t) + 2*e^(-t) - 4/3
Tue, 27 Nov 2018 19:30:25 +0100https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/?answer=44475#post-id-44475Comment by bemol for <p>In fact, <code>D[0](y)</code> is one way to represent <code>diff(y, t)</code>.</p>
<p>So just do:</p>
<pre><code>sage: ED_Lap[0].rhs().subs(y(0)==1,diff(y, t)(0)==-1).inverse_laplace(s,t)
1/3*e^(3*t) + 2*e^(-t) - 4/3
</code></pre>
https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/?comment=44477#post-id-44477Thank you very much for your time. Now it works !! :DTue, 27 Nov 2018 20:39:45 +0100https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/?comment=44477#post-id-44477Comment by slelievre for <p>In fact, <code>D[0](y)</code> is one way to represent <code>diff(y, t)</code>.</p>
<p>So just do:</p>
<pre><code>sage: ED_Lap[0].rhs().subs(y(0)==1,diff(y, t)(0)==-1).inverse_laplace(s,t)
1/3*e^(3*t) + 2*e^(-t) - 4/3
</code></pre>
https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/?comment=44482#post-id-44482Glad this helped. Please formally accept the answer by clicking the "accept" button (the one with a tick sign). This way the question will be marked as solved in the list of questions.Wed, 28 Nov 2018 07:39:21 +0100https://ask.sagemath.org/question/44466/im-trying-to-substitute-a-value-in-a-laplace-transform/?comment=44482#post-id-44482