-
Notifications
You must be signed in to change notification settings - Fork 22
add logabstanh
#86
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
add logabstanh
#86
Changes from 2 commits
e8d075a
528545d
5cf0058
95639d1
3364d20
0b6d9f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -149,6 +149,31 @@ end | |||||
| """ | ||||||
| $(SIGNATURES) | ||||||
|
|
||||||
| Return `log(abs(tanh(x)))`, carefully evaluated without intermediate calculation of `tanh(x)`. | ||||||
|
|
||||||
| The implementation ensures `logabstanh(-x) = logabstanh(x)`. | ||||||
| """ | ||||||
| function logabstanh(x::Real) | ||||||
| return log1p(-2/((exp(2abs(x))+1))) | ||||||
|
||||||
| return log1p(-2/((exp(2abs(x))+1))) | |
| return log(abs(tanh(x))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the version I wrote stays more accurate overall but I'll do a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's possible to do such an analysis? You can't realistically test any subtype of Real.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for any AbstractFloat log(tanh(x)) will be inaccurate for large x since tanh(x) will be very close to 1.
Uh oh!
There was an error while loading. Please reload this page.