(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
|
04-02-2021, 07:12 PM
Post: #14
|
|||
|
|||
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(03-29-2021 07:42 PM)robve Wrote: sqrt(x / (1 - x * x)) Can you explain what that meant ? Perhaps an example ? To avoid garbage of x close to 1, I would have rewrite the integrand, with infinity at x=0. (y=1-x², dy = -2x dx, would solved it exactly. But, no cheating ...) ∫(x/√(1-x²), x=0..1) = ∫((1-x)/√(x*(2-x)), x=0..1) With infinity moved, at x=0, we can add many, many more points. Since e^x grow faster than x^n, we have e^-x shrink faster then x^-n, for finite n. ∫(f(x), x=0 .. 1) = ∫f(e^-y)*(e^-y), y=0 .. inf) Code: def e_transform(f, exp=exp): # interval [0,1] -> [0,inf] >>> f = lambda x: (1-x)/sqrt(x*(2-x)) >>> ef = e_transform(f) >>> quadts(f, [0, 1]) 0.999999999624821 >>> quadts(ef, [0, inf]) 1.0 Similar results, with Gauss-Legendre quadrature: >>> quadgl(f, [0, 1]) 0.993619917982059 >>> quadgl(ef, [0, inf]) 1.0 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)