Average Error: 58.1 → 0.0
Time: 13.8s
Precision: binary64
Cost: 128
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\tanh x\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\tanh x
(FPCore (x)
 :precision binary64
 (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (tanh x))
double code(double x) {
	return (exp(x) - exp(-x)) / (exp(x) + exp(-x));
}
double code(double x) {
	return tanh(x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs
Alternative 1
Accuracy56.8
Cost256
\[\log \left(e^{\tanh x}\right)\]
Alternative 2
Accuracy59.4
Cost1408
\[\frac{\sqrt{e^{x} - e^{-x}} \cdot \sqrt{e^{x} - e^{-x}}}{e^{x} + e^{-x}}\]

Derivation

  1. Initial program 58.1

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

    \[\leadsto \color{blue}{\tanh x}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity_binary64_4190.0

    \[\leadsto \color{blue}{1 \cdot \tanh x}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity_binary64_4190.0

    \[\leadsto 1 \cdot \color{blue}{\left(1 \cdot \tanh x\right)}\]
  8. Using strategy rm
  9. Applied pow1_binary64_4800.0

    \[\leadsto 1 \cdot \left(1 \cdot \color{blue}{{\tanh x}^{1}}\right)\]
  10. Final simplification0.0

    \[\leadsto \tanh x\]

Reproduce

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