Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expint(nu,z) has bad precision for nu != 1 #453

Open
djturizo opened this issue Nov 26, 2023 · 0 comments
Open

expint(nu,z) has bad precision for nu != 1 #453

djturizo opened this issue Nov 26, 2023 · 0 comments

Comments

@djturizo
Copy link

djturizo commented Nov 26, 2023

The function expint(nu,z) presents systematic large errors for nu != 1 (for nu == 1 the library calls an optimized routine that in my experiments has good precision). I computed the relative error of expint(nu,z) for $z \in [0.01, 60]$ using as benchmark numerical quadrature in quad precision. Code for nu == 2:

import Plots as plt
import QuadGK as GK
using SpecialFunctions

function compare_plot()
    setprecision(BigFloat, 128)
    int_tol = BigFloat(1e-24)
    nu = Float64(2)
    f0 = s -> GK.quadgk(u -> exp(-s*u) / u^nu, BigFloat(1), BigFloat(Inf);
        rtol=int_tol, order=15)[1]
    f = s -> expint(nu, Float64(s))
    srange = 0.01:0.02:60
    plt.gr(size=(160*3,120*3), legend=:none)
    p1 = plt.plot(srange, BigFloat.(f.(srange)) ./ f0.(BigFloat.(srange)) .- 1)
    plt.display(p1)
end

compare_plot();

The code outputs this plot:
E2_errors
Similar plots are obtained for other values of nu (except for 1, as mentioned before), and in general the errors have the same form, with peaks of the order of 1e-13 in magnitude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant