Average Error: 12.7 → 2.8
Time: 4.7s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \leq 2.556206366461948 \cdot 10^{-167}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;y \leq 7.478347114349664 \cdot 10^{+247}:\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x + x \cdot z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \leq 2.556206366461948 \cdot 10^{-167}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;y \leq 7.478347114349664 \cdot 10^{+247}:\\
\;\;\;\;x + y \cdot \frac{x}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y 2.556206366461948e-167)
   (/ x (/ z (+ y z)))
   (if (<= y 7.478347114349664e+247)
     (+ x (* y (/ x z)))
     (/ (+ (* y x) (* x z)) 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 (y <= 2.556206366461948e-167) {
		tmp = x / (z / (y + z));
	} else if (y <= 7.478347114349664e+247) {
		tmp = x + (y * (x / z));
	} else {
		tmp = ((y * x) + (x * z)) / 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
Target2.8
Herbie2.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if y < 2.55622e-167

    1. Initial program 13.2

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified2.2

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

    if 2.55622e-167 < y < 7.47842e247

    1. Initial program 11.4

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified3.3

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Taylor expanded around 0 4.6

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    6. Simplified3.0

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

    if 7.47842e247 < y

    1. Initial program 14.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.556206366461948 \cdot 10^{-167}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;y \leq 7.478347114349664 \cdot 10^{+247}:\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x + x \cdot z}{z}\\ \end{array}\]

Reproduce

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