| Alternative 1 | |
|---|---|
| Error | 73.5% |
| Cost | 456.00 |
\[\begin{array}{l}
\mathbf{if}\;d3 \leq -2.7 \cdot 10^{-183}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d3 \leq 36:\\
\;\;\;\;37 \cdot d1\\
\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 (+ 37.0 d3) d1 (* d1 d2)))
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((37.0 + d3), d1, (d1 * d2));
}
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(Float64(37.0 + d3), d1, Float64(d1 * d2)) 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[(N[(37.0 + d3), $MachinePrecision] * d1 + N[(d1 * d2), $MachinePrecision]), $MachinePrecision]
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\mathsf{fma}\left(37 + d3, d1, d1 \cdot d2\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)
\] |
Taylor expanded in d2 around 0 100.0
Applied egg-rr100.0
Final simplification100.0
| Alternative 1 | |
|---|---|
| Error | 73.5% |
| Cost | 456.00 |
| Alternative 2 | |
|---|---|
| Error | 93.1% |
| Cost | 452.00 |
| Alternative 3 | |
|---|---|
| Error | 93.9% |
| Cost | 452.00 |
| Alternative 4 | |
|---|---|
| Error | 100.0% |
| Cost | 448.00 |
| Alternative 5 | |
|---|---|
| Error | 64.2% |
| Cost | 324.00 |
| Alternative 6 | |
|---|---|
| Error | 33.0% |
| Cost | 192.00 |
herbie shell --seed 2023093
(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)))