Average Error: 12.4 → 3.0
Time: 2.3s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.9851351852842985 \cdot 10^{-54} \lor \neg \left(z \le 4.35859024137570151 \cdot 10^{-87}\right):\\ \;\;\;\;\frac{x \cdot 1}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + z}{\frac{z}{x}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.9851351852842985 \cdot 10^{-54} \lor \neg \left(z \le 4.35859024137570151 \cdot 10^{-87}\right):\\
\;\;\;\;\frac{x \cdot 1}{\frac{z}{y + z}}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((x * (y + z)) / z);
}
double code(double x, double y, double z) {
	double temp;
	if (((z <= -1.9851351852842985e-54) || !(z <= 4.3585902413757015e-87))) {
		temp = ((x * 1.0) / (z / (y + z)));
	} else {
		temp = ((y + z) / (z / x));
	}
	return temp;
}

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.1
Herbie3.0
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.9851351852842985e-54 or 4.3585902413757015e-87 < z

    1. Initial program 14.0

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(1 \cdot \left(y + z\right)\right)}}{z}\]
    4. Applied associate-*r*14.0

      \[\leadsto \frac{\color{blue}{\left(x \cdot 1\right) \cdot \left(y + z\right)}}{z}\]
    5. Applied associate-/l*0.3

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

    if -1.9851351852842985e-54 < z < 4.3585902413757015e-87

    1. Initial program 8.8

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

      \[\leadsto \frac{\color{blue}{\left(y + z\right) \cdot x}}{z}\]
    4. Applied associate-/l*8.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.9851351852842985 \cdot 10^{-54} \lor \neg \left(z \le 4.35859024137570151 \cdot 10^{-87}\right):\\ \;\;\;\;\frac{x \cdot 1}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + z}{\frac{z}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(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))