| Alternative 1 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 324 |
\[\begin{array}{l}
\mathbf{if}\;d3 \leq 7 \cdot 10^{-162}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d3\\
\end{array}
\]
(FPCore (d1 d2 d3) :precision binary64 (+ (* d1 d2) (* d1 d3)))
(FPCore (d1 d2 d3) :precision binary64 (fma d2 d1 (* d1 d3)))
double code(double d1, double d2, double d3) {
return (d1 * d2) + (d1 * d3);
}
double code(double d1, double d2, double d3) {
return fma(d2, d1, (d1 * d3));
}
function code(d1, d2, d3) return Float64(Float64(d1 * d2) + Float64(d1 * d3)) end
function code(d1, d2, d3) return fma(d2, d1, Float64(d1 * d3)) end
code[d1_, d2_, d3_] := N[(N[(d1 * d2), $MachinePrecision] + N[(d1 * d3), $MachinePrecision]), $MachinePrecision]
code[d1_, d2_, d3_] := N[(d2 * d1 + N[(d1 * d3), $MachinePrecision]), $MachinePrecision]
d1 \cdot d2 + d1 \cdot d3
\mathsf{fma}\left(d2, d1, d1 \cdot d3\right)
| Original | 100.0% |
|---|---|
| Target | 100.0% |
| Herbie | 100.0% |
Initial program 100.0%
Simplified100.0%
[Start]100.0 | \[ d1 \cdot d2 + d1 \cdot d3
\] |
|---|---|
distribute-lft-out [=>]100.0 | \[ \color{blue}{d1 \cdot \left(d2 + d3\right)}
\] |
Applied egg-rr100.0%
[Start]100.0 | \[ d1 \cdot \left(d2 + d3\right)
\] |
|---|---|
distribute-rgt-in [=>]100.0 | \[ \color{blue}{d2 \cdot d1 + d3 \cdot d1}
\] |
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(d2, d1, d3 \cdot d1\right)}
\] |
*-commutative [=>]100.0 | \[ \mathsf{fma}\left(d2, d1, \color{blue}{d1 \cdot d3}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 324 |
| Alternative 2 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Accuracy | 53.8% |
| Cost | 192 |
herbie shell --seed 2023151
(FPCore (d1 d2 d3)
:name "FastMath dist"
:precision binary64
:herbie-target
(* d1 (+ d2 d3))
(+ (* d1 d2) (* d1 d3)))