ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 26 Nov 2018 23:09:05 -0600I'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 DbemolMon, 26 Nov 2018 23:09:05 -0600https://ask.sagemath.org/question/44466/How to generate an element from laplace distributionhttps://ask.sagemath.org/question/26617/how-to-generate-an-element-from-laplace-distribution/ Hi, I am wondering how to generate a random element according to laplace distribution.
I tried the method RealDistribution(). But it failed.
According to the reference manual, laplace distribution is not supported.
http://www.sagemath.org/doc/reference/probability/sage/gsl/probability_distribution.html
In the manual, there are some examples showing how to deal with uniform distribution, Gaussian distribution, etc.
My questions are:
(1) How do I know exactly which distributions are supported by the RealDistribution() method?
(2) Is there anyway I can simply generate an element according to laplace distribution in sage?
Thank you in advance. qbyteTue, 21 Apr 2015 14:57:56 -0500https://ask.sagemath.org/question/26617/How to find inverse laplace transformhttps://ask.sagemath.org/question/36656/how-to-find-inverse-laplace-transform/Hi!
I'm trying to find the inverse laplace transform from the following equation:
(5 * s * e^(-2*s))/(s^2 + 9).inverse_laplace(s,t),
although sage responds with:
ilt((5 * s * e^(-2*s))/(s^2 + 9)).
How do I find the inverse laplace transform from the equation above?
Sincerly SimonismonSat, 18 Feb 2017 13:13:43 -0600https://ask.sagemath.org/question/36656/inverse 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)
calc314Tue, 29 May 2012 10:39:07 -0500https://ask.sagemath.org/question/9013/laplace(heaviside(t),t,s) doesn't return 1/shttps://ask.sagemath.org/question/33152/laplaceheavisidetts-doesnt-return-1s/ var('s')
var('t',domain='positive')
laplace(heaviside(t),t,s)
returns an unevaluated function object in stead of returning `1/s`. Other functions such as `sin(t)` and `dirac_delta(t)` seem to give the correct results. Is this just a blind spot in laplace, or do I need to refine my domains on `s` or `t`?
If this transform just isn't implemented, is there an easy way for me to patch it locally?G BTue, 19 Apr 2016 18:14:14 -0500https://ask.sagemath.org/question/33152/Setting the conditions at t=0 for laplace transform with sage (instead of maxima)https://ask.sagemath.org/question/31713/setting-the-conditions-at-t0-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
howilSun, 20 Dec 2015 09:56:36 -0600https://ask.sagemath.org/question/31713/Trying to find phase and group delay of transfer functionshttps://ask.sagemath.org/question/29386/trying-to-find-phase-and-group-delay-of-transfer-functions/ I have several functions I would like to get the phase and group delay. In python I did the following
from sympy import pi, Symbol, I , atan, im, re, simplify, collect, trigsimp, sign
fr = Symbol('fr', real=True)
fo = Symbol('fo', real=True)
fn = Symbol('fn', real=True)
f = Symbol('f',real=True)
q = Symbol('q', real=True)
qn = Symbol('qn', real=True)
wr = 2*pi*fr
wo = 2*pi*fo
wn = 2*pi*fn
w = 2*pi*f
s = I*w
# Lp1 - s domain
H_lp1 = wr/(s+wr)
(re_part,im_part) = H_lp1.expand(complex=True).as_real_imag()
H_lp1_ph = atan(im_part/re_part)
Which returns the correct answer but when I try a more complicated function such as
H_lpn2 = ((s**2+wn**2)*(wo/wn)**2)/(s**2+s*(wo/q)+wo**2)
(re_part,im_part) = H_lpn2.expand(complex=True).as_real_imag()
H_lpn2_ph_expanded = atan(im_part/re_part)
H_lpn2_ph = simplify(H_lpn2_ph_expanded)
It does not return the complete solution. Any ideas?
leftiTue, 01 Sep 2015 12:07:21 -0500https://ask.sagemath.org/question/29386/plotting inverse laplace transformhttps://ask.sagemath.org/question/10532/plotting-inverse-laplace-transform/Hi there,
I'm studying a 4th order (two second order filters cascaded) electronic filter and I need it's time response.
I have derivated the transfert function and to get the time response, I apply the inverse laplace transform of the transfer function multiplied by a ramp.
Sage returns a result and I would like to plot this result, in order to check if this is correct but I don't know how to do so...
#!/opt/sage-5.11/sage
import cmath as m
from sage.calculus.calculus import inverse_laplace
r11 = 200.00e3
r21 = 800.00e3
c11 = lambda n: 1.25e-12 * (n+1)
c21 = lambda n: 312.5e-15 * (n+1)
wz1 = lambda n: 1/(r21*c11(n))
wp1 = lambda n: 1/(r11*c11(n))
# second filter
r12 = 266.67e3
r22 = 200.00e3
r32 = 800.00e3
c12 = lambda n: 1.25e-12*(n+1)
c22 = lambda n: 312.5e-15*(n+1)
A = r32/r12
w02 = lambda n: abs(1/(m.sqrt(r22*r32*c12(n)*c22(n))))
w02sq = lambda n: 1/(r22*r32*c12(n)*c22(n))
# second order coefficient
a = lambda n: 1/w02sq(n)
b = lambda n: r22*r32*c22(n)*((1/r12) + (1/r22) + (1/r32))
# gain
k = lambda n: A/wz1(n)
# input pulse
gain = 4
# electron injection
injfc = lambda x: x*1.602177e-19
# input
ampout = lambda x: injfc(x)/50e-15
# some more gain
gainout = lambda x: ampout(x)*gain
# set a value for i
i = 3
# declare p as a variable
p = var('p')
# the transfer function
f = ((k(i)*p) / (((1+p/wp1(i))**2) * ((p/w02(i))**2 + b(i)*p + 1)))
# transfer function multiplied by a very fast ramp and the input
fs = f*(2.00e6/p**2)*gainout(25000)
# please, gimme the inverse laplace
g = fs.inverse_laplace(p,x)
print "g(x) = ", g
# this is where I would like to plot g
# plot (g(x))
Thank you very much for your help
Best regards,
Olivier
osfeTue, 10 Sep 2013 06:21:37 -0500https://ask.sagemath.org/question/10532/Laplace of the differential of another variable in sagehttps://ask.sagemath.org/question/9257/laplace-of-the-differential-of-another-variable-in-sage/Why did the diff(y.laplace(t,s),x) come out to be `D[0](laplace)(y(x, t), t, s)*D[0](y)(x, t)`? Could someone help me?yangzbMon, 20 Aug 2012 22:47:19 -0500https://ask.sagemath.org/question/9257/How to read this code?https://ask.sagemath.org/question/9248/how-to-read-this-code/In sage, I performed the laplace transformation:
de=diff(y,t,2)-diff(y,x,2)==k*sin(pi*x);de.laplace(t,s)
and got such a code:
s^2L(y(x,t),t,s)-D[0](y)(x,t)2D[0,0]L(y(x,t),t,s)?sy(x,0)?D[0]L(y(x,t),t,s)D[0,0](y)(x,t)?D[1](y)(x,0)=sksin(?x)
Can someone tells me what `D[0](y)(x,t)2D[0,0]L(y(x,t),t,s)` and `D[0]L(y(x,t),t,s)D[0,0](y)(x,t)` mean?
Thanks!
yangzbThu, 16 Aug 2012 15:29:28 -0500https://ask.sagemath.org/question/9248/Problems with LaPlace transform when 'a' is negative in e^-athttps://ask.sagemath.org/question/8908/problems-with-laplace-transform-when-a-is-negative-in-e-at/ var('s t')
f = t^(-1)*exp(-t)-t^(-1)*exp((-3)*t)
f.laplace(t,s)
The above transform works as expected, however, when (-3) is changed to (3), I get the following error:
Traceback (click to the left of this block for traceback)
...
TypeError: ECL says: Maxima asks: Is s-3 positive, negative, or zero?
The Solution that I am expecting is:
log((s - 3)/(s + 1))
I don't know how to specify if s-3 is positive, negative, or zero. Any ideas?
Thanks,
Taylor Killian
tkillianThu, 19 Apr 2012 17:39:03 -0500https://ask.sagemath.org/question/8908/