+ All Categories
Home > Documents > Piecewise Functions and Convolution Integrals

Piecewise Functions and Convolution Integrals

Date post: 15-Feb-2016
Category:
Upload: halil
View: 126 times
Download: 0 times
Share this document with a friend
Description:
ACA 2014 Applications of Computer Algebra Session: Integration: implementation and applications Fordham University New York, NY, USA, July 9-12. Piecewise Functions and Convolution Integrals. Michel Beaudin, Frédérick Henri, ÉTS , Montréal, Canada. Introduction - PowerPoint PPT Presentation
Popular Tags:
60
Piecewise Functions and Convolution Integrals Michel Beaudin, Frédérick Henri, ÉTS, Montréal, Canada ACA 2014 Applications of Computer Algebra Session: Integration: implementation and applications Fordham University New York, NY, USA, July 9-12
Transcript
Page 1: Piecewise Functions and  Convolution Integrals

Piecewise Functions and

Convolution IntegralsMichel Beaudin, Frédérick Henri, ÉTS, Montréal, Canada

ACA 2014 Applications of Computer Algebra

Session: Integration: implementation and applicationsFordham University

New York, NY, USA, July 9-12

Page 2: Piecewise Functions and  Convolution Integrals

2

• Introduction• Convolution of two functions :

• Case of Laplace transforms• Continuous LTI systems• Computing the convolution

• Symbolic Convolution in Nspire CAS• Conclusion

Overview

Page 3: Piecewise Functions and  Convolution Integrals

3

Why this subject?At the last ACA conference, we showed how useful it was for a Computer Algebra System (CAS) to perform symbolic integration of Piecewise Continuous Functions (PCF) and expressions containing such functions.Sadly, Texas Instruments computer algebra system Nspire CAS is able to deal with PCF but presents some limitations.

Introduction

Page 4: Piecewise Functions and  Convolution Integrals

4

Let a PCF be defined over an interval (or the entire real line) and be continuous over each sub-interval. Here is what Nspire CAS does well :

• The symbolic derivative, the symbolic indefinite integral and the symbolic definite integral.

• The system correctly checks the endpoints for the derivative and adjusts the constants of integration for each sub-interval for the integral.

Introduction

Page 5: Piecewise Functions and  Convolution Integrals

5

Introduction

Constants are added to obtain a continuousantiderivative.

Exact value.

Here is an example.

Page 6: Piecewise Functions and  Convolution Integrals

6

Function f(x) and definite integral:

Introduction

Page 7: Piecewise Functions and  Convolution Integrals

7

Important: a continuous antiderivative!

Introduction

( )y f x

( )f x dx

Page 8: Piecewise Functions and  Convolution Integrals

8

We just saw that Nspire CAS uses templates to define piecewise functions.

These templates are attractive but some limitations appear if one wants to perform more complicated symbolic operations.

Introduction

Page 9: Piecewise Functions and  Convolution Integrals

As an example, we continue with our earlier function y = f(x) and try to compute .

9

Introduction

2 ( )x f x dx

Unable to compute!

No exact value!

Page 10: Piecewise Functions and  Convolution Integrals

10

Nspire CAS built-in integrator is unable to perform the symbolic integration of a product of a single expression with a piecewise function.

Furthermore, it only returns a floating point approximation for the definite integral.

Introduction

Page 11: Piecewise Functions and  Convolution Integrals

11

This is why Frédérick Henri has programmed some functions (showed last year at ACA).

With these functions (included in a special library used by us at ETS), Nspire CAS is now able to do all of this correctly!

Introduction

Page 12: Piecewise Functions and  Convolution Integrals

12

Here is a brief recap of how it works:1. We group into a single piecewise function

an expression using the function grouper_fct(ex, var) where ex is an expression in variable var.

Elsexxx

Elsexxx

