Problem with integral on WP 34s
|
09-15-2021, 07:41 AM
Post: #27
|
|||
|
|||
RE: Problem with integral on WP 34s
Hi, lrdheat
For tanh-sinh, a to b, c = (a+b)/2, sample points f(c), then f(c-d*r), f(c+d*r) For sinh-sinh, -∞ to ∞, c = 0, sample points f(c), then f(c-d*r), f(c+d*r) For exp-sinh, a to ∞, c = a, sample points f(c+d), then f(c+d/r), f(c+d*r) This may be over-simplified. see double_exponential.py https://www.hpmuseum.org/forum/thread-16549.html https://www.hpmuseum.org/forum/thread-16...#pid148080 f(x) = x*exp(-x), important part is from 0 to 10, peak at 1.0 After peak, it decay fast f(0) = 0 f(1) ≈ 0.368 (peak) f(10) ≈ 0.000454 f(20) ≈ 0.0000000412 f(30) ≈ 0.00000000000281 Convergence is based from previous estimate, with 1st sample point f(c) If we integrate from 0 .. 1e6, f(c=5e5) ≈ 2.87E-217142, underflow to 0.0 Next estimate also 0.0 ... it "converged" Or course, if system designed not to underflow, it still work (but not great) With more reasonable limits, we get better result. >>> from double_exponential import * >>> f = lambda x: x*exp(-x) >>> double_exponential(f, 0, 1e6) (mpf('0.99999999958767749'), mpf('0.00028631970183223832'), 197, 5, 0, [ mpf('0.019275511359964845'), mpf('0.009934112577158722'), mpf('0.40518132830865922'), mpf('1.0876426215773149'), mpf('0.99971367988584525'), mpf('0.99999999958767749') ]) >>> double_exponential(f, 0, 100) (mpf('1.0'), mpf('1.7892954451426135e-8'), 93, 4, 0, [ mpf('2.458125108263046'), mpf('1.2794193804039591'), mpf('1.0055096455855115'), mpf('1.0000000178929545'), mpf('1.0') ]) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)