Integration on WP 34S
10-31-2021, 09:42 PM
Post: #1
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
Integration on WP 34S
Impressed at how well integration is handled on the WP 34S on my DM 42 platform. I was surprised to see that e^-x from 0 to infinity (yes, the WP 34S has the ability to enter infinity!) came out as 1. Most of my calculators will show “1” for an integration range from 0 to 1000, but will miss the important part of the function if integrated from, say, 0 to 10000, and report “0” (Prime in home does report “1” for large numbers). The HP 42S does see the important part of the function using 0 to 10,000 and does report 1.

Question: While the WP 34S does correctly “see” the important part of the function when using 0 to infinity, it, like most of my other calculators, shows “0” if I use an interval of 0 to 40000. Why does it work when using infinity, but fail for large specific numbers?
11-01-2021, 12:16 AM
Post: #2
 Albert Chan Senior Member Posts: 2,682 Joined: Jul 2018
RE: Integration on WP 34S
(10-31-2021 09:42 PM)lrdheat Wrote:  Question: While the WP 34S does correctly “see” the important part of the function when using 0 to infinity, it, like most of my other calculators, shows “0” if I use an interval of 0 to 40000. Why does it work when using infinity, but fail for large specific numbers?

DE integration algorithm start at the midpoint of two limit, and spread to the edges.
Sample points are then concentrated mostly to the edges.
For f(x) = exp(-x), sample points just underflowed to 0.0

Without underflow issues, it will handle it fine.
Example, mpmath is designed never underflow.

>>> from mpmath import *
(mpf('1.0'), mpf('1.0e-26'))

If you input limit of 0 to infinity, it does not have a finite top limit.
Points are exponentially spread out toward infinity.

It will not go too far though.
It is really doing two integral at once: $$\displaystyle \int_0^∞ = \int_0^1 + \int_1^∞$$

If the first integral dominates, it will stop the other from going too far.
If this is not the case, it will fail

lua> f = function(x) return exp(-k*x)*k end
lua> k = 1
0.9999999999876823 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 6.251443807136335e-012 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 131
lua> k = 1e-3
0.9999999990384378 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 7.2610534321713e-010 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 437
lua> k = 1e3