Average Error: 12.6 → 2.4
Time: 4.4s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -5.140138329347149 \cdot 10^{+39}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{elif}\;z \leq -2.590230819832462 \cdot 10^{-190}:\\ \;\;\;\;\frac{x \cdot \left(z + y\right)}{z}\\ \mathbf{elif}\;z \leq 5.046753511079363 \cdot 10^{-233}:\\ \;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{z + y}{\sqrt[3]{z}}\\ \mathbf{elif}\;z \leq 3.2609574170760183 \cdot 10^{-99}:\\ \;\;\;\;\frac{x \cdot \left(z + y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -5.140138329347149 \cdot 10^{+39}:\\
\;\;\;\;x \cdot \frac{z + y}{z}\\

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

\mathbf{elif}\;z \leq 5.046753511079363 \cdot 10^{-233}:\\
\;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{z + y}{\sqrt[3]{z}}\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.140138329347149e+39)
   (* x (/ (+ z y) z))
   (if (<= z -2.590230819832462e-190)
     (/ (* x (+ z y)) z)
     (if (<= z 5.046753511079363e-233)
       (* (/ x (* (cbrt z) (cbrt z))) (/ (+ z y) (cbrt z)))
       (if (<= z 3.2609574170760183e-99)
         (/ (* x (+ z y)) z)
         (/ x (/ z (+ z y))))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.140138329347149e+39) {
		tmp = x * ((z + y) / z);
	} else if (z <= -2.590230819832462e-190) {
		tmp = (x * (z + y)) / z;
	} else if (z <= 5.046753511079363e-233) {
		tmp = (x / (cbrt(z) * cbrt(z))) * ((z + y) / cbrt(z));
	} else if (z <= 3.2609574170760183e-99) {
		tmp = (x * (z + y)) / z;
	} else {
		tmp = x / (z / (z + y));
	}
	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.6
Target2.9
Herbie2.4
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 4 regimes
  2. if z < -5.140138329347149e39

    1. Initial program 19.0

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

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

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

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

    if -5.140138329347149e39 < z < -2.5902308198324621e-190 or 5.04675351107936281e-233 < z < 3.2609574170760183e-99

    1. Initial program 4.7

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

    if -2.5902308198324621e-190 < z < 5.04675351107936281e-233

    1. Initial program 14.6

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary64_1136615.5

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}\]
    4. Applied times-frac_binary64_113378.3

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

    if 3.2609574170760183e-99 < z

    1. Initial program 13.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.140138329347149 \cdot 10^{+39}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{elif}\;z \leq -2.590230819832462 \cdot 10^{-190}:\\ \;\;\;\;\frac{x \cdot \left(z + y\right)}{z}\\ \mathbf{elif}\;z \leq 5.046753511079363 \cdot 10^{-233}:\\ \;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{z + y}{\sqrt[3]{z}}\\ \mathbf{elif}\;z \leq 3.2609574170760183 \cdot 10^{-99}:\\ \;\;\;\;\frac{x \cdot \left(z + y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \end{array}\]

Reproduce

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