?

Average Accuracy: 99.9% → 100.0%
Time: 6.3s
Precision: binary64
Cost: 6848.00

?

\[\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

Original99.9%
Target99.9%
Herbie100.0%
\[a \cdot b + a \cdot \left(c + d\right) \]

Derivation?

  1. Initial program 99.9%

    \[a \cdot \left(\left(b + c\right) + d\right) \]
  2. Applied egg-rr100.0%

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

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

Alternatives

Alternative 1
Accuracy53.9%
Cost984.00
\[\begin{array}{l} \mathbf{if}\;d \leq 2.5 \cdot 10^{-263}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 1.42 \cdot 10^{-216}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-199}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{-183}:\\ \;\;\;\;c \cdot a\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-134}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-130}:\\ \;\;\;\;c \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot d\\ \end{array} \]
Alternative 2
Accuracy83.9%
Cost982.00
\[\begin{array}{l} \mathbf{if}\;b \leq 1.8 \cdot 10^{-151} \lor \neg \left(b \leq 2.9 \cdot 10^{-139}\right) \land \left(b \leq 5.4 \cdot 10^{-121} \lor \neg \left(b \leq 1.55 \cdot 10^{-92}\right) \land b \leq 1.12 \cdot 10^{-79}\right):\\ \;\;\;\;a \cdot \left(c + d\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \end{array} \]
Alternative 3
Accuracy85.6%
Cost981.00
\[\begin{array}{l} t_0 := a \cdot \left(b + d\right)\\ t_1 := \left(b + c\right) \cdot a\\ \mathbf{if}\;d \leq 5.8 \cdot 10^{-162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.9 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 9.8 \cdot 10^{-87} \lor \neg \left(d \leq 2.7 \cdot 10^{-61}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(c + d\right)\\ \end{array} \]
Alternative 4
Accuracy78.7%
Cost452.00
\[\begin{array}{l} \mathbf{if}\;d \leq 2.6 \cdot 10^{-126}:\\ \;\;\;\;\left(b + c\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot d\\ \end{array} \]
Alternative 5
Accuracy99.9%
Cost448.00
\[a \cdot \left(\left(b + c\right) + d\right) \]
Alternative 6
Accuracy53.1%
Cost324.00
\[\begin{array}{l} \mathbf{if}\;c \leq 2.6 \cdot 10^{-133}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;c \cdot a\\ \end{array} \]
Alternative 7
Accuracy35.2%
Cost192.00
\[b \cdot a \]

Error

Reproduce?

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