\[ \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, d2 - d3, d1 \cdot \left(d4 - d1\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 (- d2 d3) (* d1 (- d4 d1))))
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, (d2 - d3), (d1 * (d4 - d1)));
}
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(d2 - d3), Float64(d1 * Float64(d4 - d1)))
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[(d2 - d3), $MachinePrecision] + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
↓
\mathsf{fma}\left(d1, d2 - d3, d1 \cdot \left(d4 - d1\right)\right)
Alternatives
| Alternative 1 |
|---|
| Error | 15.5 |
|---|
| Cost | 1108 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
t_1 := d1 \cdot \left(d4 - d1\right)\\
\mathbf{if}\;d3 \leq -2.3544833646285208 \cdot 10^{+113}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -3.825501482466774 \cdot 10^{+84}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq -3.448076334887785 \cdot 10^{+53}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq -574373177314322900:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 1.927371358207162 \cdot 10^{+119}:\\
\;\;\;\;d1 \cdot d4 + d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 15.5 |
|---|
| Cost | 980 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d2 + d4\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
t_2 := d1 \cdot \left(d4 - d1\right)\\
\mathbf{if}\;d3 \leq -2.3544833646285208 \cdot 10^{+113}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq -3.825501482466774 \cdot 10^{+84}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq -3.448076334887785 \cdot 10^{+53}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -574373177314322900:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq 1.927371358207162 \cdot 10^{+119}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 16.5 |
|---|
| Cost | 848 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d3\right)\\
\mathbf{if}\;d2 \leq -2.8645683616144374 \cdot 10^{+97}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -2.2953449869905247 \cdot 10^{+35}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq -4.22899108828013 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -4.195010618982268 \cdot 10^{+20}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 29.2 |
|---|
| Cost | 784 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d4 \leq -2.8958648435099907 \cdot 10^{-19}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq -1.4868189919802926 \cdot 10^{-102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 6.16918366052222 \cdot 10^{-303}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 5788881537600.205:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 2.8 |
|---|
| Cost | 708 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 2.3588317800041587 \cdot 10^{-49}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4 + d1 \cdot \left(d2 - d3\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.0 |
|---|
| Cost | 704 |
|---|
\[d1 \cdot \left(d2 - \left(d1 + d3\right)\right) + d1 \cdot d4
\]
| Alternative 7 |
|---|
| Error | 15.5 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d3\right)\\
\mathbf{if}\;d3 \leq -2.6375710794760755 \cdot 10^{+144}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 1.6258774209151778 \cdot 10^{+119}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 6.3 |
|---|
| Cost | 580 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d1 \leq 1.3 \cdot 10^{+50}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 2.8 |
|---|
| Cost | 580 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 2.3588317800041587 \cdot 10^{-49}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 0.0 |
|---|
| Cost | 576 |
|---|
\[d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)
\]
| Alternative 11 |
|---|
| Error | 12.5 |
|---|
| Cost | 452 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 4.7966823443891195 \cdot 10^{-58}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 30.8 |
|---|
| Cost | 324 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d4 \leq 4.7966823443891195 \cdot 10^{-58}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 60.9 |
|---|
| Cost | 192 |
|---|
\[d1 \cdot d3
\]
| Alternative 14 |
|---|
| Error | 60.7 |
|---|
| Cost | 192 |
|---|
\[d1 \cdot d1
\]
| Alternative 15 |
|---|
| Error | 43.8 |
|---|
| Cost | 192 |
|---|
\[d1 \cdot d2
\]