本文整理汇总了Python中sympy.integrals.transforms.inverse_laplace_transform函数的典型用法代码示例。如果您正苦于以下问题:Python inverse_laplace_transform函数的具体用法?Python inverse_laplace_transform怎么用?Python inverse_laplace_transform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inverse_laplace_transform函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_expint
def test_expint():
from sympy import E1, expint, Max, re, lerchphi, Symbol, simplify, Si, Ci, Ei
aneg = Symbol("a", negative=True)
u = Symbol("u", polar=True)
assert mellin_transform(E1(x), x, s) == (gamma(s) / s, (0, oo), True)
assert inverse_mellin_transform(gamma(s) / s, s, x, (0, oo)).rewrite(expint).expand() == E1(x)
assert mellin_transform(expint(a, x), x, s) == (gamma(s) / (a + s - 1), (Max(1 - re(a), 0), oo), True)
# XXX IMT has hickups with complicated strips ...
assert simplify(
unpolarify(
inverse_mellin_transform(gamma(s) / (aneg + s - 1), s, x, (1 - aneg, oo)).rewrite(expint).expand(func=True)
)
) == expint(aneg, x)
assert mellin_transform(Si(x), x, s) == (
-2 ** s * sqrt(pi) * gamma(s / 2 + S(1) / 2) / (2 * s * gamma(-s / 2 + 1)),
(-1, 0),
True,
)
assert inverse_mellin_transform(
-2 ** s * sqrt(pi) * gamma((s + 1) / 2) / (2 * s * gamma(-s / 2 + 1)), s, x, (-1, 0)
) == Si(x)
assert mellin_transform(Ci(sqrt(x)), x, s) == (
-2 ** (2 * s - 1) * sqrt(pi) * gamma(s) / (s * gamma(-s + S(1) / 2)),
(0, 1),
True,
)
assert inverse_mellin_transform(
-4 ** s * sqrt(pi) * gamma(s) / (2 * s * gamma(-s + S(1) / 2)), s, u, (0, 1)
).expand() == Ci(sqrt(u))
# TODO LT of Si, Shi, Chi is a mess ...
assert laplace_transform(Ci(x), x, s) == (-log(1 + s ** 2) / 2 / s, 0, True)
assert laplace_transform(expint(a, x), x, s) == (lerchphi(s * polar_lift(-1), 1, a), 0, S(0) < re(a))
assert laplace_transform(expint(1, x), x, s) == (log(s + 1) / s, 0, True)
assert laplace_transform(expint(2, x), x, s) == ((s - log(s + 1)) / s ** 2, 0, True)
assert inverse_laplace_transform(-log(1 + s ** 2) / 2 / s, s, u).expand() == Heaviside(u) * Ci(u)
assert inverse_laplace_transform(log(s + 1) / s, s, x).rewrite(expint) == Heaviside(x) * E1(x)
assert (
inverse_laplace_transform((s - log(s + 1)) / s ** 2, s, x).rewrite(expint).expand()
== (expint(2, x) * Heaviside(x)).rewrite(Ei).rewrite(expint).expand()
)
开发者ID:whimsy-Pan,项目名称:sympy,代码行数:46,代码来源:test_transforms.py
示例2: inverse_laplace_sympy
def inverse_laplace_sympy(expr, s, t):
# This barfs when needing to generate Dirac deltas
from sympy.integrals.transforms import inverse_laplace_transform
result = inverse_laplace_transform(expr, t, s)
if result.has(sym.InverseLaplaceTransform):
raise ValueError('Cannot determine inverse Laplace'
' transform of %s with sympy' % expr)
return result
开发者ID:mph-,项目名称:lcapy,代码行数:10,代码来源:laplace.py
示例3: test_laplace_transform
def test_laplace_transform():
LT = laplace_transform
a, b, c, = symbols('a b c', positive=True)
t = symbols('t')
w = Symbol("w")
f = Function("f")
# Test unevaluated form
assert laplace_transform(f(t), t, w) == LaplaceTransform(f(t), t, w)
assert inverse_laplace_transform(f(w), w, t, plane=0) == InverseLaplaceTransform(f(w), w, t, 0)
# test a bug
spos = symbols('s', positive=True)
assert LT(exp(t), t, spos)[:2] == (1/(spos - 1), True)
# basic tests from wikipedia
assert LT((t-a)**b*exp(-c*(t-a))*Heaviside(t-a), t, s) \
== ((s + c)**(-b - 1)*exp(-a*s)*gamma(b + 1), -c, True)
assert LT(t**a, t, s) == (s**(-a - 1)*gamma(a + 1), 0, True)
assert LT(Heaviside(t), t, s) == (1/s, 0, True)
assert LT(Heaviside(t - a), t, s) == (exp(-a*s)/s, 0, True)
assert LT(1 - exp(-a*t), t, s) == (a/(s*(a + s)), 0, True)
assert LT((exp(2*t)-1)*exp(-b - t)*Heaviside(t)/2, t, s, noconds=True) \
== exp(-b)/(s**2 - 1)
assert LT(exp(t), t, s)[:2] == (1/(s-1), 1)
assert LT(exp(2*t), t, s)[:2] == (1/(s-2), 2)
assert LT(exp(a*t), t, s)[:2] == (1/(s-a), a)
assert LT(log(t/a), t, s) == ((log(a) + log(s) + EulerGamma)/(-s), 0, True)
assert LT(erf(t), t, s) == ((-erf(s/2) + 1)*exp(s**2/4)/s, 0, True)
assert LT(sin(a*t), t, s) == (a/(a**2 + s**2), 0, True)
assert LT(cos(a*t), t, s) == (s/(a**2 + s**2), 0, True)
# TODO would be nice to have these come out better
assert LT(exp(-a*t)*sin(b*t), t, s) == (1/b/(1 + (a + s)**2/b**2), -a, True)
assert LT(exp(-a*t)*cos(b*t), t, s) == \
(1/(s + a)/(1 + b**2/(a + s)**2), -a, True)
# TODO sinh, cosh have delicate cancellation
assert LT(besselj(0, t), t, s) == (1/sqrt(1 + s**2), 0, True)
assert LT(besselj(1, t), t, s) == (1 - 1/sqrt(1 + 1/s**2), 0, True)
# TODO general order works, but is a *mess*
# TODO besseli also works, but is an even greater mess
# test a bug in conditions processing
# TODO the auxiliary condition should be recognised/simplified
assert LT(exp(t)*cos(t), t, s)[:-1] in [
((s - 1)/(s**2 - 2*s + 2), -oo),
((s - 1)/((s - 1)**2 + 1), -oo),
]
开发者ID:goodok,项目名称:sympy,代码行数:54,代码来源:test_transforms.py
示例4: test_issue_8514
def test_issue_8514():
from sympy import simplify
a, b, c, = symbols('a b c', positive=True)
t = symbols('t', positive=True)
ft = simplify(inverse_laplace_transform(1/(a*s**2+b*s+c),s, t))
assert ft == ((exp(t*(exp(I*atan2(0, -4*a*c + b**2)/2) -
exp(-I*atan2(0, -4*a*c + b**2)/2))*
sqrt(Abs(4*a*c - b**2))/(4*a))*exp(t*cos(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2))/a) + I*sin(t*sin(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2))/(2*a)) - cos(t*sin(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2))/(2*a)))*exp(-t*(b + cos(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2)))/(2*a))/sqrt(-4*a*c + b**2))
开发者ID:A-turing-machine,项目名称:sympy,代码行数:12,代码来源:test_transforms.py
示例5: test_as_integral
def test_as_integral():
from sympy import Function, Integral
f = Function('f')
assert mellin_transform(f(x), x, s).rewrite('Integral') == \
Integral(x**(s - 1)*f(x), (x, 0, oo))
assert fourier_transform(f(x), x, s).rewrite('Integral') == \
Integral(f(x)*exp(-2*I*pi*s*x), (x, -oo, oo))
assert laplace_transform(f(x), x, s).rewrite('Integral') == \
Integral(f(x)*exp(-s*x), (x, 0, oo))
assert str(inverse_mellin_transform(f(s), s, x, (a, b)).rewrite('Integral')) \
== "Integral(x**(-s)*f(s), (s, _c - oo*I, _c + oo*I))"
assert str(inverse_laplace_transform(f(s), s, x).rewrite('Integral')) == \
"Integral(f(s)*exp(s*x), (s, _c - oo*I, _c + oo*I))"
assert inverse_fourier_transform(f(s), s, x).rewrite('Integral') == \
Integral(f(s)*exp(2*I*pi*s*x), (s, -oo, oo))
开发者ID:FedericoV,项目名称:sympy,代码行数:15,代码来源:test_transforms.py
示例6: inverse_laplace
def inverse_laplace(self):
"""Attempt inverse Laplace transform"""
try:
result = self._inverse_laplace()
except:
print('Determining inverse Laplace transform with sympy...')
# Try splitting into partial fractions to help sympy.
expr = self.partfrac().expr
# This barfs when needing to generate Dirac deltas
from sympy.integrals.transforms import inverse_laplace_transform
result = inverse_laplace_transform(expr, t, self.var)
if hasattr(self, '_laplace_conjugate_class'):
result = self._laplace_conjugate_class(result)
return result
开发者ID:bcbnz,项目名称:lcapy,代码行数:19,代码来源:core.py
示例7: test_laplace_transform
def test_laplace_transform():
from sympy import fresnels, fresnelc
LT = laplace_transform
a, b, c, = symbols("a b c", positive=True)
t = symbols("t")
w = Symbol("w")
f = Function("f")
# Test unevaluated form
assert laplace_transform(f(t), t, w) == LaplaceTransform(f(t), t, w)
assert inverse_laplace_transform(f(w), w, t, plane=0) == InverseLaplaceTransform(f(w), w, t, 0)
# test a bug
spos = symbols("s", positive=True)
assert LT(exp(t), t, spos)[:2] == (1 / (spos - 1), True)
# basic tests from wikipedia
assert LT((t - a) ** b * exp(-c * (t - a)) * Heaviside(t - a), t, s) == (
(s + c) ** (-b - 1) * exp(-a * s) * gamma(b + 1),
-c,
True,
)
assert LT(t ** a, t, s) == (s ** (-a - 1) * gamma(a + 1), 0, True)
assert LT(Heaviside(t), t, s) == (1 / s, 0, True)
assert LT(Heaviside(t - a), t, s) == (exp(-a * s) / s, 0, True)
assert LT(1 - exp(-a * t), t, s) == (a / (s * (a + s)), 0, True)
assert LT((exp(2 * t) - 1) * exp(-b - t) * Heaviside(t) / 2, t, s, noconds=True) == exp(-b) / (s ** 2 - 1)
assert LT(exp(t), t, s)[:2] == (1 / (s - 1), 1)
assert LT(exp(2 * t), t, s)[:2] == (1 / (s - 2), 2)
assert LT(exp(a * t), t, s)[:2] == (1 / (s - a), a)
assert LT(log(t / a), t, s) == ((log(a * s) + EulerGamma) / s / -1, 0, True)
assert LT(erf(t), t, s) == ((erfc(s / 2)) * exp(s ** 2 / 4) / s, 0, True)
assert LT(sin(a * t), t, s) == (a / (a ** 2 + s ** 2), 0, True)
assert LT(cos(a * t), t, s) == (s / (a ** 2 + s ** 2), 0, True)
# TODO would be nice to have these come out better
assert LT(exp(-a * t) * sin(b * t), t, s) == (b / (b ** 2 + (a + s) ** 2), -a, True)
assert LT(exp(-a * t) * cos(b * t), t, s) == ((a + s) / (b ** 2 + (a + s) ** 2), -a, True)
assert LT(besselj(0, t), t, s) == (1 / sqrt(1 + s ** 2), 0, True)
assert LT(besselj(1, t), t, s) == (1 - 1 / sqrt(1 + 1 / s ** 2), 0, True)
# TODO general order works, but is a *mess*
# TODO besseli also works, but is an even greater mess
# test a bug in conditions processing
# TODO the auxiliary condition should be recognised/simplified
assert LT(exp(t) * cos(t), t, s)[:-1] in [
((s - 1) / (s ** 2 - 2 * s + 2), -oo),
((s - 1) / ((s - 1) ** 2 + 1), -oo),
]
# Fresnel functions
assert laplace_transform(fresnels(t), t, s) == (
(
-sin(s ** 2 / (2 * pi)) * fresnels(s / pi)
+ sin(s ** 2 / (2 * pi)) / 2
- cos(s ** 2 / (2 * pi)) * fresnelc(s / pi)
+ cos(s ** 2 / (2 * pi)) / 2
)
/ s,
0,
True,
)
assert laplace_transform(fresnelc(t), t, s) == (
(
sin(s ** 2 / (2 * pi)) * fresnelc(s / pi) / s
- cos(s ** 2 / (2 * pi)) * fresnels(s / pi) / s
+ sqrt(2) * cos(s ** 2 / (2 * pi) + pi / 4) / (2 * s),
0,
True,
)
)
assert LT(Matrix([[exp(t), t * exp(-t)], [t * exp(-t), exp(t)]]), t, s) == Matrix(
[[(1 / (s - 1), 1, True), ((s + 1) ** (-2), 0, True)], [((s + 1) ** (-2), 0, True), (1 / (s - 1), 1, True)]]
)
开发者ID:whimsy-Pan,项目名称:sympy,代码行数:82,代码来源:test_transforms.py
示例8: print
# coding: utf-8
# 참고문헌: http://docs.sympy.org/dev/modules/integrals/integrals.html#sympy.integrals.transforms.laplace_transform
# http://www.mathalino.com/reviewer/advance-engineering-mathematics/table-laplace-transforms-elementary-functions
import sympy as sp
from sympy.integrals.transforms import inverse_laplace_transform
from sympy.integrals.transforms import laplace_transform
t, s = sp.symbols('t s')
w = sp.Symbol('w', real=True)
a = sp.Symbol('a', real=True)
p = sp.Symbol('p', real=True)
y = a * sp.sin(w * t + p)
print("y = %s" % y)
Y = laplace_transform(y, t, s)
print("Y = %s" % str(Y))
yi = inverse_laplace_transform(Y[0], s, t)
print("yi = %s" % str(yi))
开发者ID:kangwonlee,项目名称:16pfc_kangwonlee,代码行数:21,代码来源:test_laplace.py
示例9: range
#print Input_func_laplace[0]
#transfer func as given in paper
Trans_func = k*((tau_p*s+1)/(tau_d*s+1))
Output_func_laplace = Input_func_laplace[0]*Trans_func
print Output_func_laplace
'''c=[]
plt.figure(3)
for i in range(0,25):
c.append(Output_func_laplace.subs(s,ti[i]))
plt.plot(ti,c)
plt.title('Laplace Function curve')
plt.show()'''
Inv_laplace = inverse_laplace_transform(Output_func_laplace,s,t)
print Inv_laplace
#Output_func = Inv_laplace
#plotting output function
plt.figure(2)
b=[]
for i in range(0,25):
b.append(Inv_laplace.subs(t,ti[i]))
plt.plot(ti,b)
plt.title('Output Function')
plt.xlabel('Time(t)')
#plt.ylabel('')
plt.show()
开发者ID:shamikam,项目名称:spndAnalysis,代码行数:30,代码来源:transferfunc.py
注:本文中的sympy.integrals.transforms.inverse_laplace_transform函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论