Average Error: 58.1 → 0.7
Time: 5.8s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\frac{\mathsf{expm1}\left(x + x\right)}{{\left(e^{2 \cdot x}\right)}^{3} + 1} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 - e^{2 \cdot x} \cdot 1\right)\right)\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\frac{\mathsf{expm1}\left(x + x\right)}{{\left(e^{2 \cdot x}\right)}^{3} + 1} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 - e^{2 \cdot x} \cdot 1\right)\right)
double f(double x) {
        double r39052 = x;
        double r39053 = exp(r39052);
        double r39054 = -r39052;
        double r39055 = exp(r39054);
        double r39056 = r39053 - r39055;
        double r39057 = r39053 + r39055;
        double r39058 = r39056 / r39057;
        return r39058;
}

double f(double x) {
        double r39059 = x;
        double r39060 = r39059 + r39059;
        double r39061 = expm1(r39060);
        double r39062 = 2.0;
        double r39063 = r39062 * r39059;
        double r39064 = exp(r39063);
        double r39065 = 3.0;
        double r39066 = pow(r39064, r39065);
        double r39067 = 1.0;
        double r39068 = r39066 + r39067;
        double r39069 = r39061 / r39068;
        double r39070 = r39064 * r39064;
        double r39071 = r39064 * r39067;
        double r39072 = r39067 - r39071;
        double r39073 = r39070 + r39072;
        double r39074 = r39069 * r39073;
        return r39074;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.1

    \[\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 div-inv0.7

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

    \[\leadsto 1 \cdot \left(\mathsf{expm1}\left(x + x\right) \cdot \color{blue}{\frac{1}{e^{2 \cdot x} + 1}}\right)\]
  6. Using strategy rm
  7. Applied flip3-+0.7

    \[\leadsto 1 \cdot \left(\mathsf{expm1}\left(x + x\right) \cdot \frac{1}{\color{blue}{\frac{{\left(e^{2 \cdot x}\right)}^{3} + {1}^{3}}{e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 \cdot 1 - e^{2 \cdot x} \cdot 1\right)}}}\right)\]
  8. Applied associate-/r/0.7

    \[\leadsto 1 \cdot \left(\mathsf{expm1}\left(x + x\right) \cdot \color{blue}{\left(\frac{1}{{\left(e^{2 \cdot x}\right)}^{3} + {1}^{3}} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 \cdot 1 - e^{2 \cdot x} \cdot 1\right)\right)\right)}\right)\]
  9. Applied associate-*r*0.7

    \[\leadsto 1 \cdot \color{blue}{\left(\left(\mathsf{expm1}\left(x + x\right) \cdot \frac{1}{{\left(e^{2 \cdot x}\right)}^{3} + {1}^{3}}\right) \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 \cdot 1 - e^{2 \cdot x} \cdot 1\right)\right)\right)}\]
  10. Simplified0.7

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

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

Reproduce

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