Average Error: 12.6 → 2.4
Time: 2.3s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.25214836899743172 \cdot 10^{-266}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;z \le 1.2662689376772197 \cdot 10^{-111}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} + 1\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.25214836899743172 \cdot 10^{-266}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} + 1\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 <= -1.2521483689974317e-266)) {
		VAR = ((double) (x / ((double) (z / ((double) (y + z))))));
	} else {
		double VAR_1;
		if ((z <= 1.2662689376772197e-111)) {
			VAR_1 = ((double) (((double) (((double) (x * y)) / z)) + x));
		} else {
			VAR_1 = ((double) (x * ((double) (((double) (y / z)) + 1.0))));
		}
		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.6
Target3.1
Herbie2.4
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -1.25214836899743172e-266

    1. Initial program 13.1

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

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

    if -1.25214836899743172e-266 < z < 1.2662689376772197e-111

    1. Initial program 9.5

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 6.3

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

    if 1.2662689376772197e-111 < z

    1. Initial program 13.1

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
    6. Taylor expanded around 0 0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.25214836899743172 \cdot 10^{-266}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;z \le 1.2662689376772197 \cdot 10^{-111}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} + 1\right)\\ \end{array}\]

Reproduce

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