0

If I do sinh(1000) I get Inf, which it seems is expected, but I am curious to know if there are any ways to overcome this?

I tried: format(round(sinh(1000), 2), nsmall = 2) believing it is a decimal issue, but maybe my issue is more conceptual, than technical?

I just found it strange that sinh(700) works well but fails on numbers near enough above this

student
  • 1,001
  • 2
  • 12
  • 24
lapgoch
  • 35
  • 7

1 Answers1

0

See this answer. numeric objects in R can only get so big. The inverse sinh is approximately log(x) + log(2) for large x:

> .Machine$double.xmax
[1] 1.797693e+308
> sinh(log(.Machine$double.xmax) + log(2))
[1] 1.797693e+308
> sinh(log(.Machine$double.xmax) + log(2) + 1e-10)
[1] Inf

A common approach is to work in log-space. log(sinh(x)) for large x is approximately x - log(2):

> log(sinh(700))
[1] 699.3069
> 700 - log(2)
[1] 699.3069
> log(sinh(700)) - 700 + log(2)
[1] 5.495604e-14

If you clarify what you are trying to do with numbers larger than sinh(700), someone may have additional ideas to work around your problem.

jblood94
  • 10,340
  • 1
  • 10
  • 15