Accuracy of Integral with epsilon
10-09-2021, 02:01 PM
Post: #15
 robve Member Posts: 287 Joined: Sep 2020
RE: Accuracy of Integral with epsilon
(10-09-2021 01:41 AM)robve Wrote:
(10-08-2021 11:28 PM)lrdheat Wrote:  Did not think the integral was remarkable, but was fascinated by how different calculators handled it as written. My Prime in home shows 40.0000000143 (!). Impressed with the WP 34S.

I did a quick check with my implementation: for a specified accuracy of eps=10^-4 Tanh-Sinh only performs 27 integrand evaluations to converge to 40 exactly, or at least very close (depends on the floating point format, single/double IEEE 754 or BCD etc.)

The WP 34S uses Tanh-Sinh. That implementation can be improved though.

WP 34S results with a IEEE 754 based implementation matching the Python code given by the author:
eps=10^-4: abs error = 0.0051939; est. error = 0.0155524; evals = 7
eps=10^-5: abs error = 0.000130107; est. error = 0.0156835; evals = 9
eps=10^-6: abs error = 0.000121986; est. error = 6.30233e-06; evals = 17
eps=10^-7: abs error = 2.14894e-06; est. error = 3.30639e-06; evals = 19
eps=10^-8: abs error = 2.14894e-06; est. error = 3.30639e-06; evals = 19
eps=10^-9: abs error = 5.81537e-09; est. error = 3.35997e-06; evals = 21

Note that the given eps is not necessarily smaller than the abs error obtained ("under delivers"). Only the last result delivers a decent estimate. Whether or not the convergence check is satisfied with the estimated error is a detail that may differ in the implementation(s) of Tanh-Sinh, thus eps=10^4 may produce a better answer for some, but to get the better answer 19, 21 or more evaluations are needed to get close enough.

The qthsh implementation (discussed on the HP forum thread) of the same algorithm with some differences has 27 evaluations for eps=10^4 with small abs error 5.63299e-09. Qthsh approaches integration boundaries more consistently, evaluating additional boundary points by handling singularities instead of terminating early. Otherwise the algorithms are the same. This explains why qthsh has 27 versus WP 34S 21 evaluations. Like the WP 34S, qthsh was verified and compared to WP 34S and other algorithms, including a verification of accuracy with over 800 integrals.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
 « Next Oldest | Next Newest »

 Messages In This Thread Accuracy of Integral with epsilon - lrdheat - 10-08-2021, 09:57 PM RE: Accuracy of Integral with epsilon - toml_12953 - 10-08-2021, 10:17 PM RE: Accuracy of Integral with epsilon - Thomas Okken - 10-08-2021, 10:18 PM RE: Accuracy of Integral with epsilon - toml_12953 - 10-08-2021, 10:28 PM RE: Accuracy of Integral with epsilon - lrdheat - 10-08-2021, 11:28 PM RE: Accuracy of Integral with epsilon - toml_12953 - 10-09-2021, 12:47 AM RE: Accuracy of Integral with epsilon - robve - 10-09-2021, 01:41 AM RE: Accuracy of Integral with epsilon - Valentin Albillo - 10-09-2021, 02:22 AM RE: Accuracy of Integral with epsilon - Paul Dale - 10-09-2021, 02:27 AM RE: Accuracy of Integral with epsilon - Thomas Okken - 10-09-2021, 08:47 AM RE: Accuracy of Integral with epsilon - John Keith - 10-09-2021, 05:40 PM RE: Accuracy of Integral with epsilon - robve - 10-09-2021, 08:37 PM RE: Accuracy of Integral with epsilon - Claudio L. - 10-12-2021, 04:47 PM RE: Accuracy of Integral with epsilon - robve - 10-14-2021, 02:43 AM RE: Accuracy of Integral with epsilon - robve - 10-09-2021, 09:50 PM RE: Accuracy of Integral with epsilon - Albert Chan - 10-10-2021, 11:51 AM RE: Accuracy of Integral with epsilon - robve - 10-10-2021, 02:07 PM RE: Accuracy of Integral with epsilon - robve - 10-09-2021 02:01 PM RE: Accuracy of Integral with epsilon - lrdheat - 10-09-2021, 03:13 AM RE: Accuracy of Integral with epsilon - toml_12953 - 10-09-2021, 05:44 AM RE: Accuracy of Integral with epsilon - toml_12953 - 10-09-2021, 11:26 AM RE: Accuracy of Integral with epsilon - lrdheat - 10-09-2021, 05:16 AM RE: Accuracy of Integral with epsilon - lrdheat - 10-09-2021, 03:25 PM

User(s) browsing this thread: 1 Guest(s)