Average Error: 12.1 → 3.0
Time: 2.0s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.4377386799486208 \cdot 10^{-43} \lor \neg \left(z \le -1.7237487380979473 \cdot 10^{-180}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -3.4377386799486208 \cdot 10^{-43} \lor \neg \left(z \le -1.7237487380979473 \cdot 10^{-180}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y + z)))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if (((z <= -3.437738679948621e-43) || !(z <= -1.7237487380979473e-180))) {
		VAR = ((double) (x / ((double) (z / ((double) (y + z))))));
	} else {
		VAR = ((double) (((double) (x / z)) * ((double) (y + z))));
	}
	return VAR;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -3.4377386799486208e-43 or -1.7237487380979473e-180 < z

    1. Initial program 12.9

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

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

    if -3.4377386799486208e-43 < z < -1.7237487380979473e-180

    1. Initial program 5.7

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/5.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.4377386799486208 \cdot 10^{-43} \lor \neg \left(z \le -1.7237487380979473 \cdot 10^{-180}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \end{array}\]

Reproduce

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