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

Open
#453 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
julia
Domain
backend

Research direction

Start by running the Julia comparison code in the issue with SpecialFunctions and QuadGK, reproducing the relative-error plot for nu = 2 over z from 0.01 to 60. Then locate the expint(nu,z) implementation and compare its results with the quad-precision benchmark. Done means materially reducing the systematic precision errors for nu values other than 1 while preserving the existing nu == 1 behavior.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Julia
Stars
384
Forks
115
Avg merge
2d 9h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaMath/SpecialFunctions.jl

All issues in JuliaMath/SpecialFunctions.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.