Average Error: 12.7 → 3.0
Time: 2.0s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 9.056787863554104 \cdot 10^{-163}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{elif}\;x \leq 3.6996407791868194 \cdot 10^{-64}:\\ \;\;\;\;\left(x \cdot \left(z + y\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \leq 9.056787863554104 \cdot 10^{-163}:\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= x 9.056787863554104e-163)
   (/ x (/ z (+ z y)))
   (if (<= x 3.6996407791868194e-64)
     (* (* x (+ z y)) (/ 1.0 z))
     (* x (/ (+ z 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 <= 9.056787863554104e-163) {
		tmp = x / (z / (z + y));
	} else if (x <= 3.6996407791868194e-64) {
		tmp = (x * (z + y)) * (1.0 / z);
	} else {
		tmp = x * ((z + 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.7
Target3.2
Herbie3.0
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if x < 9.05678786355410441e-163

    1. Initial program 11.7

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

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

    if 9.05678786355410441e-163 < x < 3.6996407791868194e-64

    1. Initial program 2.0

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

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

    if 3.6996407791868194e-64 < x

    1. Initial program 18.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 9.056787863554104 \cdot 10^{-163}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{elif}\;x \leq 3.6996407791868194 \cdot 10^{-64}:\\ \;\;\;\;\left(x \cdot \left(z + y\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \end{array}\]

Reproduce

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