Average Error: 3.6 → 0
Time: 3.8s
Precision: binary64
Cost: 576
\[-14 \leq a \land a \leq -13 \land -3 \leq b \land b \leq -2 \land 3 \leq c \land c \leq 3.5 \land 12.5 \leq d \land d \leq 13.5\]
\[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2\]
\[2 \cdot \left(\left(b + c\right) + \left(a + d\right)\right)\]
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
2 \cdot \left(\left(b + c\right) + \left(a + d\right)\right)
(FPCore (a b c d) :precision binary64 (* (+ a (+ b (+ c d))) 2.0))
(FPCore (a b c d) :precision binary64 (* 2.0 (+ (+ b c) (+ a d))))
double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
double code(double a, double b, double c, double d) {
	return 2.0 * ((b + c) + (a + d));
}

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
Herbie0
\[\left(a + b\right) \cdot 2 + \left(c + d\right) \cdot 2\]

Alternatives

Alternative 1
Error3.6
Cost576
\[2 \cdot \left(a + \left(b + \left(c + d\right)\right)\right)\]
Alternative 2
Error54.6
Cost385
\[\begin{array}{l} \mathbf{if}\;d \leq 12.734247393548207:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
Alternative 3
Error55.1
Cost64
\[1\]

Error

Derivation

  1. Initial program 3.6

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2\]
  2. Using strategy rm
  3. Applied associate-+r+_binary64_20562.8

    \[\leadsto \left(a + \color{blue}{\left(\left(b + c\right) + d\right)}\right) \cdot 2\]
  4. Using strategy rm
  5. Applied add-log-exp_binary64_21632.8

    \[\leadsto \left(a + \left(\left(b + c\right) + \color{blue}{\log \left(e^{d}\right)}\right)\right) \cdot 2\]
  6. Applied add-log-exp_binary64_21632.8

    \[\leadsto \left(a + \left(\left(b + \color{blue}{\log \left(e^{c}\right)}\right) + \log \left(e^{d}\right)\right)\right) \cdot 2\]
  7. Applied add-log-exp_binary64_21632.8

    \[\leadsto \left(a + \left(\left(\color{blue}{\log \left(e^{b}\right)} + \log \left(e^{c}\right)\right) + \log \left(e^{d}\right)\right)\right) \cdot 2\]
  8. Applied sum-log_binary64_22152.8

    \[\leadsto \left(a + \left(\color{blue}{\log \left(e^{b} \cdot e^{c}\right)} + \log \left(e^{d}\right)\right)\right) \cdot 2\]
  9. Applied sum-log_binary64_22152.8

    \[\leadsto \left(a + \color{blue}{\log \left(\left(e^{b} \cdot e^{c}\right) \cdot e^{d}\right)}\right) \cdot 2\]
  10. Applied add-log-exp_binary64_21632.8

    \[\leadsto \left(\color{blue}{\log \left(e^{a}\right)} + \log \left(\left(e^{b} \cdot e^{c}\right) \cdot e^{d}\right)\right) \cdot 2\]
  11. Applied sum-log_binary64_22151.5

    \[\leadsto \color{blue}{\log \left(e^{a} \cdot \left(\left(e^{b} \cdot e^{c}\right) \cdot e^{d}\right)\right)} \cdot 2\]
  12. Simplified3.0

    \[\leadsto \log \color{blue}{\left(e^{a + \left(d + \left(b + c\right)\right)}\right)} \cdot 2\]
  13. Using strategy rm
  14. Applied associate-+r+_binary64_20560.9

    \[\leadsto \log \left(e^{\color{blue}{\left(a + d\right) + \left(b + c\right)}}\right) \cdot 2\]
  15. Using strategy rm
  16. Applied exp-sum_binary64_21701.2

    \[\leadsto \log \color{blue}{\left(e^{a + d} \cdot e^{b + c}\right)} \cdot 2\]
  17. Applied log-prod_binary64_22100.8

    \[\leadsto \color{blue}{\left(\log \left(e^{a + d}\right) + \log \left(e^{b + c}\right)\right)} \cdot 2\]
  18. Simplified0.5

    \[\leadsto \left(\color{blue}{\left(a + d\right)} + \log \left(e^{b + c}\right)\right) \cdot 2\]
  19. Simplified0

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(b + c\right) + \left(a + d\right)\right)}\]
  21. Final simplification0

    \[\leadsto 2 \cdot \left(\left(b + c\right) + \left(a + d\right)\right)\]

Reproduce

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