Average Error: 58.2 → 0.8
Time: 4.8s
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 r34982 = x;
        double r34983 = exp(r34982);
        double r34984 = -r34982;
        double r34985 = exp(r34984);
        double r34986 = r34983 - r34985;
        double r34987 = r34983 + r34985;
        double r34988 = r34986 / r34987;
        return r34988;
}

double f(double x) {
        double r34989 = x;
        double r34990 = r34989 + r34989;
        double r34991 = expm1(r34990);
        double r34992 = 2.0;
        double r34993 = r34992 * r34989;
        double r34994 = exp(r34993);
        double r34995 = 1.0;
        double r34996 = r34994 + r34995;
        double r34997 = 3.0;
        double r34998 = pow(r34996, r34997);
        double r34999 = cbrt(r34998);
        double r35000 = r34991 / r34999;
        return r35000;
}

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.7

    \[\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.8

    \[\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.8

    \[\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.8

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

Reproduce

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