Average Error: 5.7 → 3.9
Time: 1.8s
Precision: binary64
\[\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;y \le 4.799146880334546 \cdot 10^{-107}:\\ \;\;\;\;\left(b + 1\right) \cdot \left(x \cdot \left(y \cdot a + y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b\\ \end{array}\]
\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b
\begin{array}{l}
\mathbf{if}\;y \le 4.799146880334546 \cdot 10^{-107}:\\
\;\;\;\;\left(b + 1\right) \cdot \left(x \cdot \left(y \cdot a + y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b\\

\end{array}
double code(double x, double y, double a, double b) {
	return ((double) (((double) (((double) (x * y)) + ((double) (((double) (x * y)) * a)))) + ((double) (((double) (((double) (x * y)) + ((double) (((double) (x * y)) * a)))) * b))));
}
double code(double x, double y, double a, double b) {
	double VAR;
	if ((y <= 4.7991468803345464e-107)) {
		VAR = ((double) (((double) (b + 1.0)) * ((double) (x * ((double) (((double) (y * a)) + y))))));
	} else {
		VAR = ((double) (((double) (((double) (x * y)) + ((double) (((double) (x * y)) * a)))) + ((double) (((double) (((double) (x * y)) + ((double) (((double) (x * y)) * a)))) * b))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if y < 4.799146880334546e-107

    1. Initial program 7.5

      \[\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b\]
    2. Simplified5.0

      \[\leadsto \color{blue}{\left(b + 1\right) \cdot \left(x \cdot \left(y \cdot a + y\right)\right)}\]

    if 4.799146880334546e-107 < y

    1. Initial program 1.2

      \[\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 4.799146880334546 \cdot 10^{-107}:\\ \;\;\;\;\left(b + 1\right) \cdot \left(x \cdot \left(y \cdot a + y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y + \left(x \cdot y\right) \cdot a\right) + \left(x \cdot y + \left(x \cdot y\right) \cdot a\right) \cdot b\\ \end{array}\]

Reproduce

herbie shell --seed 2020153 
(FPCore (x y a b)
  :name "(+ (+ (* x y) (* (* x y) a)) (* (+ (* x y) (* (* x y) a)) b))"
  :precision binary64
  (+ (+ (* x y) (* (* x y) a)) (* (+ (* x y) (* (* x y) a)) b)))