Average Error: 0.0 → 0.0
Time: 2.9s
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)\]
\[a \cdot \left(\left(b + c\right) + d\right) \]
\[\mathsf{fma}\left(b + c, a, a \cdot d\right) \]
a \cdot \left(\left(b + c\right) + d\right)
\mathsf{fma}\left(b + c, a, a \cdot d\right)
(FPCore (a b c d) :precision binary64 (* a (+ (+ b c) d)))
(FPCore (a b c d) :precision binary64 (fma (+ b c) a (* a d)))
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((b + c), a, (a * d));
}

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. Applied fma-def_binary640.0

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

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

Reproduce

herbie shell --seed 2021275 
(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)))