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

sinh not too accurate for numbers approaching -1 or 1 #484

Closed
jrus opened this Issue Oct 19, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@jrus

jrus commented Oct 19, 2015

I left a comment on the relevant pull request, but I figured I should make a separate issue, in case nobody sees that one. Ping @pavpanchekha.

A 5th degree Taylor expansion for sinh, as currently used by mathjs, isn’t very accurate when you get away from zero. For instance, with x = 0.99, it has an error of ~1.87e-4 (according to Wolfram Alpha).

As an alternative, you could use the degree 17 Taylor expansion the way the GNU Scientific Library does for the range [-1, 1], or you could e.g. use a Chebyshev series expansion.

Also, it probably makes sense to defer to the native Math.sinh function if it is defined. (Part of ECMAScript 6.)

@josdejong josdejong added the bug label Oct 24, 2015

@josdejong

This comment has been minimized.

Owner

josdejong commented Oct 24, 2015

Thanks for bringing this up! Would you be interested in improving the current implementation?

@pavpanchekha

This comment has been minimized.

Contributor

pavpanchekha commented Oct 27, 2015

Hi @jrus, and thanks for bringing up this problem. I'll look into using Chebyshev series, and try to figure out how to avoid the problem in the future.

@josdejong

This comment has been minimized.

Owner

josdejong commented Oct 27, 2015

Thanks @pavpanchekha

@cukejianya

This comment has been minimized.

cukejianya commented Jan 22, 2016

See if #555 solves this problem. @josdejong @jrus

@josdejong josdejong referenced this issue Jan 25, 2016

Closed

Sinh Accuracy #555

@josdejong

This comment has been minimized.

Owner

josdejong commented Apr 3, 2016

I've fixed this in the develop branch by using ES6 Math functions when available, and if not, falling back on a simple implementation using exp (nothing fancy). This means that in practice you may see some inaccuracy issues on old versions of node (v0.10, v0.12).

@josdejong josdejong closed this in bbfa7d5 Apr 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment