-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
missing Complex expm1 and log1p #3141
Comments
Bump. The absence of these functions breaks complex step differentiation of code that uses these functions. |
Now that #6539 is merged (thanks to @simonbyrne), we only need a log1p(x) = 2*atanh(x/(x+2)) or (due to Kahan, apparently) function log1p(x)
u = 1+x
u == 1 ? x : log(u)*x/(u-1)
end though some care is required in the latter version to ensure type stability (e.g. for |
On my machine, the Some care is required with the branch cuts, in both versions, e.g. to have the right sign of zero along the negative real axis. |
Actually, both versions are inaccurate near |
The
expm1
andlog1p
functions are not yet implemented forComplex
types.In principle, I think these are straightforward: use a Taylor expansion for small arguments
z
(e.g. it is cheapest to check whether|real(z)|+|imag(z)|
is small), and explicit functionexp
/log
calls otherwise. The only annoyance is that you have to change the "small" cutoff and the order of the Taylor series depending upon the precision. ForFloat64
andFloat32
this is simple, but forBigFloat
matters are hairier.The text was updated successfully, but these errors were encountered: