Average Error: 12.4 → 2.0
Time: 1.6s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.38635864862267137 \cdot 10^{-72} \lor \neg \left(x \le 1.7087081133191823 \cdot 10^{-110}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{-z}, -y, x\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -1.38635864862267137 \cdot 10^{-72} \lor \neg \left(x \le 1.7087081133191823 \cdot 10^{-110}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}} + x\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{-z}, -y, x\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 VAR;
	if (((x <= -1.3863586486226714e-72) || !(x <= 1.7087081133191823e-110))) {
		VAR = ((x / (z / y)) + x);
	} else {
		VAR = fma((x / -z), -y, x);
	}
	return VAR;
}

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.3863586486226714e-72 or 1.7087081133191823e-110 < x

    1. Initial program 16.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef0.9

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied clear-num1.0

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{y}}} \cdot x + x\]
    7. Applied associate-*l/0.8

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

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

    if -1.3863586486226714e-72 < x < 1.7087081133191823e-110

    1. Initial program 6.8

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef6.7

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied clear-num6.7

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{y}}} \cdot x + x\]
    7. Applied associate-*l/6.2

      \[\leadsto \color{blue}{\frac{1 \cdot x}{\frac{z}{y}}} + x\]
    8. Simplified6.2

      \[\leadsto \frac{\color{blue}{x}}{\frac{z}{y}} + x\]
    9. Using strategy rm
    10. Applied frac-2neg6.2

      \[\leadsto \frac{x}{\color{blue}{\frac{-z}{-y}}} + x\]
    11. Applied associate-/r/3.6

      \[\leadsto \color{blue}{\frac{x}{-z} \cdot \left(-y\right)} + x\]
    12. Applied fma-def3.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{-z}, -y, x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.38635864862267137 \cdot 10^{-72} \lor \neg \left(x \le 1.7087081133191823 \cdot 10^{-110}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{-z}, -y, x\right)\\ \end{array}\]

Reproduce

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