Average Error: 1.7 → 1.7
Time: 2.8s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z) :precision binary64 (fabs (+ (/ 4.0 y) (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	return ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) ((x / y) * z))))));
}
double code(double x, double y, double z) {
	return ((double) fabs(((double) ((4.0 / y) + ((double) ((x / y) * ((double) (1.0 - z))))))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program Error: 1.7 bits

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
  2. Taylor expanded around 0 Error: 3.3 bits

    \[\leadsto \left|\color{blue}{\left(4 \cdot \frac{1}{y} + \frac{x}{y}\right) - \frac{x \cdot z}{y}}\right|\]
  3. SimplifiedError: 1.7 bits

    \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)}\right|\]
  4. Final simplificationError: 1.7 bits

    \[\leadsto \left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|\]

Reproduce

herbie shell --seed 2020203 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))