Average Error: 12.7 → 2.9
Time: 3.1s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\frac{x}{\frac{z}{z + y}}\]
\frac{x \cdot \left(y + z\right)}{z}
\frac{x}{\frac{z}{z + y}}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z) :precision binary64 (/ x (/ z (+ z y))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	return x / (z / (z + y));
}

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

Target

Original12.7
Target2.9
Herbie2.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Initial program 12.7

    \[\frac{x \cdot \left(y + z\right)}{z}\]
  2. Using strategy rm
  3. Applied associate-/l*_binary642.9

    \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
  4. Simplified2.9

    \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
  5. Final simplification2.9

    \[\leadsto \frac{x}{\frac{z}{z + y}}\]

Alternatives

Reproduce

herbie shell --seed 2021118 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))