Average Error: 0.0 → 0.0
Time: 4.4s
Precision: binary64
\[\left(\left(\left(56789 \leq a \land a \leq 98765\right) \land \left(0 \leq b \land b \leq 1\right)\right) \land \left(0 \leq c \land c \leq 0.0016773\right)\right) \land \left(0 \leq d \land d \leq 0.0016773\right)\]
\[[b, c, d] = \mathsf{sort}([b, c, d]) \\]
\[a \cdot \left(\left(b + c\right) + d\right) \]
\[\mathsf{fma}\left(a, b, \mathsf{fma}\left(a, d, a \cdot c\right)\right) \]
a \cdot \left(\left(b + c\right) + d\right)
\mathsf{fma}\left(a, b, \mathsf{fma}\left(a, d, a \cdot c\right)\right)
(FPCore (a b c d) :precision binary64 (* a (+ (+ b c) d)))
(FPCore (a b c d) :precision binary64 (fma a b (fma a d (* a c))))
double code(double a, double b, double c, double d) {
	return a * ((b + c) + d);
}
double code(double a, double b, double c, double d) {
	return fma(a, b, fma(a, d, (a * c)));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Target

Original0.0
Target0.0
Herbie0.0
\[a \cdot b + a \cdot \left(c + d\right) \]

Derivation

  1. Initial program 0.0

    \[a \cdot \left(\left(b + c\right) + d\right) \]
  2. Applied distribute-rgt-in_binary640.0

    \[\leadsto \color{blue}{\left(b + c\right) \cdot a + d \cdot a} \]
  3. Taylor expanded in a around 0 0.0

    \[\leadsto \color{blue}{a \cdot \left(c + \left(d + b\right)\right)} \]
  4. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, \mathsf{fma}\left(a, d, a \cdot c\right)\right)} \]
  5. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(a, b, \mathsf{fma}\left(a, d, a \cdot c\right)\right) \]

Reproduce

herbie shell --seed 2022024 
(FPCore (a b c d)
  :name "Expression, p14"
  :precision binary64
  :pre (and (and (and (and (<= 56789.0 a) (<= a 98765.0)) (and (<= 0.0 b) (<= b 1.0))) (and (<= 0.0 c) (<= c 0.0016773))) (and (<= 0.0 d) (<= d 0.0016773)))

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

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