Average Error: 0.4 → 0.2
Time: 6.4s
Precision: binary64
\[\left(\left(\left(\left(\left(\left(\left(\left(1 \leq a \land a \leq 2\right) \land 2 \leq b\right) \land b \leq 4\right) \land 4 \leq c\right) \land c \leq 8\right) \land 8 \leq d\right) \land d \leq 16\right) \land 16 \leq e\right) \land e \leq 32\]
\[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
\[\mathsf{fma}\left(1, e, \mathsf{fma}\left(\sqrt{d}, \sqrt{d}, c + \left(b + a\right)\right)\right) \]
\left(\left(\left(e + d\right) + c\right) + b\right) + a
\mathsf{fma}\left(1, e, \mathsf{fma}\left(\sqrt{d}, \sqrt{d}, c + \left(b + a\right)\right)\right)
(FPCore (a b c d e) :precision binary64 (+ (+ (+ (+ e d) c) b) a))
(FPCore (a b c d e)
 :precision binary64
 (fma 1.0 e (fma (sqrt d) (sqrt d) (+ c (+ b a)))))
double code(double a, double b, double c, double d, double e) {
	return (((e + d) + c) + b) + a;
}
double code(double a, double b, double c, double d, double e) {
	return fma(1.0, e, fma(sqrt(d), sqrt(d), (c + (b + a))));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Bits error versus e

Target

Original0.4
Target0.2
Herbie0.2
\[\left(d + \left(c + \left(a + b\right)\right)\right) + e \]

Derivation

  1. Initial program 0.4

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Applied egg-rr0.4

    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(1, e, d + c\right)} + b\right) + a \]
  3. Applied egg-rr0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(1, e, \left(d + c\right) + \left(b + a\right)\right)} \]
  4. Applied egg-rr0.2

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

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

Reproduce

herbie shell --seed 2022130 
(FPCore (a b c d e)
  :name "Expression 1, p15"
  :precision binary64
  :pre (and (and (and (and (and (and (and (and (and (<= 1.0 a) (<= a 2.0)) (<= 2.0 b)) (<= b 4.0)) (<= 4.0 c)) (<= c 8.0)) (<= 8.0 d)) (<= d 16.0)) (<= 16.0 e)) (<= e 32.0))

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

  (+ (+ (+ (+ e d) c) b) a))