| Alternative 1 | |
|---|---|
| Error | 73.9% |
| Cost | 456.00 |
\[\begin{array}{l}
\mathbf{if}\;d2 \leq -36:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 1.8 \cdot 10^{-159}:\\
\;\;\;\;d1 \cdot 37\\
\mathbf{else}:\\
\;\;\;\;d3 \cdot d1\\
\end{array}
\]
(FPCore (d1 d2 d3) :precision binary64 (+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))
(FPCore (d1 d2 d3) :precision binary64 (fma d3 d1 (* d1 (+ d2 37.0))))
double code(double d1, double d2, double d3) {
return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
double code(double d1, double d2, double d3) {
return fma(d3, d1, (d1 * (d2 + 37.0)));
}
function code(d1, d2, d3) return Float64(Float64(Float64(d1 * d2) + Float64(Float64(d3 + 5.0) * d1)) + Float64(d1 * 32.0)) end
function code(d1, d2, d3) return fma(d3, d1, Float64(d1 * Float64(d2 + 37.0))) end
code[d1_, d2_, d3_] := N[(N[(N[(d1 * d2), $MachinePrecision] + N[(N[(d3 + 5.0), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * 32.0), $MachinePrecision]), $MachinePrecision]
code[d1_, d2_, d3_] := N[(d3 * d1 + N[(d1 * N[(d2 + 37.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\mathsf{fma}\left(d3, d1, d1 \cdot \left(d2 + 37\right)\right)
| Original | 99.9% |
|---|---|
| Target | 100.0% |
| Herbie | 100.0% |
Initial program 99.9
Simplified100.0
[Start]99.9 | \[ \left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\] |
|---|---|
associate-+l+ [=>]99.9 | \[ \color{blue}{d1 \cdot d2 + \left(\left(d3 + 5\right) \cdot d1 + d1 \cdot 32\right)}
\] |
*-commutative [=>]99.9 | \[ d1 \cdot d2 + \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot 32\right)
\] |
distribute-lft-out [=>]100.0 | \[ d1 \cdot d2 + \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + 32\right)}
\] |
distribute-lft-out [=>]100.0 | \[ \color{blue}{d1 \cdot \left(d2 + \left(\left(d3 + 5\right) + 32\right)\right)}
\] |
associate-+l+ [=>]100.0 | \[ d1 \cdot \left(d2 + \color{blue}{\left(d3 + \left(5 + 32\right)\right)}\right)
\] |
metadata-eval [=>]100.0 | \[ d1 \cdot \left(d2 + \left(d3 + \color{blue}{37}\right)\right)
\] |
Applied egg-rr100.0
Applied egg-rr100.0
Final simplification100.0
| Alternative 1 | |
|---|---|
| Error | 73.9% |
| Cost | 456.00 |
| Alternative 2 | |
|---|---|
| Error | 93.3% |
| Cost | 452.00 |
| Alternative 3 | |
|---|---|
| Error | 93.6% |
| Cost | 452.00 |
| Alternative 4 | |
|---|---|
| Error | 100.0% |
| Cost | 448.00 |
| Alternative 5 | |
|---|---|
| Error | 64.4% |
| Cost | 324.00 |
| Alternative 6 | |
|---|---|
| Error | 33.0% |
| Cost | 192.00 |
herbie shell --seed 2023097
(FPCore (d1 d2 d3)
:name "FastMath dist3"
:precision binary64
:herbie-target
(* d1 (+ (+ 37.0 d3) d2))
(+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))