Average Error: 58.2 → 0.0
Time: 5.0s
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 r32967 = x;
        double r32968 = exp(r32967);
        double r32969 = -r32967;
        double r32970 = exp(r32969);
        double r32971 = r32968 - r32970;
        double r32972 = r32968 + r32970;
        double r32973 = r32971 / r32972;
        return r32973;
}

double f(double x) {
        double r32974 = x;
        double r32975 = tanh(r32974);
        return r32975;
}

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. Using strategy rm
  3. Applied tanh-undef0.0

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

    \[\leadsto \tanh x\]

Reproduce

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