Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-17-2021, 11:45 PM
Post: #62
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-17-2021 01:51 PM)robve Wrote:  printf("%d diff=%g\n", 1 << i, f(a + d/v)/v - f(a + v*d)*v);
...
Note the 2i value when the diff sign changes, if it changes.

There may be a flaw with this ...

Example, we know exp(-0.01*x) on [0,inf], d ~ 700 is good
But, we can rewrite the integrand as exp(-0.01/x)/x^2, that has optimal d ~ 1/700

With sign checking method, both will suggest optimal d ~ 700.

lua> Q = require 'quad'
lua> f = function(x) return exp(-0.01*x) end
lua> g = function(x) return exp(-0.01/x)/(x*x) end
lua> Q.quad(Q.count(f), 0, huge, 700), Q.n
100       71
lua> Q.quad(Q.count(g), 0, huge, 1/700), Q.n
100       71

If we build g(x) = f(1/x)/x^2, both would use the *same* points, with orders swapped.
(points might have rounding errors with 1/x, but otherwise equivalent.)

The formula is just simple substitution, x = 1/y, dx = -dy/y^2

\(\displaystyle \int_a^∞ f(x)\,dx = \int_0^∞ f(x+a)\,dx = \int_0^∞ {f(1/y+a) \over y^2} dy\)
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-17-2021 11:45 PM



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