Average Error: 12.2 → 2.9
Time: 2.5s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq 2.503793877446147 \cdot 10^{-301} \lor \neg \left(z \leq 2.1382498498323363 \cdot 10^{-143}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \left(z + y\right)}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq 2.503793877446147 \cdot 10^{-301} \lor \neg \left(z \leq 2.1382498498323363 \cdot 10^{-143}\right):\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{x \cdot \left(z + y\right)}}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= z 2.503793877446147e-301) (not (<= z 2.1382498498323363e-143)))
   (/ x (/ z (+ z y)))
   (/ 1.0 (/ z (* x (+ z y))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if ((z <= 2.503793877446147e-301) || !(z <= 2.1382498498323363e-143)) {
		tmp = x / (z / (z + y));
	} else {
		tmp = 1.0 / (z / (x * (z + y)));
	}
	return tmp;
}

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.2
Target3.1
Herbie2.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < 2.5037938774461471e-301 or 2.1382498498323363e-143 < z

    1. Initial program 12.4

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

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

    if 2.5037938774461471e-301 < z < 2.1382498498323363e-143

    1. Initial program 10.1

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied clear-num_binary64_1418210.2

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot \left(y + z\right)}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.503793877446147 \cdot 10^{-301} \lor \neg \left(z \leq 2.1382498498323363 \cdot 10^{-143}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \left(z + y\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020277 
(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))