Average Error: 13.1 → 0.3
Time: 2.5s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -1.6477445116941071 \cdot 10^{56} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 8.0133830656333959 \cdot 10^{-67} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 7.426458603776121 \cdot 10^{296}\right)\right)\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -1.6477445116941071 \cdot 10^{56} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 8.0133830656333959 \cdot 10^{-67} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 7.426458603776121 \cdot 10^{296}\right)\right)\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y + z)))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if (((((double) (((double) (x * ((double) (y + z)))) / z)) <= -inf.0) || !((((double) (((double) (x * ((double) (y + z)))) / z)) <= -1.6477445116941071e+56) || !((((double) (((double) (x * ((double) (y + z)))) / z)) <= 8.013383065633396e-67) || !(((double) (((double) (x * ((double) (y + z)))) / z)) <= 7.42645860377612e+296))))) {
		VAR = ((double) fma(((double) (y / z)), x, x));
	} else {
		VAR = ((double) (((double) (x * ((double) (y + z)))) / z));
	}
	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

Original13.1
Target2.7
Herbie0.3
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0 or -1.6477445116941071e+56 < (/ (* x (+ y z)) z) < 8.013383065633396e-67 or 7.42645860377612e+296 < (/ (* x (+ y z)) z)

    1. Initial program 22.2

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

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

    if -inf.0 < (/ (* x (+ y z)) z) < -1.6477445116941071e+56 or 8.013383065633396e-67 < (/ (* x (+ y z)) z) < 7.42645860377612e+296

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -1.6477445116941071 \cdot 10^{56} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 8.0133830656333959 \cdot 10^{-67} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 7.426458603776121 \cdot 10^{296}\right)\right)\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \end{array}\]

Reproduce

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