Average Error: 58.0 → 0.5
Time: 3.8s
Precision: binary64
\[\frac{e^{x} - e^{-x}}{2} \]
\[\frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)\right)\right)}{2} \]
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x)
 :precision binary64
 (/
  (fma
   0.016666666666666666
   (pow x 5.0)
   (fma
    0.0003968253968253968
    (pow x 7.0)
    (fma 2.0 x (* 0.3333333333333333 (pow x 3.0)))))
  2.0))
double code(double x) {
	return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
	return fma(0.016666666666666666, pow(x, 5.0), fma(0.0003968253968253968, pow(x, 7.0), fma(2.0, x, (0.3333333333333333 * pow(x, 3.0))))) / 2.0;
}
function code(x)
	return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0)
end
function code(x)
	return Float64(fma(0.016666666666666666, (x ^ 5.0), fma(0.0003968253968253968, (x ^ 7.0), fma(2.0, x, Float64(0.3333333333333333 * (x ^ 3.0))))) / 2.0)
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
code[x_] := N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision] + N[(0.0003968253968253968 * N[Power[x, 7.0], $MachinePrecision] + N[(2.0 * x + N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\frac{e^{x} - e^{-x}}{2}
\frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)\right)\right)}{2}

Error

Bits error versus x

Derivation

  1. Initial program 58.0

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Taylor expanded in x around 0 0.5

    \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.0003968253968253968 \cdot {x}^{7} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)\right)}}{2} \]
  3. Simplified0.5

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)\right)\right)}}{2} \]
  4. Final simplification0.5

    \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)\right)\right)}{2} \]

Reproduce

herbie shell --seed 2022133 
(FPCore (x)
  :name "Hyperbolic sine"
  :precision binary64
  (/ (- (exp x) (exp (- x))) 2.0))