?

Average Error: 0.0 → 0.0
Time: 7.7s
Precision: binary64
Cost: 6848

?

\[\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) \]
(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));
}
function code(a, b, c, d)
	return Float64(a * Float64(Float64(b + c) + d))
end
function code(a, b, c, d)
	return fma(Float64(b + c), a, Float64(a * d))
end
code[a_, b_, c_, d_] := N[(a * N[(N[(b + c), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_, d_] := N[(N[(b + c), $MachinePrecision] * a + N[(a * d), $MachinePrecision]), $MachinePrecision]
a \cdot \left(\left(b + c\right) + d\right)
\mathsf{fma}\left(b + c, a, a \cdot d\right)

Error?

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 egg-rr0.0

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

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

Alternatives

Alternative 1
Error30.5
Cost1380
\[\begin{array}{l} \mathbf{if}\;d \leq 3.4 \cdot 10^{-290}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-274}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-264}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-260}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;d \leq 8.8 \cdot 10^{-249}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-160}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;d \leq 1.26 \cdot 10^{-136}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{-103}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;d \leq 1.12 \cdot 10^{-100}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot d\\ \end{array} \]
Alternative 2
Error0.1
Cost960
\[\left(c \cdot a - \left(a \cdot d\right) \cdot -2\right) + a \cdot \left(b - d\right) \]
Alternative 3
Error9.4
Cost584
\[\begin{array}{l} \mathbf{if}\;c \leq 3.8 \cdot 10^{-164}:\\ \;\;\;\;a \cdot \left(b + d\right)\\ \mathbf{elif}\;c \leq 2 \cdot 10^{-94}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(c + d\right)\\ \end{array} \]
Alternative 4
Error0.0
Cost576
\[c \cdot a + a \cdot \left(b + d\right) \]
Alternative 5
Error12.9
Cost452
\[\begin{array}{l} \mathbf{if}\;d \leq 1.2 \cdot 10^{-100}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot d\\ \end{array} \]
Alternative 6
Error10.0
Cost452
\[\begin{array}{l} \mathbf{if}\;d \leq 1.12 \cdot 10^{-100}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(c + d\right)\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[a \cdot \left(\left(b + c\right) + d\right) \]
Alternative 8
Error30.1
Cost324
\[\begin{array}{l} \mathbf{if}\;c \leq 5.5 \cdot 10^{-133}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;c \cdot a\\ \end{array} \]
Alternative 9
Error41.2
Cost192
\[b \cdot a \]

Error

Reproduce?

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