Average Error: 12.4 → 1.9
Time: 3.2s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -inf.0 \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -6.61839896682325078 \cdot 10^{-230}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -inf.0 \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -6.61839896682325078 \cdot 10^{-230}\right):\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

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

\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 (((((double) (((double) (x * ((double) (y + z)))) / z)) <= -inf.0) || !(((double) (((double) (x * ((double) (y + z)))) / z)) <= -6.618398966823251e-230))) {
		VAR = ((double) (x + ((double) (x * ((double) (y / z))))));
	} else {
		VAR = ((double) (x + ((double) (((double) (x * y)) * ((double) (1.0 / 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.4
Target3.1
Herbie1.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0 or -6.61839896682325078e-230 < (/ (* x (+ y z)) z)

    1. Initial program 19.1

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified2.8

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

    if -inf.0 < (/ (* x (+ y z)) z) < -6.61839896682325078e-230

    1. Initial program 0.4

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified4.3

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied div-inv4.3

      \[\leadsto x + x \cdot \color{blue}{\left(y \cdot \frac{1}{z}\right)}\]
    5. Applied associate-*r*0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -inf.0 \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -6.61839896682325078 \cdot 10^{-230}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

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