Solve for upper/lower bound of a numerical definite integral

If you’re worried about accumulated errors, the best approach is probably to compute first to low precision (.1 or so), and then restart with that as a guess. This will take much less than 2x the time (since the second newton pass will converge very quickly since you start close to the right answer), but should prevent excessive back and forths causing cancellation issues.

Roots.jl do the job. Thanks

@carloslesmes, could you post the solution that you have found using Roots,jl?

Another way is to write the problem like this:

\\ \int_a^x f(x')dx'=K(x)\\ \\ \frac{d}{dx}K(x) = f(x),\quad K(a)=0

Use Differential Equations to solve for K(x) and then use interpolation to find the solution:
DiffEqs_to_solve_definite_integral

NB: I have updated the code above under solution#4

Hi
Suppose you’re to solve for x:

\int_{0}^{x} 5(1-t)^{4} dt=0.9
using Roots, QuadGK
f1(x)=5(1-x)^4
f2(x)=quadgk(f,0,x)[1]-0.9
find_zero(g,0.5)
2 Likes