ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 28 Feb 2017 11:22:41 -0600inverse laplace transforms of shiftshttps://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/I've been trying to get Sage to solve an ODE using Laplace transforms. Unfortunately, shifted functions appear to cause a problem for the `inverse_laplace` command. David Joyner's ODE book (dated 2008) says that Sage does not have the functionality to do this. Has this situation changed? Do I need to do something differently here to get this to work?
Here is a snippet of something I tried.
u=piecewise([[(0,3),0],[(3,infinity),exp(-2*(t-3))]],t)
u.laplace(t,s)
inverse_laplace(_,s,t)
The first two lines work properly, but the last line returns a formal result:
ilt(e^(-3*s)/(s + 2), s, t)
Tue, 29 May 2012 10:39:07 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/Answer by mforets for <p>I've been trying to get Sage to solve an ODE using Laplace transforms. Unfortunately, shifted functions appear to cause a problem for the <code>inverse_laplace</code> command. David Joyner's ODE book (dated 2008) says that Sage does not have the functionality to do this. Has this situation changed? Do I need to do something differently here to get this to work?</p>
<p>Here is a snippet of something I tried.</p>
<pre><code>u=piecewise([[(0,3),0],[(3,infinity),exp(-2*(t-3))]],t)
u.laplace(t,s)
inverse_laplace(_,s,t)
</code></pre>
<p>The first two lines work properly, but the last line returns a formal result:</p>
<pre><code>ilt(e^(-3*s)/(s + 2), s, t)
</code></pre>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?answer=36664#post-id-36664A simple implementation using the local `heaviside` function (see also [generalized functions](http://doc.sagemath.org/html/en/reference/functions/sage/functions/generalized.html)) is written in [this question](https://ask.sagemath.org/question/36656/how-to-find-inverse-laplace-transform/), and is such that:
var('t s')
u=piecewise([[(0,3),0],[(3,infinity),exp(-2*(t-3))]], var=t)
F(s) = u.laplace(t,s);
InverseLaplace(F, s, t)
produces $\newcommand{\Bold}[1]{\mathbf{#1}}t \ {\mapsto}\ e^{\left(-2 \, t + 6\right)} H\left(t - 3\right)$.Sun, 19 Feb 2017 14:06:26 -0600https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?answer=36664#post-id-36664Comment by calc314 for <p>A simple implementation using the local <code>heaviside</code> function (see also <a href="http://doc.sagemath.org/html/en/reference/functions/sage/functions/generalized.html">generalized functions</a>) is written in <a href="https://ask.sagemath.org/question/36656/how-to-find-inverse-laplace-transform/">this question</a>, and is such that:</p>
<pre><code>var('t s')
u=piecewise([[(0,3),0],[(3,infinity),exp(-2*(t-3))]], var=t)
F(s) = u.laplace(t,s);
InverseLaplace(F, s, t)
</code></pre>
<p>produces $\newcommand{\Bold}[1]{\mathbf{#1}}t \ {\mapsto}\ e^{\left(-2 \, t + 6\right)} H\left(t - 3\right)$.</p>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=36766#post-id-36766`InverseLaplace` is not currently a built-in function.Tue, 28 Feb 2017 11:22:41 -0600https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=36766#post-id-36766Answer by kcrisman for <p>I've been trying to get Sage to solve an ODE using Laplace transforms. Unfortunately, shifted functions appear to cause a problem for the <code>inverse_laplace</code> command. David Joyner's ODE book (dated 2008) says that Sage does not have the functionality to do this. Has this situation changed? Do I need to do something differently here to get this to work?</p>
<p>Here is a snippet of something I tried.</p>
<pre><code>u=piecewise([[(0,3),0],[(3,infinity),exp(-2*(t-3))]],t)
u.laplace(t,s)
inverse_laplace(_,s,t)
</code></pre>
<p>The first two lines work properly, but the last line returns a formal result:</p>
<pre><code>ilt(e^(-3*s)/(s + 2), s, t)
</code></pre>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?answer=13632#post-id-13632I guess Maxima can't do it.
sage: inverse_laplace?
def inverse_laplace(ex, t, s):
r"""
Attempts to compute the inverse Laplace transform of
``self`` with respect to the variable `t` and
transform parameter `s`. If this function cannot find a
solution, a formal function is returned.
(%i1) display2d:false;
(%o1) false
(%i2) f(s):=%e^(-3*s)/(s+2);
(%o2) f(s):=%e^-(3*s)/(2+s)
(%i4) ilt(f(s),t,s);
(%o4) 'ilt(%e^-(3*s)/(s+2),t,s)
Does that answer things? If you want to file an enhancement request to Maxima, please do, maybe it's not so hard for them to implement; however, presumably there are arbitrarily hard ones like this that no system could do...Tue, 29 May 2012 18:48:02 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?answer=13632#post-id-13632Comment by calc314 for <p>I guess Maxima can't do it.</p>
<pre><code>sage: inverse_laplace?
def inverse_laplace(ex, t, s):
r"""
Attempts to compute the inverse Laplace transform of
``self`` with respect to the variable `t` and
transform parameter `s`. If this function cannot find a
solution, a formal function is returned.
(%i1) display2d:false;
(%o1) false
(%i2) f(s):=%e^(-3*s)/(s+2);
(%o2) f(s):=%e^-(3*s)/(2+s)
(%i4) ilt(f(s),t,s);
(%o4) 'ilt(%e^-(3*s)/(s+2),t,s)
</code></pre>
<p>Does that answer things? If you want to file an enhancement request to Maxima, please do, maybe it's not so hard for them to implement; however, presumably there are arbitrarily hard ones like this that no system could do...</p>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19724#post-id-19724Thanks for the help. It seems like the t-domain shifts and s-domain shifts that we teach in a standard ODE course should be reasonable to implement. Web searches indicate that there are some folks who have implemented their own code in maxima to handle this.Wed, 30 May 2012 10:48:09 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19724#post-id-19724Comment by calc314 for <p>I guess Maxima can't do it.</p>
<pre><code>sage: inverse_laplace?
def inverse_laplace(ex, t, s):
r"""
Attempts to compute the inverse Laplace transform of
``self`` with respect to the variable `t` and
transform parameter `s`. If this function cannot find a
solution, a formal function is returned.
(%i1) display2d:false;
(%o1) false
(%i2) f(s):=%e^(-3*s)/(s+2);
(%o2) f(s):=%e^-(3*s)/(2+s)
(%i4) ilt(f(s),t,s);
(%o4) 'ilt(%e^-(3*s)/(s+2),t,s)
</code></pre>
<p>Does that answer things? If you want to file an enhancement request to Maxima, please do, maybe it's not so hard for them to implement; however, presumably there are arbitrarily hard ones like this that no system could do...</p>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19705#post-id-19705I'm not sure about the robustness of either of the approaches above, but they are interesting.Fri, 01 Jun 2012 17:20:33 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19705#post-id-19705Comment by calc314 for <p>I guess Maxima can't do it.</p>
<pre><code>sage: inverse_laplace?
def inverse_laplace(ex, t, s):
r"""
Attempts to compute the inverse Laplace transform of
``self`` with respect to the variable `t` and
transform parameter `s`. If this function cannot find a
solution, a formal function is returned.
(%i1) display2d:false;
(%o1) false
(%i2) f(s):=%e^(-3*s)/(s+2);
(%o2) f(s):=%e^-(3*s)/(2+s)
(%i4) ilt(f(s),t,s);
(%o4) 'ilt(%e^-(3*s)/(s+2),t,s)
</code></pre>
<p>Does that answer things? If you want to file an enhancement request to Maxima, please do, maybe it's not so hard for them to implement; however, presumably there are arbitrarily hard ones like this that no system could do...</p>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19706#post-id-19706And, this link appears to be for an approach that might be useful upstream: http://www.ma.utexas.edu/pipermail/maxima/2007/008424.htmlFri, 01 Jun 2012 17:19:49 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19706#post-id-19706Comment by calc314 for <p>I guess Maxima can't do it.</p>
<pre><code>sage: inverse_laplace?
def inverse_laplace(ex, t, s):
r"""
Attempts to compute the inverse Laplace transform of
``self`` with respect to the variable `t` and
transform parameter `s`. If this function cannot find a
solution, a formal function is returned.
(%i1) display2d:false;
(%o1) false
(%i2) f(s):=%e^(-3*s)/(s+2);
(%o2) f(s):=%e^-(3*s)/(2+s)
(%i4) ilt(f(s),t,s);
(%o4) 'ilt(%e^-(3*s)/(s+2),t,s)
</code></pre>
<p>Does that answer things? If you want to file an enhancement request to Maxima, please do, maybe it's not so hard for them to implement; however, presumably there are arbitrarily hard ones like this that no system could do...</p>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19707#post-id-19707The following appears to be a deeper patch for maxima: http://comments.gmane.org/gmane.comp.mathematics.maxima.general/33278Fri, 01 Jun 2012 17:18:27 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19707#post-id-19707Comment by kcrisman for <p>I guess Maxima can't do it.</p>
<pre><code>sage: inverse_laplace?
def inverse_laplace(ex, t, s):
r"""
Attempts to compute the inverse Laplace transform of
``self`` with respect to the variable `t` and
transform parameter `s`. If this function cannot find a
solution, a formal function is returned.
(%i1) display2d:false;
(%o1) false
(%i2) f(s):=%e^(-3*s)/(s+2);
(%o2) f(s):=%e^-(3*s)/(2+s)
(%i4) ilt(f(s),t,s);
(%o4) 'ilt(%e^-(3*s)/(s+2),t,s)
</code></pre>
<p>Does that answer things? If you want to file an enhancement request to Maxima, please do, maybe it's not so hard for them to implement; however, presumably there are arbitrarily hard ones like this that no system could do...</p>
https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19720#post-id-19720Ooh, maybe that could be implemented upstream, then. Can you post some links?Thu, 31 May 2012 08:00:41 -0500https://ask.sagemath.org/question/9013/inverse-laplace-transforms-of-shifts/?comment=19720#post-id-19720