Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-15-2021, 10:38 PM (This post was last modified: 04-16-2021 01:15 PM by Albert Chan.)
Post: #58
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-15-2021 09:29 PM)robve Wrote:  The derivation to select d=700 for the integrand exp(-0.01*y) is clear, except for the
initial requirement that is not obvious from the integrand and interval: exp(-0.01y) = 0.001

My aim is to pick d such that \(\int_0^d\) covered bulk of the area, less work for \(\int_d^∞\)
Based on experience with plots, if value is below 1/1000 of peak, it seems to touch the x-axis.

Actual number is not that critical. Hitting exact 100 is just lucky.

lua> Q = require 'quad'
lua> f2 = function(x) return exp(-0.01*x) end
lua> for d=500,1500,100 do print(d, Q.quad(Q.count(f2), 0, huge, d), Q.n) end

500    99.99999999999997    71
600    100                  71
700    100                  71
800    99.99999999999997    71
900    99.99999999999999    71
1000   99.99999999999997    71
1100   99.99999999999997    71
1200   99.99999999999997    71
1300   99.99999999999999    71
1400   99.99999999999996    71
1500   99.99999999999997    71


Note that we could accomplish the same by compressing the function, by factor d

lua> x, d = 20, 512
lua> f2(x) * 100 -- exact result, for \(\int_x^∞\)
81.87307530779819

lua> f3 = function(d) return function(x) return f2(x*d)*d end end
lua> Q.quad(Q.count(f3(d)), x/d, huge/d), Q.n
81.87307530779817       69

lua> Q.quad(Q.count(f2), x, huge, d), Q.n
81.87307530779817       69

Both expressions are equivalent (because I picked d = power-of-2)
But setting d is cost free, and less messy.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature - Albert Chan - 04-15-2021 10:38 PM



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