Average Error: 58.2 → 0.6
Time: 5.3s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{{\left(e^{2 \cdot x} + 1\right)}^{3}}}\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{{\left(e^{2 \cdot x} + 1\right)}^{3}}}
double f(double x) {
        double r34848 = x;
        double r34849 = exp(r34848);
        double r34850 = -r34848;
        double r34851 = exp(r34850);
        double r34852 = r34849 - r34851;
        double r34853 = r34849 + r34851;
        double r34854 = r34852 / r34853;
        return r34854;
}

double f(double x) {
        double r34855 = x;
        double r34856 = r34855 + r34855;
        double r34857 = expm1(r34856);
        double r34858 = 2.0;
        double r34859 = r34858 * r34855;
        double r34860 = exp(r34859);
        double r34861 = 1.0;
        double r34862 = r34860 + r34861;
        double r34863 = 3.0;
        double r34864 = pow(r34862, r34863);
        double r34865 = cbrt(r34864);
        double r34866 = r34857 / r34865;
        return r34866;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.2

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
  2. Simplified0.6

    \[\leadsto \color{blue}{1 \cdot \frac{\mathsf{expm1}\left(x + x\right)}{\mathsf{fma}\left(1, 1, e^{x + x}\right)}}\]
  3. Using strategy rm
  4. Applied add-cbrt-cube0.6

    \[\leadsto 1 \cdot \frac{\mathsf{expm1}\left(x + x\right)}{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(1, 1, e^{x + x}\right) \cdot \mathsf{fma}\left(1, 1, e^{x + x}\right)\right) \cdot \mathsf{fma}\left(1, 1, e^{x + x}\right)}}}\]
  5. Simplified0.6

    \[\leadsto 1 \cdot \frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{\color{blue}{{\left(e^{2 \cdot x} + 1\right)}^{3}}}}\]
  6. Final simplification0.6

    \[\leadsto \frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{{\left(e^{2 \cdot x} + 1\right)}^{3}}}\]

Reproduce

herbie shell --seed 2020039 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))