文章目录
1. 卷积
计算 x ( t ) = { 1 , 0 < t < 1 0 , e l s e , h ( t ) = { t , 0 < t < 1 0 , e l s e x(t)=\begin{cases}1 ,0<t<1\\0,else \end{cases},h(t)=\begin{cases}t ,0<t<1\\0,else \end{cases} x(t)={1,0<t<10,else,h(t)={t,0<t<10,else的卷积
(1)定义函数
x[t_] := If[0 <= t && t < 1, 1, 0];
h[t_] := If[0 < t && t < 2, t, 0];
Plot[{x[t], h[t]}, {t, -2, 2}, PlotStyle -> {Thick, Dashed}]
(2)卷积计算
1. 定义计算
∫ − ∞ + ∞ x ( τ ) h ( t − τ ) d τ = ∫ − ∞ + ∞ x ( t − τ ) h ( τ ) d τ \int_{-\infty}^{+\infty}x(\tau)h(t-\tau)d\tau = \int_{-\infty}^{+\infty}x(t-\tau)h(\tau)d\tau ∫−∞+∞x(τ)h(t−τ)dτ=∫−∞+∞x(t−τ)h(τ)dτ
f0 = Integrate[x[w]*h[t - w], {w, -Infinity, +Infinity}]
f1 = Integrate[x[t - w]*h[w], {w, -Infinity, +Infinity}]
Plot[{f0, f1}, {t, -3, 3}, PlotStyle -> {Thick, Dashed}]
2. 系统函数计算
f3 = Convolve[x[w], h[w], w, t]
3. 傅里叶变换
h ( t ) ∗ x ( t ) = F − 1 ( H ( w ) ⋅ X ( w ) ) h(t)*x(t)=F^{-1}(H(w) \cdot X(w)) h(t)∗x(t)=F−1(H(w)⋅X(w))
fx = FourierTransform[x[t], t, w]
fh = FourierTransform[h[t], t, w]
f = Sqrt[2*Pi]*InverseFourierTransform[fx*fh, w, t]
Plot[{f, f1}, {t, -3, 3}, PlotStyle -> {Thick, Dashed}]
问题:如何将两个图形打印在一副图形中?
使用Plot函数,设定两个函数图像,并设置PlotStyle分别为实现与虚线。
Plot[{f0, f1}, {t, -3, 3}, PlotStyle -> {Thick, Dashed}]
2. Laplace变换
求 f ( t ) = t 4 , g ( t ) = e t sin t f(t)=t^4,g(t)=e^t\sin t f(t)=t4,g(t)=etsint得Laplace变换
(1)定义函数
f[t_] := t^4;
g[t_] := E^t*Sin[t];
(2)函数变换
2.1 函数正变换
l1 = LaplaceTransform[f[t], t, s]
l2 = LaplaceTransform[g[t], t, s]
2.2 函数逆变换
InverseLaplaceTransform[l1, s, t]
InverseLaplaceTransform[l2, s, t]
问题:结果的三角和指数表达
(1)三角转指数表达
TrigToExp[g[t]]
(2)全化简
全化简用于结果语句的化简。
InverseLaplaceTransform[l2, s, t]
FullSimplify[%]
3. Laplace变换解非齐次微分方程
x ′ ′ ′ + 3 x ′ ′ + 3 x ′ + x = 1 x ′ ′ ( 0 ) = x ′ ( 0 ) = x ( 0 ) = 0 x'''+3x''+3x'+x=1 \\ x''(0)=x'(0)=x(0)=0 x′′′+3x′′+3x′+x=1x′′(0)=x′(0)=x(0)=0
(1)Laplace变换
3 ∗ s 2 F ( s ) + 3 ∗ s F ( s ) + F ( s ) = 1 s 3*s^2F(s)+3*sF(s)+F(s)=\frac{1}{s} 3∗s2F(s)+3∗sF(s)+F(s)=s1
f1 = LaplaceTransform[x'''[t] + 3 x''[t] + 3 x'[t] + x[t], t, s]
f2 = LaplaceTransform[1, t, s]
(2)给出初始条件
X[0] = 0;
X''[0] = 0;
X'[0] = 0;
(3)解方程获取Laplace变换函数
Solve[f1 == f2, LaplaceTransform[X[t], t, s]]
LaplaceTransform[X[t], t,
s] /. {{LaplaceTransform[X[t], t, s] -> 1/(s (1 + s)^3)}}
(4)Laplace反变换求原函数
x = InverseLaplaceTransform[sol, s, t]
FullSimplify[x]
所有代码
ClearAll;
X[0] = 0;
X''[0] = 0;
X'[0] = 0;
f1 = LaplaceTransform[X'''[t] + 3*X''[t] + 3*X'[t] + X[t], t, s]
f2 = LaplaceTransform[1, t, s]
Solve[f1 == f2, LaplaceTransform[X[t], t, s]]
sol = LaplaceTransform[X[t], t,
s] /. {{LaplaceTransform[X[t], t, s] -> 1/(s (1 + s)^3)}}
x = InverseLaplaceTransform[sol, s, t]
FullSimplify[x]
例题
{ x ′ ′ ( t ) − 2 x ′ ( t ) − y ′ ( t ) + 2 y ( t ) = 0 x ′ ( t ) + y ′ ( t ) − 2 x ( t ) = − 2 e − t \begin{cases} x''(t)-2x'(t)-y'(t)+2y(t)=0 \\ x'(t)+y'(t)-2x(t)=-2e^{-t} \end{cases} {x′′(t)−2x′(t)−y′(t)+2y(t)=0x′(t)+y′(t)−2x(t)=−2e−t
ClearAll;
f1 = LaplaceTransform[{X''[t] - 2 X'[t] - Y'[t] + 2 Y[t],
X'[t] + Y'[t] - 2 X[t]}, t, s]
f2 = LaplaceTransform[{0, -2*E^{-t}}, t, s]
X[0] = 2;
X'[0] = 3;
Y[0] = 1;
Solve[f1 == f2, {LaplaceTransform[X[t], t, s],
LaplaceTransform[Y[t], t, s]}]
sol = {LaplaceTransform[X[t], t, s], LaplaceTransform[Y[t], t, s]} /. %
x = InverseLaplaceTransform[sol, s, t]
FullSimplify[x]
4. Laplace变换求解积分方程
a t 2 − ∫ 0 t cos ( x − t ) f ( x ) d x = f ( t ) at^2-\int_{0}^{t}\cos (x-t)f(x)dx=f(t) at2−∫0tcos(x−t)f(x)dx=f(t)