\[ \begin{array}{c}[d2, d4] = \mathsf{sort}([d2, d4])\\ \end{array} \]
\[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\]
↓
\[\mathsf{fma}\left(d1, d4 - d1, d1 \cdot \left(d2 - d3\right)\right)
\]
(FPCore (d1 d2 d3 d4)
:precision binary64
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
↓
(FPCore (d1 d2 d3 d4) :precision binary64 (fma d1 (- d4 d1) (* d1 (- d2 d3))))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
↓
double code(double d1, double d2, double d3, double d4) {
return fma(d1, (d4 - d1), (d1 * (d2 - d3)));
}
function code(d1, d2, d3, d4)
return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1))
end
↓
function code(d1, d2, d3, d4)
return fma(d1, Float64(d4 - d1), Float64(d1 * Float64(d2 - d3)))
end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
↓
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(d4 - d1), $MachinePrecision] + N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
↓
\mathsf{fma}\left(d1, d4 - d1, d1 \cdot \left(d2 - d3\right)\right)
Alternatives
| Alternative 1 |
|---|
| Error | 0.0 |
|---|
| Cost | 6976 |
|---|
\[\mathsf{fma}\left(d1, d2 - d3, d1 \cdot \left(d4 - d1\right)\right)
\]
| Alternative 2 |
|---|
| Error | 20.9 |
|---|
| Cost | 1509 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := -d1 \cdot d3\\
t_2 := d1 \cdot \left(d4 - d1\right)\\
t_3 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d3 \leq -5.2 \cdot 10^{+104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq -5 \cdot 10^{-213}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;d3 \leq -7.6 \cdot 10^{-304}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 4.6 \cdot 10^{-274}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq 7.2 \cdot 10^{-262}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 3.2 \cdot 10^{-182}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq 4 \cdot 10^{+95} \lor \neg \left(d3 \leq 5.9 \cdot 10^{+141}\right) \land d3 \leq 4.2 \cdot 10^{+192}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 17.1 |
|---|
| Cost | 1244 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
t_2 := d1 \cdot \left(d4 - d1\right)\\
t_3 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d3 \leq -2.2 \cdot 10^{+69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq -1.25 \cdot 10^{-213}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;d3 \leq -1.8 \cdot 10^{-305}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 5.4 \cdot 10^{-274}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq 1.32 \cdot 10^{-261}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 2.75 \cdot 10^{-182}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq 10^{+81}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 20.1 |
|---|
| Cost | 1113 |
|---|
\[\begin{array}{l}
t_0 := -d1 \cdot d3\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d3 \leq -3.2 \cdot 10^{+104}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -7.5 \cdot 10^{-301}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 2 \cdot 10^{-183}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{elif}\;d3 \leq 1.05 \cdot 10^{+96} \lor \neg \left(d3 \leq 8 \cdot 10^{+142}\right) \land d3 \leq 2.4 \cdot 10^{+192}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 30.4 |
|---|
| Cost | 984 |
|---|
\[\begin{array}{l}
t_0 := -d1 \cdot d3\\
\mathbf{if}\;d4 \leq -1.12 \cdot 10^{-105}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.22 \cdot 10^{-108}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 6.6 \cdot 10^{-68}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.7 \cdot 10^{-18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.06 \cdot 10^{+20}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 1.4 \cdot 10^{+38}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 19.0 |
|---|
| Cost | 850 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d3 \leq -2.1 \cdot 10^{+104} \lor \neg \left(d3 \leq 1.06 \cdot 10^{+96}\right) \land \left(d3 \leq 7.5 \cdot 10^{+142} \lor \neg \left(d3 \leq 2.4 \cdot 10^{+192}\right)\right):\\
\;\;\;\;-d1 \cdot d3\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 8.0 |
|---|
| Cost | 848 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -3.2 \cdot 10^{+103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 7.8 \cdot 10^{+80}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{elif}\;d3 \leq 8 \cdot 10^{+142}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 2.5 \cdot 10^{+159}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 2.8 |
|---|
| Cost | 713 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d3 \leq -8.2 \cdot 10^{-57} \lor \neg \left(d3 \leq 1.35 \cdot 10^{-53}\right):\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 4.7 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d1 \leq -17500000000000:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{+22}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 30.8 |
|---|
| Cost | 588 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 6.2 \cdot 10^{-22}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 9.5 \cdot 10^{+19}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 1.2 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 13.0 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 1.7 \cdot 10^{-18}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 6 \cdot 10^{+27}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 0.0 |
|---|
| Cost | 576 |
|---|
\[d1 \cdot \left(\left(d4 - d1\right) + \left(d2 - d3\right)\right)
\]
| Alternative 13 |
|---|
| Error | 30.7 |
|---|
| Cost | 324 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 3.2 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 44.1 |
|---|
| Cost | 192 |
|---|
\[d1 \cdot d4
\]