FastGaussQuadrature.jl icon indicating copy to clipboard operation
FastGaussQuadrature.jl copied to clipboard

Loosen limit n ≤ 4000 in gaussjacobi

Open dlfivefifty opened this issue 8 years ago • 3 comments

This seems to be a hold over from MATLAB since

julia> n=5000;a=rand(n);b=rand(n-1);@time eig(SymTridiagonal(a,b));
  4.166163 seconds (276.39 k allocations: 203.424 MB, 1.36% gc time)

dlfivefifty avatar May 01 '17 23:05 dlfivefifty

Is there any technical problem for this limitations?

Is it okay to replace

    elseif n <= 4000 && max(a,b)>=5.
        jacobi_gw(n, a, b)
    else
        error("gaussjacobi($n,$a,$b) is not implemented: n must be ≤ 4000 for max(a,b)≥5.")
    end

with

    else
        jacobi_gw(n, a, b)
    end

?

https://github.com/JuliaApproximation/FastGaussQuadrature.jl/blob/master/src/gaussjacobi.jl#L25

If there's a problem, I guess the convergence of Newton's method is suspicious. Because the Newton iteration algorithm has hard-coded loop limitation. https://github.com/JuliaApproximation/FastGaussQuadrature.jl/blob/master/src/gaussjacobi.jl#L88

hyrodium avatar Jan 08 '21 08:01 hyrodium

Go for it! I think the limitation on n ≤ 4000 was just because Matlab was not using SymTridiagonal.

If there's a problem, I guess the convergence of Newton's method is suspicious

True, this could effect the large a and b case. Even worse, the initial guesses might not be sufficiently accurate to converge. @ajt60gaibb any thoughts?

dlfivefifty avatar Jan 08 '21 09:01 dlfivefifty

If we add GenericLinearAlgebra.jl as a dependency we could just use Golub-Welsch with BigFloat for large a and b and then cast to Float64.

dlfivefifty avatar Jan 09 '21 14:01 dlfivefifty