# Dirac’s Delta Function

## 846 days 전, namy0727 작성

#6.4 Dirac Delta Function Example #a = 1 var('t, s, k') f(t,k)= (1/k)*(unit_step(t-1) - unit_step(t-(1+k))) print " fk(t) ="; show(f(t,k)) sum([plot(f(t,0.1*n),(x,0,2),color=rainbow(6)[n]) for n in [1..5]])
  fk(t) = \newcommand{\Bold}{\mathbf{#1}}-\frac{\mathrm{u}\left(-k + t - 1\right) - \mathrm{u}\left(t - 1\right)}{k} fk(t) = #6.4 Dirac Delta Function Example Cont'd F(s,k) = f.laplace('t','s').simplify_full() print " Fk(s) ="; show(F(s,k)) F(s) = limit(F(s,k), k=0 ) print " F(s) ="; show(F(s))
  Fk(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{{\left(e^{\left(k s\right)} - 1\right)} e^{\left(-k s - s\right)}}{k s} F(s) = \newcommand{\Bold}{\mathbf{#1}}e^{\left(-s\right)}  Fk(s) = F(s) =
#6.4 Time-Shifting Function def timeshift(func,a): return func.subs(t = t - a)*unit_step(t - a)
#6.4 Example 1 #y(0) = 0, dy(0)/dt = 0 t, s, y = var('t, s, y') y(t) = function('y')(t) de = diff(y(t),t,2) + 3*diff(y(t),t) + 2*y(t) == unit_step(t-1) - unit_step(t-2) de_symb = maxima(de) laplace_eq = de_symb.laplace('t','s'); show(laplace_eq)
 \newcommand{\Bold}{\mathbf{#1}}-\left.{{{\it \partial}}\over{{\it \partial}\,t}}\,y\left(t\right) \right|_{t=0}+3\,\left(s\,\mathcal{L}\left(y\left(t\right) , t , s \right)-y\left(0\right)\right)+s^2\,\mathcal{L}\left(y\left(t\right) , t , s\right)+2\,\mathcal{L}\left(y\left(t\right) , t , s\right)-y \left(0\right)\,s={{e^ {- s }}\over{s}}-{{e^ {- 2\,s }}\over{s}}
#6.4 Example 1 Cont'd Y = var('Y') laplace_eq = [s^2*Y + 3*s*Y + 2*Y == exp(-s)/s - exp(-2*s)/s] laplace_sol = solve(laplace_eq,Y) show(laplace_sol)
 \newcommand{\Bold}{\mathbf{#1}}\left[Y = \frac{{\left(e^{s} - 1\right)} e^{\left(-2 \, s\right)}}{s^{3} + 3 \, s^{2} + 2 \, s}\right]
#6.4 Example 1 Cont'd F(s) = 1/(s^3 + 3*s^2 + 2*s) print "F(s) ="; show(F(s)) F = F.factor() print "F(s) ="; show(F(s)) F = F.partial_fraction() print "F(s) ="; show(F(s)) f =inverse_laplace(F,s,t) print "f(t) ="; show(f(t))
 F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{1}{s^{3} + 3 \, s^{2} + 2 \, s} F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{1}{{\left(s + 2\right)} {\left(s + 1\right)} s} F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{1}{2 \, {\left(s + 2\right)}} - \frac{1}{s + 1} + \frac{1}{2 \, s} f(t) = \newcommand{\Bold}{\mathbf{#1}}-e^{\left(-t\right)} + \frac{1}{2} \, e^{\left(-2 \, t\right)} + \frac{1}{2} F(s) = F(s) = F(s) = f(t) =
#6.4 Example 1 Cont'd y(t) = timeshift(f,1) - timeshift(f,2) print "y(t) ="; show(y(t)) plot(y(t),(t,0,4))
 y(t) = \newcommand{\Bold}{\mathbf{#1}}-\frac{1}{2} \, {\left(2 \, e^{\left(-t + 1\right)} - e^{\left(-2 \, t + 2\right)} - 1\right)} \mathrm{u}\left(t - 1\right) + \frac{1}{2} \, {\left(2 \, e^{\left(-t + 2\right)} - e^{\left(-2 \, t + 4\right)} - 1\right)} \mathrm{u}\left(t - 2\right) y(t) = #6.4 Example 2 #y(0) = 0, dy(0)/dt = 0 t, s, y = var('t, s, y') y(t) = function('y')(t) de = diff(y(t),t,2) + 3*diff(y(t),t) + 2*y(t) == dirac_delta(t-1) de_symb = maxima(de) laplace_eq = de_symb.laplace('t','s'); show(laplace_eq)
 \newcommand{\Bold}{\mathbf{#1}}-\left.{{{\it \partial}}\over{{\it \partial}\,t}}\,y\left(t\right) \right|_{t=0}+3\,\left(s\,\mathcal{L}\left(y\left(t\right) , t , s \right)-y\left(0\right)\right)+s^2\,\mathcal{L}\left(y\left(t\right) , t , s\right)+2\,\mathcal{L}\left(y\left(t\right) , t , s\right)-y \left(0\right)\,s=e^ {- s }
#6.4 Example 2 Cont'd Y = var('Y') laplace_eq = [s^2*Y + 3*s*Y + 2*Y == exp(-s)] laplace_sol = solve(laplace_eq,Y) show(laplace_sol)
 \newcommand{\Bold}{\mathbf{#1}}\left[Y = \frac{e^{\left(-s\right)}}{s^{2} + 3 \, s + 2}\right]
#6.4 Example 2 Cont'd F(s) = 1/(s^2 + 3*s + 2) print "F(s) ="; show(F(s)) F = F.factor() print "F(s) ="; show(F(s)) F = F.partial_fraction() print "F(s) ="; show(F(s)) f =inverse_laplace(F,s,t) print "f(t) ="; show(f(t))
 F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{1}{s^{2} + 3 \, s + 2} F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{1}{{\left(s + 2\right)} {\left(s + 1\right)}} F(s) = \newcommand{\Bold}{\mathbf{#1}}-\frac{1}{s + 2} + \frac{1}{s + 1} f(t) = \newcommand{\Bold}{\mathbf{#1}}e^{\left(-t\right)} - e^{\left(-2 \, t\right)} F(s) = F(s) = F(s) = f(t) =
#6.4 Example 2 Cont'd y(t) = timeshift(f,1) print "y(t) ="; show(y(t)) plot(y(t),(t,0,5))
 y(t) = \newcommand{\Bold}{\mathbf{#1}}{\left(e^{\left(-t + 1\right)} - e^{\left(-2 \, t + 2\right)}\right)} \mathrm{u}\left(t - 1\right) y(t) = #6.4 Example 3 #q(0) = 0, dq(0)/dt = 0 t, s, y = var('t, s, y') q(t) = function('q')(t) de = diff(q(t),t,2) + 20*diff(q(t),t) + 10000*q(t) == dirac_delta(t) de_symb = maxima(de) laplace_eq = de_symb.laplace('t','s'); show(laplace_eq)
 \newcommand{\Bold}{\mathbf{#1}}-\left.{{{\it \partial}}\over{{\it \partial}\,t}}\,q\left(t\right) \right|_{t=0}+20\,\left(s\,\mathcal{L}\left(q\left(t\right) , t , s \right)-q\left(0\right)\right)+s^2\,\mathcal{L}\left(q\left(t\right) , t , s\right)+10000\,\mathcal{L}\left(q\left(t\right) , t , s \right)-q\left(0\right)\,s=1
#6.4 Example 3 Cont'd Q = var('Q') laplace_eq = [s^2*Q +20*s*Q + 10000*Q == 1] laplace_sol = solve(laplace_eq,Q) show(laplace_sol)
 \newcommand{\Bold}{\mathbf{#1}}\left[Q = \frac{1}{s^{2} + 20 \, s + 10000}\right]
#6.4 Example 3 Cont'd Q = 1/(s^2 + 20*s + 10000) q =inverse_laplace(Q,s,t) print "q(t) ="; show(q(t)) plot(q(t),(t,0,0.5))
 q(t) = __main__:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. \newcommand{\Bold}{\mathbf{#1}}\frac{1}{330} \, \sqrt{11} e^{\left(-10 \, t\right)} \sin\left(30 \, \sqrt{11} t\right) __main__:6: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. q(t) = __main__:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. __main__:6: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. #6.4 Example 4 #y(0) = 1, dy(0)/dt = -5 t, s, y = var('t, s, y') y(t) = function('y')(t) de = diff(y(t),t,2) + 2*diff(y(t),t) + 2*y(t) == 10*sin(2*t)*(1 - unit_step(t - pi)) de_symb = maxima(de) laplace_eq = de_symb.laplace('t','s'); show(laplace_eq)
 \newcommand{\Bold}{\mathbf{#1}}-\left.{{{\it \partial}}\over{{\it \partial}\,t}}\,y\left(t\right) \right|_{t=0}+2\,\left(s\,\mathcal{L}\left(y\left(t\right) , t , s \right)-y\left(0\right)\right)+s^2\,\mathcal{L}\left(y\left(t\right) , t , s\right)+2\,\mathcal{L}\left(y\left(t\right) , t , s\right)-y \left(0\right)\,s={{10\,e^ {- \pi\,s }\,\left(2\,e^{\pi\,s}-2\right) }\over{s^2+4}}
#6.4 Example 4 Cont'd Y = var('Y') laplace_eq = [s^2*Y - s + 5 + 2*s*Y - 2 + 2*Y == 10*(2/(s^2 + 4))*(1 - exp(-pi*s))] laplace_sol = solve(laplace_eq,Y) show(laplace_sol)
 \newcommand{\Bold}{\mathbf{#1}}\left[Y = \frac{{\left({\left(s^{3} - 3 \, s^{2} + 4 \, s + 8\right)} e^{\left(\pi s\right)} - 20\right)} e^{\left(-\pi s\right)}}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8}\right]
#6.4 Example 4 Cont'd Q(s) = s^3 - 3*s^2 + 4*s + 8 R(s) = s^4 + 2*s^3 + 6*s^2 + 8*s + 8 F(s) = Q(s)/R(s) print "F(s) ="; show(F(s)) G(s) = 20/R(s) print "G(s) ="; show(G(s)) Y = F(s) - G(s)*exp(-pi*s) print "Y = "; show(Y)
 F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{s^{3} - 3 \, s^{2} + 4 \, s + 8}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} G(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{20}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} Y = \newcommand{\Bold}{\mathbf{#1}}\frac{s^{3} - 3 \, s^{2} + 4 \, s + 8}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} - \frac{20 \, e^{\left(-\pi s\right)}}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} F(s) = G(s) = Y = 
#6.4 Example 4 Cont'd F1(s) = (Q(s) - 20)/R(s) F2(s) = 20/R(s) F(s) = F1(s) + F2(s) print "F(s) ="; show(F(s)) F1 = F1.factor() F2 = F2.factor() F(s) = F1(s) + F2(s) print "F(s) ="; show(F(s)) F2 = F2.partial_fraction() F(s) = F1(s) + F2(s) print "F(s) ="; show(F(s)) f =inverse_laplace(F,s,t) print "f(t) ="; show(f(t))
 F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{s^{3} - 3 \, s^{2} + 4 \, s - 12}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} + \frac{20}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{s - 3}{s^{2} + 2 \, s + 2} + \frac{20}{{\left(s^{2} + 2 \, s + 2\right)} {\left(s^{2} + 4\right)}} F(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{2 \, {\left(s + 3\right)}}{s^{2} + 2 \, s + 2} - \frac{2 \, {\left(s + 1\right)}}{s^{2} + 4} + \frac{s - 3}{s^{2} + 2 \, s + 2} f(t) = \newcommand{\Bold}{\mathbf{#1}}2 \, {\left(\cos\left(t\right) + 2 \, \sin\left(t\right)\right)} e^{\left(-t\right)} + {\left(\cos\left(t\right) - 4 \, \sin\left(t\right)\right)} e^{\left(-t\right)} - 2 \, \cos\left(2 \, t\right) - \sin\left(2 \, t\right) F(s) = F(s) = F(s) = f(t) =
#6.4 Example 4 Cont'd G(s) = 20/R(s) print "G(s) ="; show(G(s)) G(s) = F2(s) print "G(s) ="; show(G(s)) g =inverse_laplace(G,s,t) print "g(t) ="; show(g(t))
 G(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{20}{s^{4} + 2 \, s^{3} + 6 \, s^{2} + 8 \, s + 8} G(s) = \newcommand{\Bold}{\mathbf{#1}}\frac{2 \, {\left(s + 3\right)}}{s^{2} + 2 \, s + 2} - \frac{2 \, {\left(s + 1\right)}}{s^{2} + 4} g(t) = \newcommand{\Bold}{\mathbf{#1}}2 \, {\left(\cos\left(t\right) + 2 \, \sin\left(t\right)\right)} e^{\left(-t\right)} - 2 \, \cos\left(2 \, t\right) - \sin\left(2 \, t\right) G(s) = G(s) = g(t) =
#6.4 Example 4 Cont'd h(t) = timeshift(g,pi) y(t) = f(t) - h(t) print "y(t) ="; show(y(t)) h = h.simplify_trig() y(t) = f(t) - h(t) print "y(t) ="; show(y(t)) plot(y(t),(t,0,4*pi))
 y(t) = \newcommand{\Bold}{\mathbf{#1}}2 \, {\left(\cos\left(t\right) + 2 \, \sin\left(t\right)\right)} e^{\left(-t\right)} + {\left(\cos\left(t\right) - 4 \, \sin\left(t\right)\right)} e^{\left(-t\right)} - {\left(2 \, {\left(\cos\left(-\pi + t\right) + 2 \, \sin\left(-\pi + t\right)\right)} e^{\left(\pi - t\right)} - 2 \, \cos\left(-2 \, \pi + 2 \, t\right) - \sin\left(-2 \, \pi + 2 \, t\right)\right)} \mathrm{u}\left(-\pi + t\right) - 2 \, \cos\left(2 \, t\right) - \sin\left(2 \, t\right) y(t) = \newcommand{\Bold}{\mathbf{#1}}-2 \, {\left(2 \, e^{t} \sin\left(t\right)^{2} - \cos\left(t\right) e^{\pi} - {\left(\cos\left(t\right) e^{t} + 2 \, e^{\pi}\right)} \sin\left(t\right) - e^{t}\right)} e^{\left(-t\right)} \mathrm{u}\left(-\pi + t\right) + 2 \, {\left(\cos\left(t\right) + 2 \, \sin\left(t\right)\right)} e^{\left(-t\right)} + {\left(\cos\left(t\right) - 4 \, \sin\left(t\right)\right)} e^{\left(-t\right)} - 2 \, \cos\left(2 \, t\right) - \sin\left(2 \, t\right) y(t) = y(t) = 