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) =

 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) =

 F(s) =
 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) 
       
#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) 
       
#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) =

F(s) =

F(s) =

f(t) =
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) =

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) 
       
#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) 
       
#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) =

F(s) =

F(s) =

f(t) =
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) =

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) 
       
#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) 
       
#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.

__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) 
       
#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) 
       
#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) =

G(s) =

Y = 
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) =

F(s) =

F(s) =

f(t) =
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) =

G(s) =

g(t) =
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) =

y(t) =

y(t) =

y(t) =