Average Error: 12.9 → 0.4
Time: 2.4s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -3.5092920853377696 \cdot 10^{-17}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 6.152532775435718 \cdot 10^{+84}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 5.489864442456623 \cdot 10^{+286}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{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} \leq -\infty:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -3.5092920853377696 \cdot 10^{-17}:\\
\;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 6.152532775435718 \cdot 10^{+84}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 5.489864442456623 \cdot 10^{+286}:\\
\;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (+ y z)) z) (- INFINITY))
   (/ x (/ z (+ y z)))
   (if (<= (/ (* x (+ y z)) z) -3.5092920853377696e-17)
     (* (* x (+ y z)) (/ 1.0 z))
     (if (<= (/ (* x (+ y z)) z) 6.152532775435718e+84)
       (/ x (/ z (+ y z)))
       (if (<= (/ (* x (+ y z)) z) 5.489864442456623e+286)
         (* (* x (+ y z)) (/ 1.0 z))
         (* x (/ (+ y z) z)))))))
double code(double x, double y, double z) {
	return (((double) (x * ((double) (y + z)))) / z);
}
double code(double x, double y, double z) {
	double tmp;
	if (((((double) (x * ((double) (y + z)))) / z) <= ((double) -(((double) INFINITY))))) {
		tmp = (x / (z / ((double) (y + z))));
	} else {
		double tmp_1;
		if (((((double) (x * ((double) (y + z)))) / z) <= -3.5092920853377696e-17)) {
			tmp_1 = ((double) (((double) (x * ((double) (y + z)))) * (1.0 / z)));
		} else {
			double tmp_2;
			if (((((double) (x * ((double) (y + z)))) / z) <= 6.152532775435718e+84)) {
				tmp_2 = (x / (z / ((double) (y + z))));
			} else {
				double tmp_3;
				if (((((double) (x * ((double) (y + z)))) / z) <= 5.489864442456623e+286)) {
					tmp_3 = ((double) (((double) (x * ((double) (y + z)))) * (1.0 / z)));
				} else {
					tmp_3 = ((double) (x * (((double) (y + z)) / z)));
				}
				tmp_2 = tmp_3;
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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.9
Target3.3
Herbie0.4
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or -3.5092920853377696e-17 < (/.f64 (*.f64 x (+.f64 y z)) z) < 6.1525327754357176e84

    1. Initial program 14.0

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

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

    if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -3.5092920853377696e-17 or 6.1525327754357176e84 < (/.f64 (*.f64 x (+.f64 y z)) z) < 5.4898644424566233e286

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}}\]

    if 5.4898644424566233e286 < (/.f64 (*.f64 x (+.f64 y z)) z)

    1. Initial program 57.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -3.5092920853377696 \cdot 10^{-17}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 6.152532775435718 \cdot 10^{+84}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 5.489864442456623 \cdot 10^{+286}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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