rodluger / Limbdark.jl

Analytical transit light curves for limb darkened stars
MIT License
14 stars 4 forks source link

Figuring out maximum value of `J_{v_max}` series to compute #52

Closed ericagol closed 5 years ago

ericagol commented 5 years ago

For large values of v_{max}, and small values of k^2, the J_{v_max} series, and derivatives, can cause underflow so that the result is zero. Right now I loop over v_{max} until J_{v_max} is non-zero, but this is very inefficient and computationally expensive.

I could just estimate the first term in the series with Stirling's approximation, and see if underflow will be a problem. If so, then I can just iterate downwards until it no longer is a problem.

@rodluger I'd be interested to hear how you handle this.

ericagol commented 5 years ago

@rodluger The way I handle this is that if this situation is ever encountered, then I call Iv_series and Jv_series with the versions that don't use the pre-computed coefficients. This seems to work sufficiently well!