HP Forums

Full Version: Integration methods...an error-proof method?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all.

Although methods like Simpson's and Trapezoidal need evaluation at the endpoint, I can see a minefield if either endpoint produces a mathematical discontinuity or undefined result thus causing an HP-67, 41, etc. program to stop. So, it seems that error-checking or implementing an error-handling flag setting (HP-41, 42, etc.). Thus, further necessitating error-handling program code.

So, rather than this approach, what are some improved integration methods to avoid, aleviate, bypass, or resolve discontinuities in functions?

Thanks.
The modified Romberg method used by the HP-71B Math Pac avoids that problem by avoiding the endpoints altogether. It also has some other features as explained on page 118 of the owner's manual. You can read that page here: http://holyjoe.net/HP71/integral.htm
(09-02-2017 10:21 PM)Joe Horn Wrote: [ -> ]The modified Romberg method used by the HP-71B Math Pac avoids that problem by avoiding the endpoints altogether. It also has some other features as explained on page 118 of the owner's manual. You can read that page here: http://holyjoe.net/HP71/integral.htm

Thanks. As I do not have a 71B, is there a port to the 67 or 41?

Also, how does this algorithm differ from the Romberg Integration program found in the program from the Math/Utilities module for TI-58/59?
(09-02-2017 10:43 PM)Matt Agajanian Wrote: [ -> ]Thanks. As I do not have a 71B, is there a port to the 67 or 41?

The HP-41 PPC ROM contains a routine called IG (InteGrate) which uses a modified Romberg, similar to the HP-71's Math Pac. Its code and some commentary can be found here: https://coertvonk.com/technology/hp41/integrate-4625

There are a few other implementations of Romberg for the HP-41 here: http://www.hpmuseum.org/software/41/41rombrg.htm

There are a BUNCH of various integration programs for the HP-41 in the "Differentiation & Integration" section of this page: http://hp41programs.yolasite.com/

(09-02-2017 10:43 PM)Matt Agajanian Wrote: [ -> ]Also, how does this algorithm differ from the Romberg Integration program found in the program from the Math/Utilities module for TI-58/59?

Anybody? Anybody? Bueller?
I would say: do the math. Analyse any "bad behaviour" and either factor (transform) it out or use an algorithm that is suited to the particular type of issue(s) (thinking of Gauss-Legendre with weight functions for example). Of course chopping up the interval of integration to isolate the issues as much as you can first is probably a good idea as well.

But perhaps I am just too old to expect any silver bullets...
(09-02-2017 09:42 PM)Matt Agajanian Wrote: [ -> ]So, rather than this approach, what are some improved integration methods to avoid, aleviate, bypass, or resolve discontinuities in functions?

Avoiding the endpoints is straightforward, the rectangle method can do this by evaluating the rectangle mid-points.

I suspect this is impossible in general. A discontinuity between two evaluation points is going to be impossible to detect. Where both sides run to opposite signed infinities can be detected (e.g. tangent) but I'm not sure how helpful that is -- the area under each side could be infinite and then there is the question as to what infinity - infinity means?

Avoiding undefined evaluation points seems problematic -- it would be possible to shift the point on error and increase the resolution around the failure which would be a start. I'm sure it could be tricked up easily.


Pauli
Let me rephrase my earlier response: if your aim is to get an accurate approximation of the integral then you should not (use algorthims that) avoid "singularities", but you need to embrace, understand and deal with them.

Simply avoiding them (i.e. sweeping them under the rug) will give you an answer, but no indication as to how (in)accurate that answer is.
(09-03-2017 05:24 AM)AlexFekken Wrote: [ -> ]Simply avoiding them (i.e. sweeping them under the rug) will give you an answer, but no indication as to how (in)accurate that answer is.

Exactly.


Pauli
In the mean time (lazy Sunday afternoon), I have come to realise that this is not just an issue when there are "discontinuities" or other types of singularities are in play.

This is one way how you can "trick up" (as suggested by Pauli) most algorithms:

Select an arbitrarily small but postive number eps and an arbitrary "value" V. For example chose eps as the smallest positive number that your system can represent, and V as the largest...

You can then construct a function that has the following properties:

- it is arbitrarily smooth everywhere (i.e. it can be differentiated everywhere and as often as you like; this also implies continuity of the function and all of its derivatives everywhere)
- the function is 0 everywhere except inside the open interval (0, eps)
- the integral over [0, eps] is V
- you can make it unimodal (a single bump), i.e. you need no weird oscillations and/or jumps to construct it.

I have only added the unimodal bit so that you do not think that this would have to be a very special, "artificial" function... Explicit details for constructing such a function are in many textbooks on analysis; typically, only the exponential function is used beyond +, -, * and / (think exp(-1/x^2) and be creative).

Now you can add this "bump" to an arbitrary function f to obtain a new function g so that

- g = f everywhere except inside the tiny interval (0,eps)
- g is just as smooth as f
- the integral of g, over any interval including [0, eps], differs by V from the integral of f

In other words: as long as you don't investigate inside (0,eps) you cannot distinguish between f and g and yet their integrals differ by as much as you like.
Reference URL's