Average Error: 12.4 → 1.8
Time: 3.1s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -4.719214907735761 \cdot 10^{-47} \lor \neg \left(z \leq 3.2862580425901126 \cdot 10^{-67}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -4.719214907735761 \cdot 10^{-47} \lor \neg \left(z \leq 3.2862580425901126 \cdot 10^{-67}\right):\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -4.719214907735761e-47) (not (<= z 3.2862580425901126e-67)))
   (/ x (/ z (+ z y)))
   (+ x (/ (* x y) 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 (((z <= -4.719214907735761e-47) || !(z <= 3.2862580425901126e-67))) {
		tmp = (x / (z / ((double) (z + y))));
	} else {
		tmp = ((double) (x + (((double) (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.4
Target3.2
Herbie1.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -4.719214907735761e-47 or 3.28625804259011263e-67 < z

    1. Initial program 14.8

      \[\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 -4.719214907735761e-47 < z < 3.28625804259011263e-67

    1. Initial program 7.8

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 4.8

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Simplified4.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.719214907735761 \cdot 10^{-47} \lor \neg \left(z \leq 3.2862580425901126 \cdot 10^{-67}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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