\[ \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
\]
↓
\[d1 \cdot \left(d2 - d3\right) + d1 \cdot \left(d4 - d1\right)
\]
(FPCore (d1 d2 d3 d4)
:precision binary64
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
↓
(FPCore (d1 d2 d3 d4)
:precision binary64
(+ (* 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 (d1 * (d2 - d3)) + (d1 * (d4 - d1));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
↓
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (d1 * (d2 - d3)) + (d1 * (d4 - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
↓
public static double code(double d1, double d2, double d3, double d4) {
return (d1 * (d2 - d3)) + (d1 * (d4 - d1));
}
def code(d1, d2, d3, d4):
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
↓
def code(d1, d2, d3, d4):
return (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 Float64(Float64(d1 * Float64(d2 - d3)) + Float64(d1 * Float64(d4 - d1)))
end
function tmp = code(d1, d2, d3, d4)
tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
end
↓
function tmp = code(d1, d2, d3, d4)
tmp = (d1 * (d2 - d3)) + (d1 * (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[(N[(d1 * N[(d2 - d3), $MachinePrecision]), $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
↓
d1 \cdot \left(d2 - d3\right) + d1 \cdot \left(d4 - d1\right)
Alternatives
| Alternative 1 |
|---|
| Error | 28.9 |
|---|
| Cost | 1312 |
|---|
\[\begin{array}{l}
t_0 := d3 \cdot \left(-d1\right)\\
\mathbf{if}\;d4 \leq -4.7 \cdot 10^{-73}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq -1.85 \cdot 10^{-118}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq -1 \cdot 10^{-260}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 1.62 \cdot 10^{-224}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.8 \cdot 10^{-185}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 1.85 \cdot 10^{-119}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.28 \cdot 10^{-90}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 1.6 \cdot 10^{+63}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 22.0 |
|---|
| Cost | 1112 |
|---|
\[\begin{array}{l}
t_0 := \left(d2 - d1\right) \cdot d1\\
t_1 := d3 \cdot \left(-d1\right)\\
\mathbf{if}\;d4 \leq 1.02 \cdot 10^{-184}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 10^{-119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 4 \cdot 10^{-85}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 2.7 \cdot 10^{-25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 9 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.3 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 13.0 |
|---|
| Cost | 1112 |
|---|
\[\begin{array}{l}
t_0 := \left(d4 - d1\right) \cdot d1\\
t_1 := \left(d4 - d3\right) \cdot d1\\
t_2 := \left(d2 - d3\right) \cdot d1\\
\mathbf{if}\;d4 \leq 7.5 \cdot 10^{-18}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d4 \leq 3.5 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 2.15 \cdot 10^{+46}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 10^{+54}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 4.8 \cdot 10^{+57}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d4 \leq 1.5 \cdot 10^{+92}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 15.4 |
|---|
| Cost | 848 |
|---|
\[\begin{array}{l}
t_0 := \left(d2 - d3\right) \cdot d1\\
t_1 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d3 \leq -2.8 \cdot 10^{+19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -5.1 \cdot 10^{-291}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 2.45 \cdot 10^{-219}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{elif}\;d3 \leq 4.1 \cdot 10^{+63}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 5.2 |
|---|
| Cost | 844 |
|---|
\[\begin{array}{l}
t_0 := d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\mathbf{if}\;d4 \leq 9.5 \cdot 10^{-18}:\\
\;\;\;\;\left(d2 - \left(d1 + d3\right)\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 2.1 \cdot 10^{+66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 2 \cdot 10^{+92}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 12.4 |
|---|
| Cost | 780 |
|---|
\[\begin{array}{l}
t_0 := \left(d4 - d3\right) \cdot d1\\
\mathbf{if}\;d2 \leq -1.1 \cdot 10^{+48}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d2 \leq -6.8 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq -4.2 \cdot 10^{-106}:\\
\;\;\;\;\left(d3 + d1\right) \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 14.2 |
|---|
| Cost | 716 |
|---|
\[\begin{array}{l}
t_0 := \left(d2 - d3\right) \cdot d1\\
\mathbf{if}\;d4 \leq 3.5 \cdot 10^{-18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 3.7 \cdot 10^{-5}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 4.2 \cdot 10^{+62}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 18.3 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := d3 \cdot \left(-d1\right)\\
\mathbf{if}\;d3 \leq -5 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 9.2 \cdot 10^{+176}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 5.5 |
|---|
| Cost | 580 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d2 \leq -9 \cdot 10^{+78}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 0.0 |
|---|
| Cost | 576 |
|---|
\[d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\]
| Alternative 11 |
|---|
| Error | 30.0 |
|---|
| Cost | 324 |
|---|
\[\begin{array}{l}
\mathbf{if}\;d2 \leq -1.5 \cdot 10^{+46}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 43.1 |
|---|
| Cost | 192 |
|---|
\[d1 \cdot d4
\]