Thanks @j_verzani, it seems like there is no error now. However, I do not see any effect of decreasing the tolerance on the result.
This is my function
function E_of_I_dw_above(I::ArbFloat, λ::ArbFloat; Emax=ArbFloat(5), maxiters=20, atol=eps(), rtol=eps(), xatol=eps(), xrtol=eps())
Emin = 0.0
I, λ, Emin, Emax = promote(I, λ, Emin, Emax)
I, atol, rtol, xatol, xrtol = promote(I, atol, rtol, xatol, xrtol)
# making sure that Emax is large enough
while I_dw_above(Emax, λ) < I
# Emax is too small
Emax = 2*Emax
end
EdE_pair_for_prob = (E -> I_dw_above(E, λ) - I, E -> dIdE_dw_above(E, λ))
E_prob = ZeroProblem(EdE_pair_for_prob, (Emin, Emax))
solve(E_prob, Roots.LithBoonkkampIJzermanBracket(), maxiters=maxiters, atol=atol, rtol=rtol, xatol=xatol, xrtol=xrtol)
end
E_of_I_dw_above(I, λ; Emax=10.0, maxiters=20, atol=eps(), rtol=eps(), xatol=eps(), xrtol=eps()) = E_of_I_dw_above(ArbFloat(I), ArbFloat(λ); Emax=Emax, maxiters=maxiters, atol=atol, rtol=rtol, xatol=xatol, xrtol=xrtol)
And I get the following:
E_of_I_dw_above(0.5, 0.1)
# 0.02888908568904820499569305844526
E_of_I_dw_above(0.5, 0.1, atol=ArbFloat(1e-60), rtol=ArbFloat(1e-60), xatol=ArbFloat(1e-60), xrtol=ArbFloat(1e-60))
# 0.0288890856890482049956930584451
bits = 400
E_of_I_dw_above(ArbFloat(0.5, bits=bits), ArbFloat(0.1, bits=bits))
# 0.02888908568904820499569305844469
E_of_I_dw_above(ArbFloat(0.5, bits=bits), ArbFloat(0.1, bits=bits), atol=ArbFloat(1e-60), rtol=ArbFloat(1e-60), xatol=ArbFloat(1e-60), xrtol=ArbFloat(1e-60))
# 0.0288890856890482049956930584451
What am I doing wrong?
About your advise regarding the accuracy. I am now using a bracketing method, LithBoonkkampIJzermanBracket
. Does this mean that I cannot improve the accuracy?