Download pdf - Laplace 76

Transcript
Page 1: Laplace 76

Spring 2006 Math 308-5057 Laplace Transforms7.6 Transforms of Discontinuous andPeriodic FunctionsFri, 03/Mar c©2006, Art Belmonte

Summary

Heaviside function

TheHeaviside unit step functionis a piecewise continuousfunction defined by

u(t) ={

0, for t < 0;1, for t ≥ 0.

Forc ∈ R (typically c > 0), thetranslate of u is defined by

uc(t) = u(t − c) ={

0, for t < c;1, for t ≥ c.

The interval function is defined by

uab(t) = u(t − a) − u(t − b) =

0, for t < a;1, for a ≤ t < b;0, for t ≥ b.

The Heaviside function is easy to implement numerically inMATLAB in a vectorized fashion. To learn all about it, readChapter 6 (“Advanced use of dfield7”) in your lab manual! Alsoread about Polking’ssqw square wave function M-file.(It’s available to you on CalcLab and is easily transferred toyour Windows XP LABS account or home.) Finally, study theMATLAB Examples in this lecture handout.

Even better, as of Fall 2003 I have learned how to fully implementthe Heaviside function in a symbolic fashion for both Laplacetransform and graphing purposes.Accordingly, your work will bemuch easier than the folks had it in the Spring!

Periodic Functions

If f (t + T) = f (t) for all t, then f is periodic with periodT (orT -periodic). Itswindow is defined as

fT (t) ={

f (t), 0 ≤ t < T ;0, t ≥ T.

More Laplace transforms

In the following,a, b, c are constants,p is a nonnegative constant,L { f (t)} = F(s) is the Laplace transform off , and the Laplacetransform of the windowgT of the piecewise continuousT -periodic functiong is given byL {gT (t)} = GT (s).

L {u(t − c)} = e−cs

s

L {uab(t)} = e−as − e−bs

sL { f (t − p)u(t − p)} = e−psF(s)

L { f (t)u(t − p)} = e−psL { f (t + p)} (s)

L {g(t)} = GT (s)

1 − e−sT=

∫ T

0g(t)e−st dt

1 − e−sT

Hand Examples

Example A

Find the Laplace transform ofe2(t−1)u(t − 1).

Solution

Let f (t) = e2t . ThenF(s) = L { f (t)} = 1

s − 2. Therefore

L{e2(t−1)u(t − 1)

}= L { f (t − 1)u(t − 1)} = e−sF(s) = e−s

s − 2.

Example B

Compute the Laplace transform ofe−tu(t − 1).

Solution

SinceL {u(t − 1)} = e−s

s, we have

L {e−tu(t − 1)

} = e−(s+1)

s + 1.

Example C

Determine the Laplace transform ofu(t − π2 ) cos 3t.

Solution

We have cos(3(t + π2 )) = cos(3t + 3

2π) = sin 3t via trig. So

L {u(t − π

2 ) cos 3t} = e− π

2 sL {cos(3(t + π

2 ))} = 3e− π

2 s

s2 + 9.

Example D

Let f (t) =

0, t < 0t, 0 ≤ t < 33, t ≥ 3

. Define f in terms of the

Heaviside function, then compute its Laplace transform.

Solution

f (t) = t (u(t) − u(t − 3)) + 3u(t − 3) = tu(t) − (t − 3)u(t − 3)

impliesL { f (t)} = e−0s

s2− e−3s

s2= 1 − e−3s

s2.

1

Page 2: Laplace 76

Example E

Find the inverse Laplace transform ofe−2s

s + 3.

Solution

Let F(s) = 1

s + 3. Then f (t) = L−1 {F(s)} = e−3t . Thus

L−1{

e−2s 1

s + 3

}= u(t − 2) f (t − 2) = u(t − 2)e−3(t−2)

={

0, t < 2;e−3(t−2), t ≥ 2.

Example F

Compute the inverse Laplace transform ofe−s

s(s − 2)2.

Solution

Let F(s) = 1

s(s − 2)2= 1/4

s− 1/4

s − 2+ 1/2

(s − 2)2via cpf. Then

f (t) = 14 − 1

4e2t + 12te2t . ThusL−1

{e−s

s(s − 2)2

}is equal to

u(t − 1) f (t − 1) = u(t − 1)(

14 − 1

4e2(t−1) + 12(t − 1)e2(t−1)

).

Example G

Consider the driven, undamped oscillator

y′′ + 4y = f (t), y(0) = 0, y′(0) = 0,

with the driving forcef (t) = u(t − 1) − u(t − 2). Solve theinitial value problem; i.e., determine the solution, or response, tothe input f (t).

Solution

OK, campers: you know the drill from Section 7.5!

1. s2Y(s) − sy(0) − y′(0) + 4Y(s) = e−s

s− e−2s

s.

2. s2Y(s) + 4Y(s) = e−s

s− e−2s

s.

3. With the aid ofcpf, we have

Y(s) = e−s

s(s2 + 4)− e−2s

s(s2 + 4)

Y(s) =14e−s

s−

14se−s

s2 + 4−

14e−2s

s+

14se−2s

s2 + 4

4. Thusy(t) =(

14 − 1

4 cos(2(t − 1)))

u(t − 1)

+(

14 cos(2(t − 2)) − 1

4

)u(t − 2).

MATLAB Examples

We corroborate the results obtained in the Hand Examples viaMATLAB’s Symbolic Math Toolbox. Here are the diary files.

Example A [revisited]%% NSS-7.6/Example A%syms tu1 = heaviside(t-1);f = exp(2 * (t-1)) * u1; pretty(f)

exp(2 t - 2) heaviside(t - 1)F = simple(laplace(f)); pretty(F)

exp(-s)-------

s - 2%echo off; diary off

Example B [revisited]%% NSS-7.6/Example B%syms tu1 = heaviside(t-1);f = exp(-t) * u1; pretty(f)

exp(-t) heaviside(t - 1)F = simple(laplace(f)); pretty(F)

exp(-1 - s)-----------

1 + s%echo off; diary off

Example C [revisited]%% NSS-7.6/Example C%syms tup2 = heaviside(t-pi/2);f = up2 * cos(3 * t); pretty(f)

heaviside(t - 1/2 pi) cos(3 t)F = simple(laplace(f)); pretty(F)

exp(- 1/2 s pi)3 ---------------

2s + 9

%echo off; diary off

Example D [revisited]%% NSS-7.6/Example D%syms tu = heaviside(t);u3 = heaviside(t-3);f = t * (u-u3) + 3 * u3; pretty(f)

t (heaviside(t) - heaviside(t - 3))+ 3 heaviside(t - 3)

%t = linspace(-2, 5);v = eval(vectorize(f));plot(t,v, ’LineWidth’, 2); grid onxlabel(’t’); ylabel(’f(t)’)title(’NSS-7.6/Example D: f(t)’)axis([-2 5 -1 4])%F = simple(laplace(f)); pretty(F)

2

Page 3: Laplace 76

1 - exp(-3 s)-------------

2s

%echo off; diary off

Example E [revisited]%% NSS-7.6/Example E%syms sF = exp(-2 * s) / (s+3); pretty(F)

exp(-2 s)---------

s + 3f = ilaplace(F); pretty(f)

heaviside(t - 2) exp(-3 t + 6)% That is, f(t) = u(t-2) * exp(-3 * (t-2)).%echo off; diary off

Example F [revisited]%% NSS-7.6/Example F%syms sF = exp(-s) / (s * (s-2)ˆ2); pretty(F)

exp(-s)----------

2s (s - 2)

f = ilaplace(F); pretty(f)

(- 3/4 exp(2 t - 2) + 1/4 + 1/2 exp(2 t - 2) t)

* heaviside(t - 1)% That is,% f(t) = u(t-1) *% ( -3/4 * exp(2 * (t-1)) + 1/4 + 1/2 * t * exp(2 * (t-1)) ).%echo off; diary off

Example G [revisited]%% NSS-7.6/Example G%syms s t Ysy = sym(’y(t)’)y =y(t)f = heaviside(t-1) - heaviside(t-2);nde = diff(y,t,2) + 4 * y - f;pretty(nde) % #0

/ 2 \|d ||--- y(t)| + 4 y(t) - heaviside(t - 1) + heaviside(t - 2)| 2 |\dt /ltde = laplace(nde); % #1ltde = chiclet(ltde); pretty(ltde)

exp(-s) exp(-2 s)s (s Ys - y(0)) - Dy(0) + 4 Ys - ------- + ---------

s seq = subs(ltde, {’y(0)’ ’Dy(0)’ }, {0 0}); % #2pretty(eq)

2 exp(-s) exp(-2 s)s Ys + 4 Ys - ------- + ---------

s sYs = solve(eq, Ys); pretty(Ys) % #3

exp(-s) - exp(-2 s)-------------------

2s (s + 4)

y = ilaplace(Ys); pretty(y) % #4

heaviside(t - 1) (1/4 - 1/4 cos(2 t - 2))+ (- 1/4 + 1/4 cos(2 t - 4)) heaviside(t - 2)

%t = linspace(0,8);y = eval(vectorize(y));plot(t,y); grid onxlabel(’t’); ylabel(’y’)title(’NSS-7.6: Example G’)%echo off; diary off

396/23 [periodic function, numerically graphed]

Let f (t) ={

e−t , 0 < t < 1,1 1 < t < 2,

and f has period 2. Plotf (t)

for 0 ≤ t ≤ 8, and compute the Laplace transform off .

Solution

Here is a graphing script M-file and the plot it produces.

%% NSS4-396/23g: Here is a graph of a periodic function f% using MATLAB logical functions (as described in Chapter 6% of your lab manual).%t = linspace(0, 7.999, 500);f = exp(-mod(t,2)) . * (0<=t & t<1) ...

+ 1 . * (1<=t & t<2) ...+ exp(-mod(t,2)) . * (2<=t & t<3) ...+ 1 . * (3<=t & t<4) ...+ exp(-mod(t,2)) . * (4<=t & t<5) ...+ 1 . * (5<=t & t<6) ...+ exp(-mod(t,2)) . * (6<=t & t<7) ...+ 1 . * (7<=t & t<8);

plot(t,f,’ * ’); grid onaxis([0, 8, -0.5 1.5])%echo off; diary off

0 2 4 6 8−0.5

0

0.5

1

1.5

t

f

NSS4−396/23g: Numerical graph of a periodic function

Now we compute the Laplace transform off using the theoremfor the Laplace transform of a periodic function.

%% NSS4-396/23%syms s tI1 = int(exp(-t) * exp(-s * t), t, 0, 1);pretty(I1)

exp(-s - 1) - 1- ---------------

s + 1I2 = int(1 * exp(-s * t), t, 1, 2);pretty(I2)

3

Page 4: Laplace 76

exp(-2 s) - exp(-s)- -------------------

sF = (I1+I2) / (1 - exp(-2 * s)); pretty(F)

exp(-s - 1) - 1 exp(-2 s) - exp(-s)- --------------- - -------------------

s + 1 s---------------------------------------

1 - exp(-2 s)%

echo off; diary off

396/26 [periodic function, symbolically graphed]

Compute the Laplace transform of thesawtooth wave fshown.

0 a 2a 3a 4a 5a 6a−0.5

0

0.5

1

1.5NSS4−396/26: Sawtooth Wave

t

f

Solution

First off, here is the script M-file that produced the plot.

%% NSS4-396/26g%% Here is a graph of a sawtooth wave! This time we use a% symbolic implementation via Heaviside step functions.% For graphing purposes, we have chosen the value 1 for the% parameter a.%a = 1;syms k tu = sym(’Heaviside(t)’);uka = subs(u, t, t-k * a)ukp1a = subs(u, t, t-(k+1) * a)f = symsum((t/a - k) * (uka - ukp1a), k, 0, 5);t = linspace(0, 6, 500);ff = eval(vectorize(f));plot(t,ff,’+’); grid onaxis equalaxis([0, 6, -0.5, 1.5])% DIG IT: Custom tickmarks!set(gca,’XTickLabel’, {’0’;’a’;’2a’;’3a’;’4a’;’5a’;’6a’ })%

echo off; diary off

Once again, we compute the Laplace transform off using thetheorem for the Laplace transform of a periodic function.

%% NSS4-396/26%syms a s tF = int(t/a * exp(-s * t), t, 0, a) / (1 - exp(-a * s));pretty(F)

exp(-s a) + exp(-s a) s a - 1- -----------------------------

2a s (1 - exp(-s a))

%

echo off; diary off

396/28 [YAPF: yet another periodic function]

Compute the Laplace transform of thishalf-rectified sine wave f.

0 5 10 15−1

−0.5

0

0.5

1

1.5

2NSS4−396/28: Half−rectified sine wave

t

y

Solution

Here is the script M-file that produced the plot.

%% NSS4-396/28g: Graph of half-rectified sine wave%syms k tu = sym(’Heaviside(t)’);u 2k pi = subs(u, t, t-2 * k* pi)u 2kp1 pi = subs(u, t, t-(2 * k+1) * pi)f = symsum(sin(t) * (u 2k pi - u 2kp1 pi), k, 0, 2);t = linspace(0, 15, 2000);ff = eval(vectorize(f));plot(t,ff); grid onaxis([0 15 -1 2])%

echo off; diary off

The third time’s the charm. We compute the Laplace transform off using the theorem for the Laplace transform of a periodicfunction.

%% NSS4-396/28%syms s tF = int(sin(t) * exp(-s * t), t, 0, pi) ...

/ (1 - exp(-2 * pi * s));pretty(F)

1 + exp(pi s)-------------------------------------

2exp(pi s) (s + 1) (1 - exp(-2 pi s))

%

echo off; diary off

397/38 [IVP with discontinuous forcing function]

Solvey′′ + 2y′ + 10y = g(t); y(0) = −1, y′(0) = 0. Here

g(t) =

10, 0 ≤ t ≤ 1020, 10 < t < 200, 20 < t

.

Then graph the solutiony(t) for 0 ≤ t ≤ 35.

4

Page 5: Laplace 76

Solution

Formulateg in terms of Heaviside step functions, then do theusual 4-step procedure!

%% NSS4-397/38%syms s t Ysy = sym(’y(t)’);u = heaviside(t);u10 = heaviside(t-10);u20 = heaviside(t-20);g = 10 * (u-u10) + 20 * (u10-u20);de0 = diff(y,t,2) + 2 * diff(y,t) + 10 * y - g;pretty(de0)

/ 2 \|d | /d \|--- y(t)| + 2 |-- y(t)| + 10 y(t) - 10 Heaviside(t) - 10 Heaviside(t - 10)| 2 | \dt /\dt /

+ 20 Heaviside(t - 20)% 1ltde = laplace(de0);ltde = chiclet(ltde);pretty(ltde)

10 exp(-10 s)s (s Ys - y(0)) - Dy(0) + 2 s Ys - 2 y(0) + 10 Ys - ---- - 10 ----------

s sexp(-20 s)

+ 20 ----------s

% 2eq0 = subs(ltde, {’y(0)’, ’Dy(0)’ }, {-1, 0 });pretty(eq0)

10 exp(-10 s) exp(-20 s)s (s Ys + 1) + 2 + 2 s Ys + 10 Ys - ---- - 10 ---------- + 20 ----------

s s s% 3Ys = solve(eq0, Ys); pretty(Ys)

2s + 2 s - 10 - 10 exp(-10 s) + 20 exp(-20 s)

- ---------------------------------------------2

s (s + 2 s + 10)% 4y = ilaplace(Ys); pretty(y)

(2 exp(-t + 20) cos(3 t - 60) + 2/3 exp(-t + 20) sin(3 t - 60) - 2)Heaviside(t - 20) +(-exp(-t + 10) cos(3 t - 30) - 1/3 exp(-t + 10) sin(3 t - 30) + 1)Heaviside(t - 10) - 2 exp(-t) cos(3 t) - 2/3 exp(-t) sin(3 t) + 1

% Graph via plot.t = linspace(0, 35, 500);y = eval(vectorize(y));plot(t,y); grid on%echo off; diary off

Beauty, eh?

0 10 20 30 40−1

−0.5

0

0.5

1

1.5

2

2.5NSS4−397/38

t

y

398/62

A mixing tank initially holds 500 L of a brine solution with a saltconcentration of 0.2 kg/L. For the first 10 minutes of operation,valve B is open, adding 12 L/min of brine containing a 0.6 kg/Lsalt solution. After 10 minutes, valve B is closed and valve A is

opened for the next 10 minutes, delivering a 0.4 kg/Lconcentration at 12 L/min. Finally, valve A is shut and valve B isswitched back in. The exit valve C removes brine at a flow rate of12 L/min, thereby keeping the volume constant.

Find the concentrationc(t) of salt in the tank as a function oftime. Graphc(t) over 0≤ t ≤ 30, then again over 30≤ t ≤ 400.

Solution

Here is a diary file followed by the two plots.

%% NSS4-398/62%syms s t Xsx = sym(’x(t)’);u = sym(’Heaviside(t)’);u10 = subs(u, t, t-10);u20 = subs(u, t, t-20);c = 3/5 * (u-u10) + 2/5 * (u10-u20) + 3/5 * u20;de0 = diff(x,t) - (12 * c - 12 * x/500);pretty(de0)

/d \|-- x(t)| - 36/5 Heaviside(t) + 12/5 Heaviside(t - 10)\dt /

- 12/5 Heaviside(t - 20) + 3/125 x(t)% 1ltde = laplace(de0);ltde = chiclet(ltde);pretty(ltde)

exp(-10 s) exp(-20 s)s Xs - x(0) - 36/5 1/s + 12/5 ---------- - 12/5 ---------- + 3/125 Xs

s s% 2eq0 = subs(ltde, ’x(0)’, 100);pretty(eq0)

exp(-10 s) exp(-20 s)s Xs - 100 - 36/5 1/s + 12/5 ---------- - 12/5 ---------- + 3/125 Xs

s s% 3Xs = solve(eq0, Xs); pretty(Xs)

125 s + 9 - 3 exp(-10 s ) + 3 exp(-20 s)100 ---------------------------------------

s (125 s + 3)% 4x = ilaplace(Xs); pretty(x)

100 exp(- 3/125 t) + 600 exp(- 3/250 t) sinh(3/250 t)- 200 Heaviside(t - 10) exp(- 3/250 t + 3/25) sinh(3/250 t - 3/25)+ 200 Heaviside(t - 20) exp(- 3/250 t + 6/25) sinh(3/250 t - 6/25)

save x = x;% Graph early on...t = linspace(0, 30, 500);x = eval(vectorize(x));c = x/500;plot(t,c); grid on% ...and in the fullness of timefigure % new plott = linspace(30, 400, 500);x = eval(vectorize(save x));c = x/500;plot(t,c); grid on% Concentration expressionc = save x / 500; pretty(c)

1/5 exp(- 3/125 t) + 6/5 exp(- 3/250 t) sinh(3/250 t)- 2/5 Heaviside(t - 10) exp(- 3/250 t + 3/25) sinh(3/250 t - 3/25)+ 2/5 Heaviside(t - 20) exp(- 3/250 t + 6/25) sinh(3/250 t - 6/25)

%

echo off; diary off

0 5 10 15 20 25 300.2

0.25

0.3

0.35

0.4NSS4−398/62: Concentration early on

Time (minutes)

Con

cent

ratio

n (k

g/L)

5

Page 6: Laplace 76

0 100 200 300 4000.3

0.35

0.4

0.45

0.5

0.55

0.6NSS4−398/62: Concentration in the long run

Time (minutes)

Con

cent

ratio

n (k

g/L)

6


Recommended