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)e−i2π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)=e−x2,则 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)=∫0−∞e−stf(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πi1∫c−i∞c+i∞e^{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)