Average Error: 12.3 → 1.8
Time: 2.4s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \le 8.3622904561588457 \cdot 10^{-120}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{y + z}}{x}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 2.34303628432969222 \cdot 10^{290}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \le 8.3622904561588457 \cdot 10^{-120}:\\
\;\;\;\;\frac{1}{\frac{\frac{z}{y + z}}{x}}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 2.34303628432969222 \cdot 10^{290}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{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 ((((double) (((double) (x * ((double) (y + z)))) / z)) <= 8.362290456158846e-120)) {
		VAR = ((double) (1.0 / ((double) (((double) (z / ((double) (y + z)))) / x))));
	} else {
		double VAR_1;
		if ((((double) (((double) (x * ((double) (y + z)))) / z)) <= 2.3430362843296922e+290)) {
			VAR_1 = ((double) (((double) (x * ((double) (y + 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
Target2.9
Herbie1.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* x (+ y z)) z) < 8.362290456158846e-120

    1. Initial program 11.5

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

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

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

    if 8.362290456158846e-120 < (/ (* x (+ y z)) z) < 2.3430362843296922e+290

    1. Initial program 0.3

      \[\frac{x \cdot \left(y + z\right)}{z}\]

    if 2.3430362843296922e+290 < (/ (* x (+ y z)) z)

    1. Initial program 57.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \le 8.3622904561588457 \cdot 10^{-120}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{y + z}}{x}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 2.34303628432969222 \cdot 10^{290}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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