Average Error: 58.4 → 0.0
Time: 1.0m
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 r2257251 = x;
        double r2257252 = exp(r2257251);
        double r2257253 = -r2257251;
        double r2257254 = exp(r2257253);
        double r2257255 = r2257252 - r2257254;
        double r2257256 = r2257252 + r2257254;
        double r2257257 = r2257255 / r2257256;
        return r2257257;
}

double f(double x) {
        double r2257258 = x;
        double r2257259 = tanh(r2257258);
        return r2257259;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.4

    \[\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 2019171 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))