Average Error: 12.1 → 2.7
Time: 2.0s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.7672276150092905 \cdot 10^{236}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{elif}\;y \le 9.8124351507309985 \cdot 10^{-21}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;y \le 1.95805875046091314 \cdot 10^{211}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \le -1.7672276150092905 \cdot 10^{236}:\\
\;\;\;\;\frac{x \cdot y}{z} + x\\

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

\mathbf{elif}\;y \le 1.95805875046091314 \cdot 10^{211}:\\
\;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}} + x\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z} + x\\

\end{array}
double code(double x, double y, double z) {
	return ((x * (y + z)) / z);
}
double code(double x, double y, double z) {
	double temp;
	if ((y <= -1.7672276150092905e+236)) {
		temp = (((x * y) / z) + x);
	} else {
		double temp_1;
		if ((y <= 9.812435150730998e-21)) {
			temp_1 = (x / (z / (y + z)));
		} else {
			double temp_2;
			if ((y <= 1.9580587504609131e+211)) {
				temp_2 = ((1.0 / ((z / x) / y)) + x);
			} else {
				temp_2 = (((x * y) / z) + x);
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	return temp;
}

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

Derivation

  1. Split input into 3 regimes
  2. if y < -1.7672276150092905e+236 or 1.9580587504609131e+211 < y

    1. Initial program 13.4

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

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

    if -1.7672276150092905e+236 < y < 9.812435150730998e-21

    1. Initial program 12.4

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

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

    if 9.812435150730998e-21 < y < 1.9580587504609131e+211

    1. Initial program 9.9

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot y}}} + x\]
    5. Using strategy rm
    6. Applied associate-/r*2.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.7672276150092905 \cdot 10^{236}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{elif}\;y \le 9.8124351507309985 \cdot 10^{-21}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;y \le 1.95805875046091314 \cdot 10^{211}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]

Reproduce

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