1 / 66

Integration of Piecewise Continuous Functions

Integration of Piecewise Continuous Functions. Michel Beaudin, Frédérick Henri, Geneviève Savard ÉTS, Montréal, Canada. ACA 2013 Applications of Computer Algebra Session: Applications and Libraries Development in Derive and TI- Nspire Malaga, Spain, July 2-6. Abstract.

nan
Télécharger la présentation

Integration of Piecewise Continuous Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Integration of Piecewise Continuous Functions Michel Beaudin, Frédérick Henri, Geneviève Savard ÉTS, Montréal, Canada ACA 2013 Applications of Computer Algebra Session: Applications and Libraries Development in Derive and TI-Nspire Malaga, Spain, July 2-6

  2. Abstract Piecewise functions are important in applied mathematics and engineering students need to deal with them often. In Nspire CAS, templates are an easy way to define piecewise functions; in DERIVE, linear combination of indicator functions can be used. Nspire CAS integrates symbolically any piecewise continuous function ─ and returns, as expected, an everywhere continuous antiderivative ─ as long as this function is not multiplied by another expression. DERIVEknows how to integrate sign(a x + b) f(x) where f is an arbitrary function, a and b real numbers and “sign” stands for the signum function: this is why products of a piecewise function with any other expression can be integrated symbolically. This will be the first part of our talk. In the second part of this talk, we will show some implementations that will allow Nspire CAS to integrate symbolically products of piecewise functions with expressions: the starting point was the discovery of a non-documented function of Nspire CAS. Examples of various operations between two piecewise functions will be given. As a final example, we will show how we have defined a Fourier series function in Nspire CAS that performs as well as DERIVE’s built-in “Fourier” function. Keywords: Piecewise functions, integration, Fourier series.

  3. Overview • Integration of piecewise continuous functions: some problems with Nspire • No problem with DERIVE! Why? • Our solution: Programming new functions in Nspire • Some applications: Fourier Series and deSolve • Conclusion I II

  4. Integration of Piecewise Continuous Functions: Problems with Nspire

  5. Integration of Piecewise ContinuousFunctions: Problems with Nspire WhatNspiredoeswell : Nspire has a nice template that helps the user define piecewise continuous functions. Symbolic integration of this kind of function will be performed by Nspire CAS. Nspireadjusts the constants of integrationsuchthatf2is a continuousfunction.

  6. Integration of Piecewise ContinuousFunctions: Problems with Nspire

  7. Integration of Piecewise ContinuousFunctions: Problems with Nspire A problem arises when ∞ appears in one of the subdomains. Nspire can’t compute the antiderivative of this function... ....nor this function.

  8. Integration of Piecewise ContinuousFunctions: Problems with Nspire A problem occurswhen the piecewisefunctionismultipliedby another function (even a very simple one). Nspire can’t find the antiderivative.

  9. Integration of Piecewise ContinuousFunctions: Problems with Nspire A problem occurswhen we multiply 2 piecewise functions. Nspire can’t compute the exact value… because it does not simplify the product into a single piecewise function.

  10. No Problem with DERIVE! Why? • Definingpiecewisefunctionswithsomebuilt-in functions(CHI, SIGN, STEP) • A veryusefulintegrationrule

  11. No problem with DERIVE! Why? Defining Piecewise Functions • Instead of templates, we may use indicator functions to define piecewise functions in DERIVE. • In DERIVE, Indicator (CHI), Signum (SIGN) and Heaviside (STEP) functions are built-in; in Nspire CAS, only signis implemented.

  12. No problem with DERIVE! Why? Defining Piecewise Functions DERIVE uses the following definitions:

  13. No problem with DERIVE! Why? Defining Piecewise Functions Even though STEP and CHI are not built-in in Nspire, one can easily define them.

  14. No problem with DERIVE! Why? Defining Piecewise Functions For example, if we need the piece of f(x) between -2 and 1, we just multiply f(x) by CHI(-2, x, 1): Values at the extremities of the subintervals are irrelevant, as far as integration is concerned. We define piecewise functions in DERIVE as a combination of CHI functions.

  15. No problem with DERIVE! Why? Defining Piecewise Functions An other example : )

  16. No problem with DERIVE! Why? Integrating Piecewise Functions Nspire DERIVE Bothsystemscanintegrate the piecewisefunctionf1(x).

  17. No problem with DERIVE! Why? Integrating Piecewise Functions Nspire DERIVE As youcansee, the constants of integrationdiffer.

  18. No problem with DERIVE! Why? Integrating Product with Piecewise Functions We have seen that Nspire CAS is unable to integrate symbolically a product of a piecewise function with another expression. Can DERIVEfindthe antiderivative?

  19. No problem with DERIVE! Why? Integrating Product with Piecewise Functions DERIVEis able to computethe antiderivative of f1(x)cos(x).

  20. No problem with DERIVE! Why? Integrating Product of 2 Piecewise Functions We have seen that Nspire CAS is unable to integrate symbolically a product of 2 piecewise function.

  21. No problem with DERIVE! Why? Integrating Product of 2 Piecewise Functions Let’s compute the same integration with DERIVE. The exact value. DERIVEunifies the product into a combination of SIGN functions. 21

  22. No problem with DERIVE! Why? The reasons: • Piecewise functions are defined as a combination of CHI functions (and this simplifies to SIGN functions). • DERIVEknows the rule R1

  23. No problem with DERIVE! Why? R1 This rule is combined with the following rule when DERIVE computes an integral involving an absolute value. For example,

  24. Our Solution: Programming New Functions in Nspire

  25. Programming New Functions in Nspire Because Nspire CAS is able to integrate symbolically a uniquepiecewise function (as long as no infinity appears in the domain!)we thought : to transform the product f1(x)f2(x)into a single piecewise function, to “remove” every occurence of “infinity” in the domain, and to use the built-in integrator to compute definite or indefinite integrals.

  26. Programming New Functions in Nspire We want Nspire CAS to continue using its own − attractive − templates instead of using indicator functions. 26

  27. Programming New Functions in Nspire • grouper_fctgroups in a single piecewise functionan expression that contains one or more piecewise subexpressions. • fct_sans_infiniremoves every occurenceof ∞ or -∞ in the domain. • integral_mcxsymbolically integrates (indefinite integral) and integral_mcx_dcomputes exactly the definite integral using the built-in integrator. Our colleague Frédérick Henri (“Fred”) has programmed some simple but quite efficient functions.

  28. Programming New Functions in Nspire A few examples… Nspire is unable to unify the product. grouper_fct return a single piecewise function

  29. Programming New Functions in Nspire A few examples… integral_mcx_d computes exactly the definite integral. Without Fred’s package : no exact value.

  30. Programming New Functions in Nspire We observe the same result when using DERIVE.

  31. Programming New Functions in Nspire grouper_fct also works with exponentiation. integral_mcxintegrates symbolically (indefinite integral) .

  32. Programming New Functions in Nspire Let’s explain some simple algorithms and show some code. First of all, in order to manipulate piecewise functions, we need a command to extract pieces of the function. Extraction is not documented into Nspire CAS user guide, but the following “discovery” saved us! part()

  33. Programming New Functions in Nspire

  34. Programming New Functions in Nspire + + 8x 9yz * * 8 x z * 9 y part()issimilarto Maple’s op()

  35. Programming New Functions in Nspire unifier_fcts(f1(x), "/", f2(x), x) = = = =

  36. Programming New Functions in Nspire Thenfct_sans_infini(f3(x))

  37. Programming New Functions in Nspire grouper_fct(f, x): generalizesunifier_fcts by workingrecursively (in case of more complicatedfunctions).

  38. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f * part(f,0) part(f,1) part(f,2) part(f,1)

  39. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f f * part(f,0) + part(f,2) part(f,1) 6x 1 f doesn’tcontainpiecewisesubexp.Return 6x+1

  40. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f f * part(f,0) + part(f,2) 6x+1 f1(x) 5 part(f,1) part(f,2)

  41. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f f * part(f,0) + 6x+1 f1(x) part(f,2) 5 part(f,1) part(f,2)

  42. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f f * part(f,0) f2(x) • 6x+1 • f1(x)

  43. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f * part(f,0) f2(x) • 6x+1 • f1(x)

  44. Programming New Functions in Nspire grouper_fct(f, x) :=operator := part(f, 0) Iff doesn’tcontain a piecewisesubexpressionThen Return f Else f1(x):= grouper_fct(part(f, 1), x) f2(x):= grouper_fct(part(f, 2), x) Returnunifier_fcts(f1(x), operator, f2(x), x) Endif f

  45. Some Applications: Fourier Series and deSolve with Nspire

  46. Some Applications: Fourier Series Let us recall that if an expression f of the variable t is defined over the interval t1 < t < t2 and extended outside the interval by periodicity (the period being P = t2 - t1), then the Fourier polynomial of order n of f is the following trigonometric polynomial:

  47. Some Applications: Fourier Series And this is DERIVE’s definition from the library “Applications of Integration”.

  48. Some Applications: Fourier Series At ETS, when students need to compute the Fourier coefficients of a periodic signal, they use their TI-Nspire CX CAS handheld to compute the integrals (for the Fourier coefficients). Then, they store the coefficients and are able to produce any partial sum in exact arithmetic.

  49. Some Applications: Fourier Series Here is an example. Students are asked to find the Fourier series of the following 2 - periodic signal. The signal is neither odd nor even. So, using Nspire CAS, we compute the Fourier coefficients, splitting the integrals ourselves into two parts!

  50. Some Applications: Fourier Series We split the integrals into two parts. Then we “inform” Nspire CAS that “n” is an integer (in order to simplify the Fourier coefficients).

More Related