Accuracy of Integral with epsilon

10102021, 02:07 PM
Post: #21




RE: Accuracy of Integral with epsilon
(10102021 11:51 AM)Albert Chan Wrote:(10092021 09:50 PM)robve Wrote: You do realize that it is a fallacy to assume exp(x) and cosh(x)+sinh(x) equate numerically, in addition to algebraically? You're right. To summarize: 1. cosh(x)+sinh(x) suffers from catastrophic cancellation for negative x, with ~x digits lost, e.g. cosh(10)+sinh(10)exp(10) = 0.000000099 and it is worse when taking exp(10)/(cosh(10)+sinh(10)) = 1.0022 (depending on the calculator's precision) 2. sinh(x) implementations may use sinh(x) = (z+z/(z+1))/2 with z=expm1(x), which improves the accuracy of sinh(x) for x<0 whereas cosh(x) is unaffected, as another example when algebraic identities may not hold numerically. 3. floating point noise not contributed by the above. This integrand is a really bad one to compare numerical integration on calculators. The results are not all that meaningful. Picking eps=10^4 does not necessarily help to prevent issues, see point 1. I might wager that a less sophisticated calculator may produce a more "accurate" result close to 40. As a funny consequence of playing around with this for a bit, I found a bug in Boost TanhSinh that produces 20 as the answer to the integral \( \int_{10}^{10} 2\,dx \). I could not believe it at first, but it is a specific problem.  Rob "I count on old friends to remain rational" 

« Next Oldest  Next Newest »

User(s) browsing this thread: