rodluger / Limbdark.jl

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

Gradient errors large near `r=1`, `b~0` #18

Closed ericagol closed 6 years ago

ericagol commented 6 years ago

Right now the the test test_transit_poly_gradient.jl is failing for r=1.0 and b ~ 0.

ericagol commented 6 years ago

The errors also occur for r=1.01 and b~0, as well as r=2.0 and b~0, so I think this is a more generic problem that occurs near b~0 for r>1.

ericagol commented 6 years ago

I found a fix: I compute b*sin(\lambda) and b*cos(\lambda), from which I get \lambda = atan2(b*sin(\lambda),b*cos(\lambda)), and then I divide both expressions by b. This gives a more accurate value for \lambda near b=0.

ericagol commented 6 years ago

Tests are passing for an absolute threshold of 10^{-8}.

rodluger commented 6 years ago

@ericagol How exactly are you computing b sin lambda and b cos lambda?

ericagol commented 6 years ago

@rodluger Have a look here:

https://github.com/rodluger/limbdark/blob/f87fd16c37990bc2aa30cca50053caf3747d9ee7/src/sn.jl#L379

I think the new approach I'm taking to the uniform case could work for H_uv as well.