Average Error: 12.9 → 0.5
Time: 11.2s
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:\\ \;\;\;\;x + \frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -4.106270057463767 \cdot 10^{+124}:\\ \;\;\;\;x + \frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 1.6771279090950563 \cdot 10^{-155}:\\ \;\;\;\;x + \frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 7.536776844305155 \cdot 10^{+301}:\\ \;\;\;\;x + \frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \frac{y}{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:\\
\;\;\;\;x + \frac{x}{\frac{z}{y}}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;x + x \cdot \frac{y}{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 (/ x (/ z y)))
   (if (<= (/ (* x (+ y z)) z) -4.106270057463767e+124)
     (+ x (* (/ 1.0 z) (* x y)))
     (if (<= (/ (* x (+ y z)) z) 1.6771279090950563e-155)
       (+ x (/ x (/ z y)))
       (if (<= (/ (* x (+ y z)) z) 7.536776844305155e+301)
         (+ x (* (/ 1.0 z) (* x y)))
         (+ x (* x (/ y z))))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if (((x * (y + z)) / z) <= -((double) INFINITY)) {
		tmp = x + (x / (z / y));
	} else if (((x * (y + z)) / z) <= -4.106270057463767e+124) {
		tmp = x + ((1.0 / z) * (x * y));
	} else if (((x * (y + z)) / z) <= 1.6771279090950563e-155) {
		tmp = x + (x / (z / y));
	} else if (((x * (y + z)) / z) <= 7.536776844305155e+301) {
		tmp = x + ((1.0 / z) * (x * y));
	} else {
		tmp = x + (x * (y / z));
	}
	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.0
Herbie0.5
\[\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 -4.10627005746376719e124 < (/.f64 (*.f64 x (+.f64 y z)) z) < 1.67712790909505627e-155

    1. Initial program 16.4

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

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

    if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -4.10627005746376719e124 or 1.67712790909505627e-155 < (/.f64 (*.f64 x (+.f64 y z)) z) < 7.5367768443051555e301

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{x + \frac{x}{\frac{z}{y}}}\]
    3. Using strategy rm
    4. Applied div-inv_binary64_72366.0

      \[\leadsto x + \frac{x}{\color{blue}{z \cdot \frac{1}{y}}}\]
    5. Applied *-un-lft-identity_binary64_72396.0

      \[\leadsto x + \frac{\color{blue}{1 \cdot x}}{z \cdot \frac{1}{y}}\]
    6. Applied times-frac_binary64_72450.3

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

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

    if 7.5367768443051555e301 < (/.f64 (*.f64 x (+.f64 y z)) z)

    1. Initial program 61.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\ \;\;\;\;x + \frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -4.106270057463767 \cdot 10^{+124}:\\ \;\;\;\;x + \frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 1.6771279090950563 \cdot 10^{-155}:\\ \;\;\;\;x + \frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 7.536776844305155 \cdot 10^{+301}:\\ \;\;\;\;x + \frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \end{array}\]

Reproduce

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