Average Error: 12.0 → 3.1
Time: 2.5s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.161724350185571 \cdot 10^{-40} \lor \neg \left(x \le 1.1452918085668837 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \left(y + z\right)}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -2.161724350185571 \cdot 10^{-40} \lor \neg \left(x \le 1.1452918085668837 \cdot 10^{-153}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{x \cdot \left(y + z\right)}}\\

\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 (((x <= -2.161724350185571e-40) || !(x <= 1.1452918085668837e-153))) {
		temp = fma((y / z), x, x);
	} else {
		temp = (1.0 / (z / (x * (y + z))));
	}
	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.0
Target3.0
Herbie3.1
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -2.161724350185571e-40 or 1.1452918085668837e-153 < x

    1. Initial program 15.9

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified1.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]

    if -2.161724350185571e-40 < x < 1.1452918085668837e-153

    1. Initial program 6.2

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

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot \left(y + z\right)}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.161724350185571 \cdot 10^{-40} \lor \neg \left(x \le 1.1452918085668837 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \left(y + z\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +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))