Average Error: 3.6 → 2.7
Time: 3.5s
Precision: binary64
\[\]
\[\]
\[\]
double code(double a, double b, double c, double d) {
	return ((double) (((double) (a + ((double) (b + ((double) (c + d)))))) * 2.0));
}
double code(double a, double b, double c, double d) {
	return ((double) (((double) (a + ((double) (((double) (b + c)) + d)))) * 2.0));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.6
Target3.8
Herbie2.7
\[\]

Derivation

  1. Initial program 3.6

    \[\]
  2. Using strategy rm
  3. Applied associate-+r+2.7

    \[\leadsto \]
  4. Final simplification2.7

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (a b c d)
  :name "Expression, p6"
  :precision binary64
  :pre (and (<= -14.0 a -13.0) (<= -3.0 b -2.0) (<= 3.0 c 3.5) (<= 12.5 d 13.5))

  :herbie-target
  (+ (* (+ a b) 2.0) (* (+ c d) 2.0))

  (* (+ a (+ b (+ c d))) 2.0))