用Python推导傅里叶变换和拉普拉斯变换

Fourier变换

【sympy】中封装了一系列积分变换的符号推导函数,其中,傅里叶变换和傅里叶变换的函数分别为

  • 【fourier_transform】 F ( k ) = ∫ − ∞ ∞ f ( x ) e − i 2 π i x k d x F(k)=\int^\infty_{-\infty}f(x)e^{-i2\pi ixk}\text dx F(k)=f(x)ei2πixkdx
  • 【inverse_fourier_transform】 f ( x ) = ∫ − ∞ ∞ F ( x ) e i 2 π i x k d k f(x)=\int^\infty_{-\infty}F(x)e^{i2\pi ixk}\text dk f(x)=F(x)ei2πixkdk

则令 f ( x ) = e − x 2 f(x)=e^{-x^2} f(x)=ex2,则 F ( k ) = π e − π 2 k 2 F(k)=\sqrt{\pi} e^{- \pi^{2} k^{2}} F(k)=π eπ2k2,变换过程如下。

from sympy import fourier_transform, inverse_fourier_transform
from sympy import exp, print_latex
from sympy.abc import x, k, a

F = fourier_transform(exp(-x**2), x, k)
print_latex(F)
f = inverse_fourier_transform(F)
print_latex(f)

拉普拉斯变换

Fourier变换存在两个问题,首先其作用对象为周期函数,其次要求这个函数不能发散。相比之下,拉普拉斯变换在变换过程中加入了一个衰减因子,从而在控制系统中更有优势。

【sympy】中封装了拉普拉斯变换及其逆变换的函数:

  • 【laplace_transform】 F ( s ) = ∫ 0 − ∞ e − s t f ( t ) d t F(s)=\int^\infty_{0^-}e^{-st}f(t)\text dt F(s)=0estf(t)dt
  • 【inverse_laplace_transform】 f ( t ) = 1 2 π i ∫ c − i ∞ c + i ∞ f(t)=\frac{1}{2\pi i}\int^{c+i\infty}_{c-i\infty} f(t)=2πi1cic+ie^{st}F(s)\text ds

其中,拉普拉斯变换函数的返回值是个元组,除了变换结果之外,还有结果的收敛于。例如,冲激信号 δ ( t ) \delta(t) δ(t)的拉普拉斯变换为常数,其返回值为 ( 1 ,   − ∞ ,  True ) \left( 1, \ -\infty, \ \text{True}\right) (1, , True)

from sympy import DiracDelta, laplace_transform
from sympy import inverse_laplace_transform, laplace_transform
from sympy.abc import t, s, a
F = laplace_transform(DiracDelta(t), t, s, simplify=True)
print_latex(F)
f = inverse_laplace_transform(F[0], s, t, simplify=True)
print_latex(f)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

微小冷

请我喝杯咖啡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值