Elsex

),cos(20),sin(

,0,

,03,1

Introduction

0),cos(30),sin(

2,)cos(23,)sin(

xxxx

xxxxxx

Page 13: Piecewise Functions and  Convolution Integrals

13

2. We use the built-in integrator of Nspire CAS to perform the integral.

Note that in the upcoming slide:• kit_ETS_fh\integral_mcx(ex, var) stands for the indefinite integral of ex wrt to var.

• kit_ETS_fh\integral_mcx_d(ex, var, lo, up) stands for the definite integral of ex wrt var from lo to up.

Introduction

Page 14: Piecewise Functions and  Convolution Integrals

14

Introduction

Nspire CAS built-in integrator.

Only a floating point approximation.

Symbolic piecewise antiderative!

Exact value!

Page 15: Piecewise Functions and  Convolution Integrals

15

Case of Laplace transforms Usually, students are introduced to Laplace transforms inside an ODE course. Functions f(t) are defined for and the Laplace transform of f is the function F defined by the improper integral

Convolution of Two Functions

0

( ) ( ) stF s f t e dt

0t

Page 16: Piecewise Functions and  Convolution Integrals

16

Case of Laplace transforms Let’s use the notation for the correspondence between the function f(t) and its transform F(s).Note that f(t) is in fact f(t) u(t) where u(t) is the unit-step function (Heaviside function):

Convolution of Two Functions

( ) ( )f t F s

0, 0( )

1, 0t

u tt

Page 17: Piecewise Functions and  Convolution Integrals

17

Case of Laplace transforms Then we have the “convolution property”

This last integral is called the convolution (in the sense of Laplace transforms) of f and g.

Convolution of Two Functions

0

( ) ( ) ( ) ( ) ( ) ( )t

F s G s f t g t f g t d

Page 18: Piecewise Functions and  Convolution Integrals

18

Case of Laplace transforms Note that it can be written in the more general form

if x(t) = f(t)u(t) and h(t) = g(t)u(t).

Convolution of Two Functions

( ) ( )x h t d

Page 19: Piecewise Functions and  Convolution Integrals

19

Case of Laplace transforms Unfortunately, in a classical ODE course, few words are said about convolution or the reasons why it is important.

For simplicity, let’s take a linear second order, constant coefficients ODE

Convolution of Two Functions

( ) ( ) ( ) ( ) ( ), (0) 0, (0) 0a y t b y t c y t x t u t y y

Page 20: Piecewise Functions and  Convolution Integrals

20

Case of Laplace transforms Then the solution of

is given by the convolutionwhere

h(t) is known as the impulse response and H(s) as the transfer function.

Convolution of Two Functions

( ) ( ) ( ) ( ) ( ), (0) 0, (0) 0a y t b y t c y t x t u t y y ( ) ( ) ( )y t x t h t

21( ) ( )h t H s

a s b s c

Page 21: Piecewise Functions and  Convolution Integrals

21

Case of Laplace transforms Usually, the ODE represents a damped mass-spring problem or a RLC circuit problem.In this case, the coefficients a, b and c are positive and there is no loss of generality taking zero initial conditions since the transient solution dies out.So, the convolution solves the ODE.

Convolution of Two Functions

Page 22: Piecewise Functions and  Convolution Integrals

22

Continuous LTI systemsWe now consider a (continuous) system

where an input x(t) enters the system and an output y(t) is produced. Some examples:

Convolution of Two Functions

4( ) ( ), ( ) 5 (2 1) 10

( ) cos( ( )), ( ) ( )

( ) ( )t

y t x t y t x tdy t x t y t x tdt

y t x d

x(t) SYSTEM y(t)

Page 23: Piecewise Functions and  Convolution Integrals

23

Continuous LTI systemsAnother example is a mass-spring system: the external force f(t) is the input (f(t) = 0 if t < 0) and the position y(t) of the object at time t is the output.The following ODE is the model used:

Convolution of Two Functions

( ) ( ) ( ) ( ), (0) 0, (0) 0m y t b y t k y t f t y y

Mass of the objectConstant of friction

Spring constant

Page 24: Piecewise Functions and  Convolution Integrals

24

Continuous LTI systemsLet the input produce the output and let the input produce the output .The system is linear if the linearly combined input produces the linear combined output

Convolution of Two Functions

1( )x t 1( )y t2 ( )x t 2 ( )y t

1 2( ) ( ) ( )x t a x t b x t

1 2( ) ( ) ( )y t a y t b y t

Page 25: Piecewise Functions and  Convolution Integrals

25

Continuous LTI systemsLet the input x(t) produces the output y(t), let a be any real number.The system is time-invariant if the shifted output y(t a) is the same as the output produced by the shifted input x(t a).That is: S(x(t)) = y(t) S(x(t a)) = y(t a)

Convolution of Two Functions

Page 26: Piecewise Functions and  Convolution Integrals

26

Continuous LTI systemsThe system is said linear, time-invariant (LTI) if both conditions are satisfied.Example: consider again the capacitor as a system. When a current i(t) passes through the capacitor C, the voltage across the capacitor is

Convolution of Two Functions

1( ) ( )t

v t i dC

Page 27: Piecewise Functions and  Convolution Integrals

27

Continuous LTI systemsThis is a linear system because of the linearity of the integral. The system is also time-invariant as a change of variable shows it.

Convolution of Two Functions

1 1( ) ( ) ( )t t a

i a d i d v t aC C

Page 28: Piecewise Functions and  Convolution Integrals

28

Computing the convolutionIn signal analysis courses, students learn how to compute by hand the convolution of two signals.They are introduced to important functions such as unit step function u(t) and unit-impulse (Dirac delta) “function” d(t). But there is no need to deal with the theory of generalized functions.

Convolution of Two Functions

Page 29: Piecewise Functions and  Convolution Integrals

29

Computing the convolutionInstead, they are using limiting process. The Dirac delta “function” is replaced by an approximate unit-impulse function:

In Derive, this is nothing else than

Convolution of Two Functions

1( ) ( ) ( )t u t u td

1 1STEP( ) STEP( ) CHI 0, ,t t t

Page 30: Piecewise Functions and  Convolution Integrals

30

Computing the convolutionGiven a system, the output to the unit-impulse d(t) is called the system impulse response h(t). Fact: in a continuous LTI system, the output y(t) to the input x(t) is given by the convolution

Convolution of Two Functions

( ) ( ) ( )y t x h t d

Page 31: Piecewise Functions and  Convolution Integrals

31

Computing the convolutionThis is easy to justify. The signal x(t) is replaced by a staircase approximation and a limit:

If is the output to , then the linearity of the integral and time invariance yields the result.

Convolution of Two Functions

( )h t ( )td0

( ) ( ) ( )

( ) lim ( ) ( ) ( )

kx t x k t k

x t x t x t d

d

d

Page 32: Piecewise Functions and  Convolution Integrals

32

Computing the convolutionSuppose you want to perform a convolution:

Then, 4 steps must be completed :• reverse the time in the signal h; • shift the variable; • multiply by the signal x; • integrate over all values of , doing this for

every value of t.

Convolution of Two Functions

( ) ( ) ( )y t x h t d

Page 33: Piecewise Functions and  Convolution Integrals

33

Computing the convolutionFor example, the convolution of two rectangular pulses of finite (but different) duration is a trapezoidal signal:

Let’s switch to Nspire CAS and show an animation of this.

Convolution of Two Functions

Convolution ofx(t) and h(t).

Page 34: Piecewise Functions and  Convolution Integrals

34

Computing the convolutionDerive can easily perform the last convolution because of its ability to integrate piecewise functions. Even though the Dirac delta function has never been implemented into Derive, we can compute symbolic limits involving indicator functions. So we can use impulse functions!

Convolution of Two Functions

Page 35: Piecewise Functions and  Convolution Integrals

35

Computing the convolutionLet us show a Derive screen where the convolution is defined.Then we will show the convolution of the two rectangular pulses x(t) = CHI(0, t, 1) and h(t) = 1.5CHI(0, t, 2).In Derive, CHI(a, x, b) is the indicator function of the open interval a < x < b. The notation is c(a, x, b).

Convolution of Two Functions

Page 36: Piecewise Functions and  Convolution Integrals

36

Computing the convolutionFinally, we will illustrate the fact that the convolution with the shifted Dirac delta function d(t a) produces a translation on a signal x(t):

The next slide shows this with a = 1.

Convolution of Two Functions

( ) ( ) ( )x t t a x t ad

Page 37: Piecewise Functions and  Convolution Integrals

37

Convolution of Two Functions

It is so easy to define a convolution of 2 signals in Derive!

We take 2 rectangular pulses, using theindicator function c of Derive.

Here is the result and the graph.

Now we convolve the « output » with d(t 1),using a limit of indicator function: this produces, as expected, a translation of the signal « output ».

Page 38: Piecewise Functions and  Convolution Integrals

38

We know Nspire CAS can’t simplify the product of a piecewise expression with another expression.So, if x(t) is piecewise with compact support, the integral of x(t) with another expression only yields a floating point value. The next slide illustrates this.

Symbolic Convolution in Nspire CAS

Page 39: Piecewise Functions and  Convolution Integrals

39

Here is, again, an example.

Now let’s try to perform the convolution of x(t) and h(t).

Symbolic Convolution in Nspire CAS

No exact value.

Exact value!

Page 40: Piecewise Functions and  Convolution Integrals

40

Nspire CAS built-in integrator won’t succeed …

Symbolic Convolution in Nspire CAS

Oups…!

Page 41: Piecewise Functions and  Convolution Integrals

41

… neither will Frédérick’s function!

Symbolic Convolution in Nspire CAS

Page 42: Piecewise Functions and  Convolution Integrals

42

So, what can we do?

Our goal is to find a way for Nspire CAS to compute the symbolic convolution without giving up the use of templates.

As far as integration is concerned, endpoints of each subinterval are irrelevant.

Symbolic Convolution in Nspire CAS

Page 43: Piecewise Functions and  Convolution Integrals

43

Here is what we will do:1. Convert a piecewise function into a linear

combination of signum functions.2. Import from Derive a very important rule:

Symbolic Convolution in Nspire CAS

Page 44: Piecewise Functions and  Convolution Integrals

44

3. Perform the symbolic integration of each term.

4. Convert the result into a piecewise expression (if applicable).

5. Moreover, if one needs to use a Dirac delta function, it should be possible to achieve, using limit of indicator functions.

Symbolic Convolution in Nspire CAS

Page 45: Piecewise Functions and  Convolution Integrals

Note : the rule

yields a continuous antiderivative. Here is why. Let G(x) be an antiderivative of F(x). Consider the function “Albert”:

This function is everywhere continuous and differentiable except at the point x = b/a.

Symbolic Convolution in Nspire CAS

Albert( ) : SIGN( ) ( ) bx ax b G x Ga

45

Page 46: Piecewise Functions and  Convolution Integrals

The derivative of SIGN(ax + b) is 0 except at x = b/a. So, for x ≠ b/a,

For x ≠ b/a, Albert(x) is continuous everywhere because SIGN and G are continuous. If x = b/a, it is also continuous because SIGN is a bounded function:

Symbolic Convolution in Nspire CAS

Albert( ) 0 ( ) SIGN( ) ( ) 0 SIGN( ) ( ).d bx G x G ax b F x ax b F xdx a

46

lim SIGN( ) ( ) 0bxa

bax b G x Ga

Page 47: Piecewise Functions and  Convolution Integrals

47

New functions were defined and saved in an updated version of the library Kit_ETS_FH.

Frédérick Henri took care of the programming side of the job and Michel Beaudin took care of the mathematical requests.

Here is a description of the principal functions.

Symbolic Convolution in Nspire CAS

Page 48: Piecewise Functions and  Convolution Integrals

48

The sign function is already implemented into Nspire CAS. We have defined the unit step function and the piecewise indicator function of the interval ]a, b[:

Frédérick’s function unpiece transforms a piecewise function into a linear combination of indicator functions. The inverse is achieved with the function signtopiece.

Symbolic Convolution in Nspire CAS

1 sign( )step( ) :2

chi( , , ) : step( ) step( )

xx

a x b x a x b

Page 49: Piecewise Functions and  Convolution Integrals

Here are some examples:

Symbolic Convolution in Nspire CAS

We add the « step » function.

We add the indicator function andcall it « chi ».

We « unpiece ».

We« convert »to piecewise.

« grouper_fct »finishes the job.

49

Page 50: Piecewise Functions and  Convolution Integrals

50

Nspire CAS is now able to do as Derive when comes time to integrate a product of sign with another expression. In fact, Frédérick has programmed the function integral_sign in order to compute the integral of expressions as sign(ax + b)·f(x).For more complicated examples, expansion is used and the function integral2 does the job.Let’s take a look at an example.

Symbolic Convolution in Nspire CAS

Page 51: Piecewise Functions and  Convolution Integrals

51

The answer would be different if sign(2x5) was factored out first; the 2 answers would differ by a constant, as for primitives.

Symbolic Convolution in Nspire CAS

Nspire built-in integrator.

Frédérick’s function!

Derive built-in integrator.

It is the same!

Page 52: Piecewise Functions and  Convolution Integrals

52

Now, let be given 2 piecewise continuous signals, say x(t) and h(t). We “unpiece” the product x()h(t ). This become a linear combination of sign functions and we integrate it using the new integral2 function. The antiderivative is then evaluated between ∞ and ∞. This yields the convolution of x and h. The function convol_gen does the job.

Symbolic Convolution in Nspire CAS

Page 53: Piecewise Functions and  Convolution Integrals

53

If the answer is a linear combination of absolute values expressions, our function conv_abs_to_p converts it into a piecewise function. Let’s give a concrete example, taking the two earlier rectangular pulses:

Symbolic Convolution in Nspire CAS

0, 00, 03( ) 1, 0 1, ( ) , 0 22

0, 1 0, 2

ttx t t h t t

t t

Page 54: Piecewise Functions and  Convolution Integrals

54

Definition ofboth signals.

Convolution ofboth signals.

Conversion to apiecewise function.

Simplification of theanswer and its graph.

Page 55: Piecewise Functions and  Convolution Integrals

55

Finally, the convolution of this output trapezoidal signal with d(t 1) should produce a translation of one unit on the right: that is the last trapezoidal output should move one unit to the right.Again, we will use a limit of indicator function in order to use a Dirac delta function.

Symbolic Convolution in Nspire CAS

Page 56: Piecewise Functions and  Convolution Integrals

56

Symbolic Convolution in Nspire CAS

The 2 signals.

We call the convolution ofthe 2 signals « output ».

We take an approximate unit-impulse.

The convolution of « output » with the approximate unit-impulse is a huge expression!But we know we will take the limit of this.

Page 57: Piecewise Functions and  Convolution Integrals

57

Symbolic Convolution in Nspire CAS

And the limit is exactly what we are expecting.The graph is the trapezoidal signal moved one unit to the right.

Page 58: Piecewise Functions and  Convolution Integrals

58

In 2006, at the beginning of Nspire CAS, Bernhard Kutzler proclaimed it as the “true successor of Derive”. Albert Rich would have disagreed…

Michel Beaudin, with the help of Frédérick Henri, wants to make Bernhard’s affirmation come true. But there is a lot more to be done, as far as the CAS part of the system is concerned.

Conclusion

Page 59: Piecewise Functions and  Convolution Integrals

59

This represents a fantastic opportunity to do mathematics and to discover, day after day, how Derive was special.

Helping Nspire CAS to become more powerful (in the CAS sense) represents my contribution to a product that gave me a lot of enthusiasm for the past 15 years!

Conclusion

Page 60: Piecewise Functions and  Convolution Integrals

60

Thank You!


Recommended