unit34.mws

ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL

Unit 34 -- Piecewise-Defined and Impulse Functions

Prof. Douglas B. Meade

Industrial Mathematics Institute

Department of Mathematics

University of South Carolina

Columbia, SC 29208

URL: http://www.math.sc.edu/~meade/

E-mail: meade@math.sc.edu

Copyright © 2001 by Douglas B. Meade

All rights reserved

-------------------------------------------------------------------

>

Outline of Unit 34

>

Initialization

> restart;

> with( DEtools ):

> with( plots ):

> with( linalg ):

> with( inttrans ):

Warning, the name changecoords has been redefined

Warning, the name adjoint has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

Warning, the name hilbert has been redefined

> #assume( a>0 ):

> Alist := [ 0, 1, 2, 4, 5, 10, 15, a ]:

> alias( seq( u[A](t) = Heaviside(t-A), A=Alist ) );

u[0](t), u[1](t), u[2](t), u[4](t), u[5](t), u[10](...

>

34.A Piecewise-Defined Functions

34.A-1 Representation with Heaviside Functions

A piecewise-defined function is a function that cannot be defined by one elementary formula for all points in the domain. For example, the piecewise linear function that linearly interpolates the origin, ( 1, 1 ), and ( 2, 0 ) and is zero for all t > 2 can be defined in Maple using the piecewise command :

> f := piecewise( t<1, t, t<2, 2-t, t>=2, 0 );

f := PIECEWISE([t, t < 1],[2-t, t < 2],[0, 2 <= t])...

>

To verify the correctness of this definition, consider the plot of the function :

> plot( f, t=0..3, thickness=3, scaling=constrained );

[Maple Plot]

>

If the function is discontinuous, e.g. ,

> g := piecewise( t<1, t, t<2, t-1, 0 );

g := PIECEWISE([t, t < 1],[t-1, t < 2],[0, otherwis...

> plot( g, t=0..3, thickness=3, scaling=constrained );

[Maple Plot]

>

The vertical line segments in this plot are not part of the graph of this function; they arise when Maple connects the sample of points on the graph of the function.

> plot( g, t=0..3, thickness=3, scaling=constrained, style=point );

[Maple Plot]

>

The discont=true option instructs Maple to attempt to identify discontinuities in the plotting interval and to not connect points on either side of the discontinuity.

> plot( g, t=0..3, thickness=3, scaling=constrained, discont=true );

[Maple Plot]

>

The Heaviside function is the piecewise-defined function with definition

> convert( Heaviside(t), piecewise, t );

PIECEWISE([0, t < 0],[undefined, t = 0],[1, 0 < t])...

>

More generally, the Heaviside function at a is

> `u`[a] = convert( Heaviside(t-a), piecewise, t );

u[a] = PIECEWISE([0, t < a],[undefined, t = a],[1, ...

>

A piecewise-defined function can be written in terms of Heaviside functions with appropriate shifts. For example,

> f = collect( convert( f, Heaviside ), Heaviside );

PIECEWISE([t, t < 1],[2-t, t < 2],[0, 2 <= t]) = (-...

> g = collect( convert( g, Heaviside ), Heaviside );

PIECEWISE([t, t < 1],[t-1, t < 2],[0, otherwise]) =...

>

34.A-2 Laplace Transform of Heaviside Functions

Let a > 0. The Laplace transform of the Heaviside function at a can be obtained by a simple change of variables ( t = tau+a ) in the integral definition.

L(u[a]) = int(exp(-s*t)*u[a](t),t = 0 .. infinity) = int(exp(-s*t),t = a .. infinity) = exp(-s*a)*int(exp(-s*tau),tau = 0 .. infinity) = exp(-s*a)*L(1) = exp(-s*a)/s .

The result can also be obtained directly from Maple

> assume( a>0 );

> L( 'u'[a](t) ) = laplace( u[a](t), t, s );

L(u[a](t)) = exp(-s*a)/s

>

34.A-3 ODE Example

Consider the IVP

> ode1 := 2*diff( x(t), t ) + x(t) = h(a,t);

ode1 := 2*diff(x(t),t)+x(t) = h(a,t)

> ic1 := x(0) = 5;

ic1 := x(0) = 5

>

where the forcing function is initially zero, jumps to the value 1 at t = a , remains at 1 until t = 10 , decreases linearly to zero between t = 10 and t = 15 , then stays at zero for t > 15 :

> h := unapply( u[a](t) + (10-t)/5*u[10](t) + (t-15)/5*u[15](t), (a,t) );

h := proc (a, t) options operator, arrow; Heaviside...

>

For example,

> convert( h(5,t), piecewise, t );

PIECEWISE([0, t < 5],[undefined, t = 5],[1, t <= 10...

>

In advance of finding an explicit solution to this IVP, take a moment to think about the direction field for this ODE. When a = 5 , the direction field is

> dir_field1 := DEplot( eval(ode1,a=5), x(t), t=0..20, x=0..6, arrows=THIN ):

> dir_field1;

[Maple Plot]

>

The solution curve satisfying the initial condition must follow the direction field. The fact that there are drastic changes in the directions at several times does not change this basic fact. In addition, note that the solution will be continuous even when the directions are discontinuous.

The solution to the general IVP is

> sol1 := dsolve( { ode1, ic1 }, x(t), method=laplace );

sol1 := x(t) = 5*exp(-1/2*t)+Heaviside(1/2*t-1/2*a)...
sol1 := x(t) = 5*exp(-1/2*t)+Heaviside(1/2*t-1/2*a)...

>

Or, as a piecewise-defined function when a = 5 :

> convert( rhs(eval(sol1,a=5)), piecewise, t );

PIECEWISE([5*exp(-1/2*t), t <= 5],[1-exp(-1/2*t+5/2...

>

A graph of the solution, with a = 5 , superimposed on the direction field shows how this solution follows the direction field

> sol_plot1 := plot( eval(rhs(sol1),a=5), t=0..20, color=BLUE ):

> display( [dir_field1,sol_plot1] );

[Maple Plot]

>

An animation of the solution and direction fields for integer values of a between 0 and 10 shows how the solutions vary with the parameter :

> P := A -> display( [ DEplot( eval(ode1,a=A), x(t), t=0..20,

> x=0..6, arrows=THIN ),

> plot( eval(rhs(sol1),a=A), t=0..20,

> color=BLUE ) ] ):

> display( [ 'P'(i) $ i=0..10 ], insequence=true );

[Maple Plot]

>

34.B Impulse Functions

34.B-1 Definition of the Dirac delta Function

The Dirac delta function is defined by the seemingly inconsistent pair of properties : delta(t) = 0 for all t <> 0 and Int(delta(t),t = -infinity .. infinity) = 1 . Because the integral of any function that is zero almost everywhere must be zero, delta is not really a function (it is a distribution). Because of this fact, it can be a little difficult to work with the Dirac delta function. Most properties of the Dirac delta function are obtained using the fact that

delta(t) = Limit(h[Delta](t),Delta = 0,right)

where

> h := Delta -> 1/(2*Delta) * ( Heaviside(t+Delta) - Heaviside(t-Delta) );

h := proc (Delta) options operator, arrow; 1/2*(Hea...

>

For all Delta > 0 observe that h[Delta] has the property that :

> Int( h[Delta], t=-infinity..infinity )

> = int( h(Delta), t=-infinity..infinity );

Int(h[Delta],t = -infinity .. infinity) = 1

>

and, for all t <> 0 :

> Limit( h[Delta], Delta=0, right ) = limit( h(Delta), Delta=0, right );

Limit(h[Delta],Delta = 0,right) = 0

>

The following animation provides additional information about this sequence of functions and its limit.

> display( [seq( plot(h(Delta), t=-1.1..1.1), Delta=[2^(-i) $ i=0..8] )], insequence=true );

[Maple Plot]

>

Superimposing each frame of this animation in a single plot is also useful.

> plot( [seq( h(Delta), Delta=[2^(-i) $ i=0..8] )], t=-1.1..1.1 );

[Maple Plot]

>

Note that it is not possible to plot the Dirac delta function.

More generally, the Dirac delta function at time a is

delta[a](t) = delta(t-a) = Limit(h[a,Delta](t),Delta = 0,right)

where

> h := (a,Delta) -> 1/(2*Delta) * ( Heaviside(t-a+Delta) - Heaviside(t-a-Delta) );

h := proc (a, Delta) options operator, arrow; 1/2*(...

>

34.B-2 Laplace Transform of the Dirac delta Function

The Laplace transform of the Dirac delta function at a is derived from the Laplace transforms of the sequence of approximating functions:

L(delta[a]) = Limit(L(h[a,Delta]),Delta = 0,right)

That is,

> assume( Delta>0, Delta<a );

> q1 := laplace( h(a,Delta), t, s );

q1 := 1/2*(1/s-exp(-s*a)/s)/a

> L( delta[a] ) = Limit( q1, Delta=0, right );

L(delta[a]) = Limit(1/2*(1/s-exp(-s*a)/s)/a,Delta =...

> `` = limit( q1, Delta=0, right );

`` = 1/2*(1/s-exp(-s*a)/s)/a

>

The Maple name for the Dirac delta function (at time 0) is Dirac . Thus, the previous result could have been obtained directly with

> L( delta[a] ) = laplace( Dirac(t-a), t, s );

L(delta[a]) = exp(-s*a)

>

34.B-3 ODE Example

A common physical interpretation of the Dirac delta function at time a is as an instantaneous impulse when t = a . To illustrate, consider an undamped harmonic oscillator with unit mass ( m = 1 ) and spring constant ( k = 3 ) that is subject to an instantaneous impulse at t = 1 and a second impulse, in the opposite direction and with three times the force, at t = 4 . Assuming the system starts at rest the IVP is

> ode2 := diff( x(t), t$2 ) + 3*x(t) = Dirac(t-1) - 3*Dirac(t-4);

ode2 := diff(x(t),`$`(t,2))+3*x(t) = Dirac(t-1)-3*D...

> ic2 := x(0)=0, D(x)(0)=0;

ic2 := x(0) = 0, D(x)(0) = 0

>

The solution to this problem is

> infolevel[dsolve] := 3:

> sol2 := dsolve( {ode2,ic2}, x(t), method=laplace );

> infolevel[dsolve] := 0:

dsolve/inttrans/solveit:   Transform of eqns is   {s^2*laplace(x(t),t,s)+3*laplace(x(t),t,s)-exp(-s)+3*exp(-4*s)}

dsolve/inttrans/solveit:   Algebraic Solution is   {laplace(x(t),t,s) = -(-exp(-s)+3*exp(-4*s))/(s^2+3)}

sol2 := x(t) = 1/3*u[1](t)*sqrt(3)*sin(sqrt(3)*(t-1...

>

Note the appearance of Heaviside functions at t = 1 and t = 4 in the solution. The graph of the solution is

> plot( rhs(sol2), t=0..10 );

[Maple Plot]

>

The solution is continuous for all time and that the amplitude of the oscillation depends on the magnitude of the impulse.

>

[Back to ODE Powertool Table of Contents]

>