?

Average Error: 0.0 → 0.0
Time: 6.3s
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
Error29.8
Cost1116
\[\begin{array}{l} \mathbf{if}\;b \leq 1.75 \cdot 10^{-252}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{-233}:\\ \;\;\;\;a \cdot d\\ \mathbf{elif}\;b \leq 1.4 \cdot 10^{-160}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;b \leq 2.7 \cdot 10^{-151}:\\ \;\;\;\;a \cdot d\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-132}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-112}:\\ \;\;\;\;a \cdot d\\ \mathbf{elif}\;b \leq 9.5 \cdot 10^{-103}:\\ \;\;\;\;c \cdot a\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 2
Error13.0
Cost717
\[\begin{array}{l} \mathbf{if}\;d \leq 6.2 \cdot 10^{-95} \lor \neg \left(d \leq 7.4 \cdot 10^{-75}\right) \land d \leq 3.65 \cdot 10^{-65}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot d\\ \end{array} \]
Alternative 3
Error10.3
Cost717
\[\begin{array}{l} \mathbf{if}\;b \leq 1.36 \cdot 10^{-189} \lor \neg \left(b \leq 8.5 \cdot 10^{-170}\right) \land b \leq 1.22 \cdot 10^{-126}:\\ \;\;\;\;a \cdot \left(c + d\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \end{array} \]
Alternative 4
Error0.0
Cost448
\[a \cdot \left(\left(b + c\right) + d\right) \]
Alternative 5
Error30.0
Cost324
\[\begin{array}{l} \mathbf{if}\;b \leq 1.06 \cdot 10^{-102}:\\ \;\;\;\;c \cdot a\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 6
Error41.5
Cost192
\[b \cdot a \]

Error

Reproduce?

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