Comments (4)
The change of variables only works reliably for 1/x^λ
for λ>=2
. If λ>1
the change of variables gives a singular integrand (with a converging integral) for which quadgk
may or may not converge for a given λ
depending on the error tolerances. Here is a figure showing what happens to the transformed problem
julia> function integrand(t, λ)
return 1/(1+t/(1-t))^λ * 1/(1-t)^2
end
integrand (generic function with 2 methods)
julia> using Plots
julia> plt = plot(; xguide="t", yguide="1/(1+t/(1-t))^λ * 1/(1-t)^2", xlims=(0,1), ylims=(0,2));
julia> for λ in [1.1, 1.5, 1.9, 2.0, 2.1, 2.5]; plot!(plt, range(0, 1, length=1000), t -> integrand(t, λ), label="λ=$λ"); end
julia> plt
So the fix is to apply a change of variables of the form x = y^a
to your integrand that removes the endpoint singularity so that dx/x^λ = a*y^(a-1)*dy/y^(λ*a) = a*dy/y^((λ-1)*a+1)
with (λ-1)*a+1 > 2
or a > 1/(λ-1)
. Here is your solution
julia> quadgk(y->10*y^9/(y^10)^1.1,1,Inf)
(9.999999999999993, 1.7763568394002505e-15)
from quadgk.jl.
Basically, if you have a badly behaved integrand and request too low an error tolerance (e.g. the default is rtol ≈ 1e-8
), then it may subdivide the integration integral closer and closer to the endpoint until roundoff errors cause it to evaluate at the endpoint, or close enough to the endpoint to cause an error..
It might be worth including a check for this (quadrature point == endpoint) in the rule evaluation, and if so stop refining (since at this point the floating-point precision will make it impossible to go further, and also we should never evaluate integrands exactly at endpoints).
However, in this case, it is evaluating at 0.9999999999999964
, not exactly at the endpoint?
from quadgk.jl.
I think 0.9999999999999964
is just the midpoint of the most refined interval, (0.9999999999999929, 1.0)
, and since the GK nodes cluster at the boundaries of the interval there is at least one node that rounds off to the endpoint
julia> using QuadGK
julia> x_end = -QuadGK.cachedrule(Float64, 7)[1][1] # outermost point in GK rule on [-1,1]
0.9914553711208126
julia> t_a, t_b = (0.9999999999999929, 1.0) # problem interval in transformed domain
(0.9999999999999929, 1.0)
julia> t_end = t_a + ((t_b - t_a)/2)*(1+x_end) # roundoff of outermost GK node to endpoint
1.0
from quadgk.jl.
With #91 the result of the OP would become
julia> quadgk(x->1/x^1.1,1,Inf)
(9.772220920299873, 0.011179284983380486)
which has underestimated error
from quadgk.jl.
Related Issues (20)
- confusion in kronrod() documentation? HOT 1
- Documentation suggestion
- TagBot trigger issue HOT 13
- AD compatibility HOT 1
- How to cite QuadGK HOT 1
- Compatibility with CUDA.jl HOT 2
- Possible regression using quadgk function and Unitful limits HOT 9
- unitful infinite bounds
- order=1 seems børked HOT 1
- contour integration HOT 1
- documentation build is failing HOT 4
- Autodiff of `quadgk` HOT 2
- Can not catch a JuliaError caused by function blowing up to infinity HOT 2
- misleading error estimate for non-convergent integral (maxevals=10^7 reached) HOT 5
- No cachedrule for DynamicQuantities types HOT 4
- Regression with [email protected] HOT 6
- spurious underflow in kronrod for large n HOT 1
- infinite limits with units and segbuf broken
- quadgk with identical lower and upper bound is broken HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quadgk.jl.