Average Error: 12.3 → 3.0
Time: 1.6s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.5037721768491619 \cdot 10^{-102} \lor \neg \left(z \le -4.15245894315525662 \cdot 10^{-198}\right):\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -3.5037721768491619 \cdot 10^{-102} \lor \neg \left(z \le -4.15245894315525662 \cdot 10^{-198}\right):\\
\;\;\;\;\frac{y}{z} \cdot x + x\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{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 VAR;
	if (((z <= -3.503772176849162e-102) || !(z <= -4.1524589431552566e-198))) {
		VAR = (((y / z) * x) + x);
	} else {
		VAR = ((y * (x / z)) + 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.3
Target2.9
Herbie3.0
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -3.503772176849162e-102 or -4.1524589431552566e-198 < z

    1. Initial program 12.6

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

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

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

    if -3.503772176849162e-102 < z < -4.1524589431552566e-198

    1. Initial program 7.8

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

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

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied div-inv8.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.5037721768491619 \cdot 10^{-102} \lor \neg \left(z \le -4.15245894315525662 \cdot 10^{-198}\right):\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} + x\\ \end{array}\]

Reproduce

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