| Alternative 1 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 13248 |
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)
\]
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* z t) (* x y))))) (if (<= t_1 INFINITY) t_1 (fma y x (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(y, x, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(y, x, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\left(x \cdot y + z \cdot t\right) + a \cdot b
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in z around 0 30.0%
Simplified60.0%
[Start]30.0 | \[ a \cdot b + y \cdot x
\] |
|---|---|
+-commutative [=>]30.0 | \[ \color{blue}{y \cdot x + a \cdot b}
\] |
fma-def [=>]60.0 | \[ \color{blue}{\mathsf{fma}\left(y, x, a \cdot b\right)}
\] |
Final simplification98.4%
| Alternative 1 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 1476 |
| Alternative 3 | |
|---|---|
| Accuracy | 53.7% |
| Cost | 1232 |
| Alternative 4 | |
|---|---|
| Accuracy | 78.2% |
| Cost | 978 |
| Alternative 5 | |
|---|---|
| Accuracy | 85.2% |
| Cost | 969 |
| Alternative 6 | |
|---|---|
| Accuracy | 67.9% |
| Cost | 713 |
| Alternative 7 | |
|---|---|
| Accuracy | 54.1% |
| Cost | 712 |
| Alternative 8 | |
|---|---|
| Accuracy | 34.5% |
| Cost | 192 |
herbie shell --seed 2023160
(FPCore (x y z t a b)
:name "Linear.V3:$cdot from linear-1.19.1.3, B"
:precision binary64
(+ (+ (* x y) (* z t)) (* a b)))