Average Error: 57.9 → 0.0
Time: 3.6s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\tanh x\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\tanh x
double f(double x) {
        double r69334 = x;
        double r69335 = exp(r69334);
        double r69336 = -r69334;
        double r69337 = exp(r69336);
        double r69338 = r69335 - r69337;
        double r69339 = r69335 + r69337;
        double r69340 = r69338 / r69339;
        return r69340;
}

double f(double x) {
        double r69341 = x;
        double r69342 = tanh(r69341);
        return r69342;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 57.9

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
  2. Using strategy rm
  3. Applied tanh-undef0.0

    \[\leadsto \color{blue}{\tanh x}\]
  4. Final simplification0.0

    \[\leadsto \tanh x\]

Reproduce

herbie shell --seed 2020027 
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))