Average Error: 12.3 → 2.8
Time: 3.1s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.6527240866960095 \cdot 10^{-216}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;z \le 5.4237474431758266 \cdot 10^{-57}:\\ \;\;\;\;\frac{x \cdot y + x \cdot z}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -3.6527240866960095 \cdot 10^{-216}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;z \le 5.4237474431758266 \cdot 10^{-57}:\\
\;\;\;\;\frac{x \cdot y + x \cdot z}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y + z}{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 ((z <= -3.6527240866960095e-216)) {
		VAR = ((double) (x / ((double) (z / ((double) (y + z))))));
	} else {
		double VAR_1;
		if ((z <= 5.423747443175827e-57)) {
			VAR_1 = ((double) (((double) (((double) (x * y)) + ((double) (x * z)))) / z));
		} else {
			VAR_1 = ((double) (x * ((double) (((double) (y + z)) / z))));
		}
		VAR = VAR_1;
	}
	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.3
Target3.1
Herbie2.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -3.6527240866960095e-216

    1. Initial program 12.4

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

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

    if -3.6527240866960095e-216 < z < 5.4237474431758266e-57

    1. Initial program 8.7

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied distribute-lft-in8.7

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

    if 5.4237474431758266e-57 < z

    1. Initial program 14.4

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity14.4

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac0.3

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y + z}{z}}\]
    5. Simplified0.3

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.6527240866960095 \cdot 10^{-216}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;z \le 5.4237474431758266 \cdot 10^{-57}:\\ \;\;\;\;\frac{x \cdot y + x \cdot z}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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