Average Error: 12.5 → 2.7
Time: 2.1s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -8.062707745030684 \cdot 10^{-149} \lor \neg \left(z \leq 1.9037644023640054 \cdot 10^{-135}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{z + y}{\sqrt[3]{z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -8.062707745030684 \cdot 10^{-149} \lor \neg \left(z \leq 1.9037644023640054 \cdot 10^{-135}\right):\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{z + y}{\sqrt[3]{z}}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -8.062707745030684e-149) (not (<= z 1.9037644023640054e-135)))
   (/ x (/ z (+ z y)))
   (* (/ x (* (cbrt z) (cbrt z))) (/ (+ z y) (cbrt 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 ((z <= -8.062707745030684e-149) || !(z <= 1.9037644023640054e-135)) {
		tmp = x / (z / (z + y));
	} else {
		tmp = (x / (cbrt(z) * cbrt(z))) * ((z + y) / cbrt(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.5
Target2.9
Herbie2.7
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -8.0627077450306839e-149 or 1.90376440236400544e-135 < z

    1. Initial program 12.8

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

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

    if -8.0627077450306839e-149 < z < 1.90376440236400544e-135

    1. Initial program 11.6

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

      \[\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_binary649.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.062707745030684 \cdot 10^{-149} \lor \neg \left(z \leq 1.9037644023640054 \cdot 10^{-135}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{z + y}{\sqrt[3]{z}}\\ \end{array}\]

Reproduce

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