In floating point arithmetic, compute efficiently: $$\sinh x=\frac{e^x-e^{-x}}{2}=\sum_{n=0}^{+\infty}\frac{x^{2n+1}}{(2n+1)!}$$ for $x=15,~x=-15,~x=0.001$.
Attempt. For $x=15$ we compute $e^{15}$ as a finite sum $\displaystyle \sum_{n=0}^{k}\frac{15^n}{n!}$ for $k$ large enough and $e^{-15}=1/e^{15}.$
For $x=-15$, $\sinh(-15)=-\sinh (15)$ and for $x=0.001$ we evaluate $\sinh 0.001$ as a finite sum $\displaystyle \sum_{n=0}^{k}\frac{0.001^{2n+1}}{(2n+1)!}$ for $k$ large enough (depending on the given precision).
Am I on the right path?
Thanks a lot!
If you can manipulate the bits of a floating point number, you can use $e^x =2^{x/\ln 2} =2^{\lfloor x/\ln 2 \rfloor +\{x/\ln 2\}} =2^{\lfloor x/\ln 2 \rfloor} 2^{\{x/\ln 2\}} $ where $\{ z \}$ is the fractional part of $z$.
$2^{\lfloor x/\ln 2 \rfloor}$ can be gotten by creating the correct exponent bits in a floating point number (with fractional part representing $1$ or $\frac12$ depending on the format) and $2^{\{x/\ln 2\}} =e^{\ln 2\{x/\ln 2\}} $ can be computed by the power series for $e^z$ with a small argument $(0 \le\ln 2\{x/\ln 2\} < 1)$ which converges quickly.
This works for negative $x$ as well as positive.
For your case, I would compute $\sinh(x) =\dfrac{e^x-e^{-x}}{2} =\dfrac{e^x}{2}-\dfrac{e^{-x}}{2} =\dfrac{e^x}{2}-\dfrac{1}{2e^x} $.
Note that if $e^{2x} > 2^{m+1}$, where $m$ is the number of bits in the floating point fraction part, then only $e^x$ needs to be computed.
Also note that if $|x|$ is small, $e^x \approx 1+x+\frac{x^2}{2}+\frac{x^3}{6} $ so $\sinh(x) \approx x+\frac{x^3}{6} $. The values of $x$ for which this is useful depends on the accuracy needed.