Average Error: 12.7 → 2.3
Time: 1.6s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \le -6.81645975360239147 \cdot 10^{22}:\\ \;\;\;\;\frac{y + z}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 9.4379571976082544 \cdot 10^{24}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 5.1520249441474563 \cdot 10^{216}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \le -6.81645975360239147 \cdot 10^{22}:\\
\;\;\;\;\frac{y + z}{\frac{z}{x}}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 9.4379571976082544 \cdot 10^{24}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 5.1520249441474563 \cdot 10^{216}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\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 ((((double) (((double) (x * ((double) (y + z)))) / z)) <= -6.8164597536023915e+22)) {
		VAR = ((double) (((double) (y + z)) / ((double) (z / x))));
	} else {
		double VAR_1;
		if ((((double) (((double) (x * ((double) (y + z)))) / z)) <= 9.437957197608254e+24)) {
			VAR_1 = ((double) fma(((double) (y / z)), x, x));
		} else {
			double VAR_2;
			if ((((double) (((double) (x * ((double) (y + z)))) / z)) <= 5.1520249441474563e+216)) {
				VAR_2 = ((double) (((double) (x * ((double) (y + z)))) / z));
			} else {
				VAR_2 = ((double) fma(((double) (y / z)), x, x));
			}
			VAR_1 = VAR_2;
		}
		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.7
Target2.8
Herbie2.3
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

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

    1. Initial program 18.6

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

      \[\leadsto \frac{\color{blue}{\left(y + z\right) \cdot x}}{z}\]
    4. Applied associate-/l*5.6

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

    if -6.8164597536023915e+22 < (/ (* x (+ y z)) z) < 9.437957197608254e+24 or 5.1520249441474563e+216 < (/ (* x (+ y z)) z)

    1. Initial program 13.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]

    if 9.437957197608254e+24 < (/ (* x (+ y z)) z) < 5.1520249441474563e+216

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \le -6.81645975360239147 \cdot 10^{22}:\\ \;\;\;\;\frac{y + z}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 9.4379571976082544 \cdot 10^{24}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 5.1520249441474563 \cdot 10^{216}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +o rules:numerics
(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))