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

OutOfMemoryError() when approximating a 3D function #938

Open
weymouth opened this issue Apr 1, 2024 · 0 comments
Open

OutOfMemoryError() when approximating a 3D function #938

weymouth opened this issue Apr 1, 2024 · 0 comments

Comments

@weymouth
Copy link

weymouth commented Apr 1, 2024

I'm trying to recreate a 3D Chebyshev surrogate model from an old paper Newman 1987.

using SpecialFunctions,QuadGK
using Base.MathConstants: γ
function bruteN(x,y,z;withS=true)
    ζ(t) = (z*sqrt(1-t^2)+y*t+im*abs(x))*sqrt(1-t^2)
    Ni(t) = imag(expintx(ζ(t))+log(ζ(t))+γ)
    2/π*quadgk(Ni,-1,0,1,atol=eps())[1]+ifelse(withS,S(x,y,z),0)
end
S(x,y,z) = -2*(1-z/(hypot(x,y,z)+abs(x)))
function bruteNsphere(R,θ,α)
	x,ρ = R*sin(θ),R*cos(θ)
	y,z = ρ*sin(α),-ρ*cos(α)
	bruteN(x,y,z,withS=false)
end

using ApproxFun
R,θ,α = Fun(0..2),Fun(CosSpace()),Fun(0..π/2)
f = bruteNsphere(R,θ,α)

As you can see, its an integral over the special function expintx which makes it very expensive to evaluate, but the integral itself is a smooth function of x,y,z or R,θ,α. (Note that I've subtracted off the log singularity at R=0, which is also done in the paper.)

Newman uses a triple Chebyshev product to estimate this function in 1987 (though he said it took him 150 hours to compute the coefficients). However, when I try to run the code above I get an OutOfMemoryError(). Certainly, I've got more memory in 2024 than Newman had in 1987 😀.

I see there is limited support for 3D functions. Is there any work around I can use here?

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