Average Error: 34.7 → 34.7
Time: 4.5s
Precision: binary64
\[\frac{\left(\left(e^{x - 2 \cdot h} - e^{x + 2 \cdot h}\right) + 8 \cdot e^{x + h}\right) - 8 \cdot e^{x - h}}{12 \cdot h}\]
\[\frac{\frac{e^{x - 2 \cdot h} - \left(e^{x + 2 \cdot h} - 8 \cdot \left(e^{x + h} - e^{x - h}\right)\right)}{h}}{12}\]
\frac{\left(\left(e^{x - 2 \cdot h} - e^{x + 2 \cdot h}\right) + 8 \cdot e^{x + h}\right) - 8 \cdot e^{x - h}}{12 \cdot h}
\frac{\frac{e^{x - 2 \cdot h} - \left(e^{x + 2 \cdot h} - 8 \cdot \left(e^{x + h} - e^{x - h}\right)\right)}{h}}{12}
double code(double x, double h) {
	return ((double) (((double) (((double) (((double) (((double) exp(((double) (x - ((double) (2.0 * h)))))) - ((double) exp(((double) (x + ((double) (2.0 * h)))))))) + ((double) (8.0 * ((double) exp(((double) (x + h)))))))) - ((double) (8.0 * ((double) exp(((double) (x - h)))))))) / ((double) (12.0 * h))));
}
double code(double x, double h) {
	return ((double) (((double) (((double) (((double) exp(((double) (x - ((double) (2.0 * h)))))) - ((double) (((double) exp(((double) (x + ((double) (2.0 * h)))))) - ((double) (8.0 * ((double) (((double) exp(((double) (x + h)))) - ((double) exp(((double) (x - h)))))))))))) / h)) / 12.0));
}

Error

Bits error versus x

Bits error versus h

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 34.7

    \[\frac{\left(\left(e^{x - 2 \cdot h} - e^{x + 2 \cdot h}\right) + 8 \cdot e^{x + h}\right) - 8 \cdot e^{x - h}}{12 \cdot h}\]
  2. Simplified34.7

    \[\leadsto \color{blue}{\frac{\frac{e^{x - 2 \cdot h} - \left(e^{x + 2 \cdot h} - 8 \cdot \left(e^{x + h} - e^{x - h}\right)\right)}{h}}{12}}\]
  3. Final simplification34.7

    \[\leadsto \frac{\frac{e^{x - 2 \cdot h} - \left(e^{x + 2 \cdot h} - 8 \cdot \left(e^{x + h} - e^{x - h}\right)\right)}{h}}{12}\]

Reproduce

herbie shell --seed 2020152 
(FPCore (x h)
  :name "(/ (- (+ (- (exp (- x (* 2 h))) (exp (+ x (* 2 h)))) (* 8 (exp (+ x h)))) (* 8 (exp (- x h)))) (* 12 h))"
  :precision binary64
  (/ (- (+ (- (exp (- x (* 2.0 h))) (exp (+ x (* 2.0 h)))) (* 8.0 (exp (+ x h)))) (* 8.0 (exp (- x h)))) (* 12.0 h)))