Adaptive Simpson and Romberg integration methods
|
03-26-2021, 05:52 PM
(This post was last modified: 03-26-2021 08:36 PM by robve.)
Post: #21
|
|||
|
|||
RE: Adaptive Simpson and Romberg integration methods
My guess is that VA uses Guass Kronrod with pre-computed tables of weights and abscissas that can give at up to 100-decimal digit precision. The highlighted part I saw somewhere in his comments, so...
Gauss Kronrod for I1 gives -0.946030174332872 with 735 evaluations and \( 10^{-15} \) precision: auto f2 = [](double x) { return cos(x)*log(x); } double Q = gauss_kronrod<double, 15>::integrate(f2, 0, 1, 5, 1E-15, &error) See NR2ed Ch.4.5 and Boost Math which I've used for this example. PS: for clarity, 100 digits refers to the internal Gauss-Kronrod points, not the integral precision. - Rob Edit: fixed ugly "Gauss" typo. "I count on old friends to remain rational" |
|||
03-26-2021, 06:35 PM
Post: #22
|
|||
|
|||
RE: Adaptive Simpson and Romberg integration methods
.
To: robve and Albert Chan: (03-26-2021 04:40 PM)robve Wrote: I noticed that all of the integrals in his post have two distinguishing features: they have a U shape (or inverted) on both or either end that makes them suitable to apply a transform before numerical integration, i.e. change of variable or u-substitution. The trick to pull this off in an implementation is basically to have an initial check of a few points to find evidence of a U on either end and then transform Seems to me we're talking different subject here. On the one hand, I'm talking about good quadrature methods that are simply given the function to integrate, the limits of integration and the accuracy to achieve and upon being run the method returns the result meeting the specified accuracy as fast as possible. Period. The user does nothing else other than supply the function, limits, and accuracy. He does not previously graph and analyze the function to see its shape, he does not study how to tame it if it needs taming, he does not do this or that transformation or another. He just supplies the function, limits and accuracy and nothing else, The method is the one which does all the work and returns a reliable result, fast. That's in the spirit of what Mr. Kahan says in the HP Journal, I quote (my highlighting):
My quadrature procedure P does exactly that, with the results seen in the 7 examples I posted. On the other hand, you're doing exactly the opposite: you're using some quadrature methods which can't deal with difficult integrands and improper integrals in general, and you are doing the "read and understand"-ing of the f(u) on behalf on the quadrature method, graphing the curve, inspecting it for spikes or singularities, etc., then applying some transformation decided by you (not the quadrature method) to spoon-feed it to it, such that it can cope and deliver some acceptable results in acceptable times. Then you go on and say that the method is "really, really good" !? Seriously: Are you joking ? Seems to me you're in a state of delusion, trying everything under the sun to reach the conclusion you want to reach (that the method is "really, really good"), instead of just throwing the function and the limits and desired accuracy to the method and letting it do what it can on its own, and if it cannot deliver reasonably without extensive help from the user, then you must simply recognize the fact and that's all, the world doesn't end. Had I provided that kind of help to my procedure for I1, it wouldn't need 512 evaluations, just 16 at most, but I didn't do it because I'm trying to test the method, not my mathematical ability to help it cope. Matter of fact, the very first integral, I1, can be proved to be equivalent to Sin(x)/x, which is orders of magnitude easier to integrate and has only a removable singularity at x = 0, but I didn't apply any transformations and instead let my procedure cope with it on its own, which it did. To wit, if this conversation is to be of any use, it's essential that we stick to a common ground, namely: you posit whatever methods you want to discuss but you let the methods do the work on their own, supplying them just the original f(x), not some transformation of it, the limits and the accuray, to afterwards judge them on their results and their speed. To begin with, try my 7 examples as-is (with no transformations or tricks whatsoever) using your preferred methods and post the results here so that we can discuss them and compare their respective performances. Agreed ? Regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
03-26-2021, 06:41 PM
(This post was last modified: 03-26-2021 06:47 PM by robve.)
Post: #23
|
|||
|
|||
RE: Adaptive Simpson and Romberg integration methods
(03-25-2021 11:57 PM)Valentin Albillo Wrote: Note: In everything that follows, no offence is ever meant, it's just my trademark style when I feel skeptic (let's say) about some statement or other, in particular if not supported by facts. IMHO, of course. No offense. As I told my former students, critical thinking is important and do not stop questioning, but use the answers to analyze ideas and adjust them accordingly. We all build on existing work published by others and give credit for their efforts. I am not sure what to think of statements like that and the references to "my method", which I never have used. I noticed that "your method" pzer on the HP-71B in every detail implements the standard Weierstrass / Durand-Kerner method for polynomial complex root finding aka "root polishing". I easily spotted this, because of the way you've set up the initial roots and the root polishing. Yet, nowhere is Durand-Kerner mentioned in your article. Further, it is the most bare and simple implementation. There is actually more we can do beyond the basics, such as 1) removing trailing (in the code, leading in the poly) zero coefficients before polishing the roots, since these do not contribute to the result; 2) reject insignificant nonzero real or imaginary parts in the roots finally found. These require a little bit of code and incur almost no overhead. These additions are quite easy and often found in implementations. So no offense as my post is derived from public existing work anyway, just like yours is. - Rob "I count on old friends to remain rational" |
|||
03-26-2021, 07:17 PM
(This post was last modified: 03-26-2021 07:49 PM by robve.)
Post: #24
|
|||
|
|||
RE: Adaptive Simpson and Romberg integration methods
(03-26-2021 05:52 PM)robve Wrote: My guess is that VA uses Guass Kronrod with pre-computed tables of weights and abscissas that can give at up to 100-decimal digit precision. The highlighted part I saw somewhere in his comments, so... Definitely just Gauss-Kronrod or/with double-exponential quadrature e.g. using tanh-sinh or similar: The tanh_sinh integration routine will use this additional information internally when performing range transformation, so that for example, if one end of the range is zero (or infinite) then our transformations will get arbitrarily close to the endpoint without precision loss. This gives the exact answer with only 74 evaluations: -0.946083070367183 auto f2 = [](double x) {return cos(x)*log(x); }; tanh_sinh<double> integrator; double Q = integrator.integrate(f2, 0.0, 1.0); The choice of tanh-sinh is usually, but not always, appropriate. The nice thing is that there are no bells and whistles, no parameters to figure out. Again, this is not new and the method(s) are suitable for handling integrals with either singularities or large values near one or both endpoint(s), i.e. the U shape Albert commented on that we referred to earlier. Such shape issues can be resolved in several ways, sometimes by transformation or by picking a suitable integrator that does it (semi)-automatically. PS. For info on double exponential integration and its implementation on the wp34S, see: https://www.hpmuseum.org/forum/thread-8021.html - Rob Edit: added link to tanh-sinh and HP forum link. "I count on old friends to remain rational" |
|||
03-26-2021, 08:22 PM
Post: #25
|
|||
|
|||
RE: Adaptive Simpson and Romberg integration methods
To: robve (03-26-2021 06:41 PM)robve Wrote:(03-25-2021 11:57 PM)Valentin Albillo Wrote: Note: In everything that follows, no offence is ever meant, it's just my trademark style when I feel skeptic (let's say) about some statement or other, in particular if not supported by facts. IMHO, of course. What does this have to do with the integration methods we were discussing in this thread ??!!? Is this intended as some kind of retaliatory ad-hominem attack by implying I don't give due credit or something ? Have you read my 40+ articles and noticed how they're being construed for the last 20+ years ? Why would you do this, other than because you did take offence despite you denying it ? For the benefit of the readers, robve sent me a PM almost a month ago about this and I kindly replied the following to him on 03-10-2021, 12:06 AM, that he seems to have forgotten. I quote my PM reply to him:
Seems robve forgot or simply didn't want to ruin his uncalled-for ad-hominem attack by including my reply here. Quote:There is actually more we can do beyond the basics, such as 1) removing trailing (in the code, leading in the poly) zero coefficients before polishing the roots, since these do not contribute to the result; 2) reject insignificant nonzero real or imaginary parts in the roots finally found. These require a little bit of code and incur almost no overhead. These additions are quite easy and often found in implementations. Again, this is but a very poorly disguised attack on the quality of my implementations by mentioning that they're basic and can be easily improved. He seems to have conveniently forgotten (again!) my reply to this in the very same PM or else he doesn't see fit to include it here, so I'll do it myself. I replied to him:
Also, I see that you haven't read or at any rate don't comment on my on-topic (integration !!) post #22, but that's irrelevant now. Listen, I'm no fool and can clearly see by this post of yours a very many things that I'm itching to say but can't and won't discuss in public lest they'd be considered ad-hominens, but also I'm not a person to suffer them gladly as well, nor the kind of individuals who issue them, so please take note of the following:
All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
03-27-2021, 12:57 AM
Post: #26
|
|||
|
|||
RE: Adaptive Simpson and Romberg integration methods
I am calling a time out on this thread.
Gene |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)