# Unit Step Function

## 1218 days 전, namy0727 작성

#6.3 Unit Step Function Example #a = 2 var('t, s') u2(t) = unit_step(t-2) show(u2(t)) plot(u2(t),(t,0,4))
 \newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{u}\left(t - 2\right) 
#6.3 Unit Step Function Laplace Transform U2(s) = u2.laplace('t','s') print "L[u(t - 2)] ="; show(U2(s))
 L[u(t - 2)] = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{e^{\left(-2 \, s\right)}}{s} L[u(t - 2)] =
#6.3 Effects of the Unit Atep Function f(t) = 5*sin(t) u2(t) = unit_step(t-2) show(f(t)) show(f(t)*u2(t)) plot(f(t),(t,0,2*pi), color='red') + plot(f(t)*u2(t), (t,0,2*pi))
 \newcommand{\Bold}[1]{\mathbf{#1}}5 \, \sin\left(t\right) \newcommand{\Bold}[1]{\mathbf{#1}}5 \, \sin\left(t\right) \mathrm{u}\left(t - 2\right) 
#6.3 Effects of the Unit Atep Function Cont'd show(f(t)) show(f(t-2)*u2(t)) plot(f(t),(t,0,2*pi), color='red') + plot(f(t-2)*u2(t), (t,0,2*pi))
 \newcommand{\Bold}[1]{\mathbf{#1}}5 \, \sin\left(t\right) \newcommand{\Bold}[1]{\mathbf{#1}}5 \, \sin\left(t - 2\right) \mathrm{u}\left(t - 2\right) 
#6.3 Use of Many Unit Step Functions print "(A), k = 1" var('t') k = 1 f(t) = k*(unit_step(t - 1) - 2*unit_step(t - 4) + unit_step(t - 6)) show(f(t)) plot(f(t),(t,0,8))
 (A), k = 1 \newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{u}\left(t - 1\right) - 2 \, \mathrm{u}\left(t - 4\right) + \mathrm{u}\left(t - 6\right)  (A), k = 1 
#6.3 Use of Many Unit Step Functions Cont'd print "(B)" f(t) = 4*sin((1/2)*pi*t)*(unit_step(t) - unit_step(t - 2) + unit_step(t - 4) - unit_step(t - 6) + unit_step(t - 8) - unit_step(t - 10)) show(f(t)) plot(f(t),(t,0,12))
 (B) \newcommand{\Bold}[1]{\mathbf{#1}}-4 \, {\left(\mathrm{u}\left(t - 2\right) - \mathrm{u}\left(t - 4\right) + \mathrm{u}\left(t - 6\right) - \mathrm{u}\left(t - 8\right) + \mathrm{u}\left(t - 10\right) - \mathrm{u}\left(t\right)\right)} \sin\left(\frac{1}{2} \, \pi t\right)  (B) 
#6.3 Example 1 var('t, s') f(t) = 2*(1 - unit_step(t - 1)) + (1/2)*(t^2)*(unit_step(t - 1) - unit_step(t - (1/2)*pi)) + cos(t)*unit_step(t - (1/2)*pi) show(f(t)) plot(f(t),(t,0,4*pi))
 \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{1}{2} \, t^{2} {\left(\mathrm{u}\left(-\frac{1}{2} \, \pi + t\right) - \mathrm{u}\left(t - 1\right)\right)} + \cos\left(t\right) \mathrm{u}\left(-\frac{1}{2} \, \pi + t\right) - 2 \, \mathrm{u}\left(t - 1\right) + 2 
#6.3 Example 1 Cont'd f1(t) = 2*(1 - unit_step(t - 1)) print "f1(t) ="; show(f1(t)) F1(s) = f1.laplace('t','s') print "F1(s) ="; show(F1(s)) f2(t) = (1/2)*t^2*unit_step(t - 1) print "f2(t) ="; show(f2(t)) F2(s) = f2.laplace('t','s') print "F2(s) ="; show(F2(s)) f3(t) = (1/2)*t^2*unit_step(t - (1/2)*pi) print "f3(t) ="; show(f3(t)) F3(s) = f3.laplace('t','s') print "F3(s) ="; show(F3(s)) f4(t) = cos(t)*unit_step(t - (1/2)*pi) print "f4(t) ="; show(f4(t)) F4(s) = f4.laplace('t','s') print "F4(s) ="; show(F4(s))
 f1(t) = \newcommand{\Bold}[1]{\mathbf{#1}}-2 \, \mathrm{u}\left(t - 1\right) + 2 F1(s) = \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{2 \, e^{\left(-s\right)}}{s} + \frac{2}{s} f2(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, t^{2} \mathrm{u}\left(t - 1\right) F2(s) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{e^{\left(-s\right)}}{2 \, s} + \frac{e^{\left(-s\right)}}{s^{2}} + \frac{e^{\left(-s\right)}}{s^{3}} f3(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, t^{2} \mathrm{u}\left(-\frac{1}{2} \, \pi + t\right) F3(s) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{\pi^{2} e^{\left(-\frac{1}{2} \, \pi s\right)}}{8 \, s} + \frac{\pi e^{\left(-\frac{1}{2} \, \pi s\right)}}{2 \, s^{2}} + \frac{e^{\left(-\frac{1}{2} \, \pi s\right)}}{s^{3}} f4(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\cos\left(t\right) \mathrm{u}\left(-\frac{1}{2} \, \pi + t\right) F4(s) = \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{e^{\left(-\frac{1}{2} \, \pi s\right)}}{s^{2} + 1} f1(t) = F1(s) = f2(t) = F2(s) = f3(t) = F3(s) = f4(t) = F4(s) =
#6.3 Example 1 Cont'd F(s) = F1(s) + F2(s) - F3(s) + F4(s) print "F(s) = F1(s) + F2(s) - F3(s) + F4(s) =" show(F(s))
 F(s) = F1(s) + F2(s) - F3(s) + F4(s) = \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{\pi^{2} e^{\left(-\frac{1}{2} \, \pi s\right)}}{8 \, s} - \frac{e^{\left(-\frac{1}{2} \, \pi s\right)}}{s^{2} + 1} - \frac{\pi e^{\left(-\frac{1}{2} \, \pi s\right)}}{2 \, s^{2}} - \frac{3 \, e^{\left(-s\right)}}{2 \, s} + \frac{2}{s} + \frac{e^{\left(-s\right)}}{s^{2}} - \frac{e^{\left(-\frac{1}{2} \, \pi s\right)}}{s^{3}} + \frac{e^{\left(-s\right)}}{s^{3}} F(s) = F1(s) + F2(s) - F3(s) + F4(s) =
#6.3 Time-Shifting Function def timeshift(func,a): return func.subs(t = t - a)*unit_step(t - a)
#6.3 Example 2 var('t, s') F(s)= exp(-s)/(s^2 + pi^2) + exp(-2*s)/(s^2 + pi^2) + exp(-3*s)/(s + 2)^2 print "F(s) ="; show(F(s))
 F(s) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{e^{\left(-s\right)}}{\pi^{2} + s^{2}} + \frac{e^{\left(-2 \, s\right)}}{\pi^{2} + s^{2}} + \frac{e^{\left(-3 \, s\right)}}{{\left(s + 2\right)}^{2}} F(s) =
#6.3 Example 2 Cont'd G1(s) = 1/(s^2 + pi^2) print "G1(s) ="; show(G1(s)) g1(t) = inverse_laplace(G1,s,t) print "g1(t) ="; show(g1(t)) f1(t) = timeshift(g1,1) print "f1(t) ="; show(f1(t)) f2(t) = timeshift(g1,2) print "f2(t) ="; show(f2(t))
 G1(s) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{\pi^{2} + s^{2}} g1(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{\sin\left(\pi t\right)}{\pi} f1(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{\sin\left(\pi {\left(t - 1\right)}\right) \mathrm{u}\left(t - 1\right)}{\pi} f2(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{\sin\left(\pi {\left(t - 2\right)}\right) \mathrm{u}\left(t - 2\right)}{\pi} G1(s) = g1(t) = f1(t) = f2(t) =
#6.3 Example 2 Cont'd G2(s) = 1/(s + 2)^2 print "G2(s) ="; show(G2(s)) g2(t) = inverse_laplace(G2,s,t) print "g2(t) ="; show(g2(t)) f3(t) = timeshift(g2,3) print "f3(t) ="; show(f3(t))
 G2(s) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{{\left(s + 2\right)}^{2}} g2(t) = \newcommand{\Bold}[1]{\mathbf{#1}}t e^{\left(-2 \, t\right)} f3(t) = \newcommand{\Bold}[1]{\mathbf{#1}}{\left(t - 3\right)} e^{\left(-2 \, t + 6\right)} \mathrm{u}\left(t - 3\right) G2(s) = g2(t) = f3(t) =
#6.3 Example 2 Cont'd f(t) = f1(t) + f2(t) + f3(t) print "f(t) = f1(t) + f2(t) + f3(t) =" show(f(t)) f(t) = (f1(t) + f2(t)).simplify_trig() + f3(t) print "f(t) ="; show(f(t)) plot(f(t),(t,0,6))
 f(t) = f1(t) + f2(t) + f3(t) = \newcommand{\Bold}[1]{\mathbf{#1}}{\left(t - 3\right)} e^{\left(-2 \, t + 6\right)} \mathrm{u}\left(t - 3\right) + \frac{\sin\left(\pi {\left(t - 1\right)}\right) \mathrm{u}\left(t - 1\right)}{\pi} + \frac{\sin\left(\pi {\left(t - 2\right)}\right) \mathrm{u}\left(t - 2\right)}{\pi} f(t) = \newcommand{\Bold}[1]{\mathbf{#1}}{\left(t - 3\right)} e^{\left(-2 \, t + 6\right)} \mathrm{u}\left(t - 3\right) - \frac{{\left(\mathrm{u}\left(t - 1\right) - \mathrm{u}\left(t - 2\right)\right)} \sin\left(\pi t\right)}{\pi}  f(t) = f1(t) + f2(t) + f3(t) = f(t) = 
#6.3 Example 4 #i(0) = 0, di(0)/dt = 0 t, s, i, u = var('t, s, i, u') i(t) = function('i')(t) de = 0.1*diff(i(t),t) + 11*i(t) + 100*integral(i(u),u,0,t) == 100*sin(400*t)*(1 - unit_step(t - 2*pi)) de_symb = maxima(de) laplace_eq = de_symb.laplace('t','s'); show(laplace_eq)
 \newcommand{\Bold}[1]{\mathbf{#1}}0.1\,\left(s\,\mathcal{L}\left(i\left(t\right) , t , s\right)-i \left(0\right)\right)+{{100\,\mathcal{L}\left(i\left(t\right) , t , s\right)}\over{s}}+11\,\mathcal{L}\left(i\left(t\right) , t , s \right)={{100\,e^ {- 2\,\pi\,s }\,\left(400\,e^{2\,\pi\,s}-400 \right)}\over{s^2+160000}}
#6.3 Example 4 Cont'd I = var('I') laplace_eq = [0.1*s*I + 100*I/s + 11*I == 100*exp(-2*pi*s)*(400*exp(2*pi*s) - 400)/(s^2 + 160000)] laplace_sol = solve(laplace_eq,I) show(laplace_sol)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[I = \frac{400000 \, {\left(s e^{\left(2 \, \pi s\right)} - s\right)} e^{\left(-2 \, \pi s\right)}}{s^{4} + 110 \, s^{3} + 161000 \, s^{2} + 17600000 \, s + 160000000}\right]
#6.3 Example 4 Cont'd I1 = 400000*s/(s^4 + 110*s^3 + 161000*s^2 + 17600000*s + 160000000) I1 = I1.partial_fraction() print "I1(s) ="; show(I1) i1 =inverse_laplace(I1,s,t) print "i1(t) ="; show(i1)
 I1(s) = \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{400 \, {\left(159 \, s - 17600\right)}}{27217 \, {\left(s^{2} + 160000\right)}} + \frac{400}{153 \, {\left(s + 100\right)}} - \frac{4000}{14409 \, {\left(s + 10\right)}} i1(t) = \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{63600}{27217} \, \cos\left(400 \, t\right) - \frac{4000}{14409} \, e^{\left(-10 \, t\right)} + \frac{400}{153} \, e^{\left(-100 \, t\right)} + \frac{17600}{27217} \, \sin\left(400 \, t\right) I1(s) = i1(t) =
#6.3 Example 4 Cont'd i2(t) = timeshift(i1,2*pi) print "i2(t) ="; show(i2(t))
 i2(t) = \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{400}{244953} \, {\left(1431 \, \cos\left(-800 \, \pi + 400 \, t\right) - 1601 \, e^{\left(200 \, \pi - 100 \, t\right)} + 170 \, e^{\left(20 \, \pi - 10 \, t\right)} - 396 \, \sin\left(-800 \, \pi + 400 \, t\right)\right)} \mathrm{u}\left(-2 \, \pi + t\right) i2(t) =
#6.3 Example 4 Cont'd i2(t) = -400/244953*(1431*cos(400*t) - 1601*exp(200*pi - 100*t) + 170*exp(20*pi - 10*t) - 396*sin(400*t))*unit_step(-2*pi + t) i(t) = i1(t) - i2(t) print "i(t) = i1(t) - i2(t) ="; show(i(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. i(t) = i1(t) - i2(t) = \newcommand{\Bold}[1]{\mathbf{#1}}\frac{400}{244953} \, {\left(1431 \, \cos\left(400 \, t\right) - 1601 \, e^{\left(200 \, \pi - 100 \, t\right)} + 170 \, e^{\left(20 \, \pi - 10 \, t\right)} - 396 \, \sin\left(400 \, t\right)\right)} \mathrm{u}\left(-2 \, \pi + t\right) - \frac{63600}{27217} \, \cos\left(400 \, t\right) - \frac{4000}{14409} \, e^{\left(-10 \, t\right)} + \frac{400}{153} \, e^{\left(-100 \, t\right)} + \frac{17600}{27217} \, \sin\left(400 \, t\right) __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. i(t) = i1(t) - i2(t) =