
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * 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
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * 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 tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * 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]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * 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
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * 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 tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * 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]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d2 d1) (- d4 d3))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d1) + (d4 - d3));
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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 - d1) + (d4 - d3))
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d1) + (d4 - d3));
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): return d1 * ((d2 - d1) + (d4 - d3))
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d1) + Float64(d4 - d3))) end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * ((d2 - d1) + (d4 - d3));
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d1), $MachinePrecision] + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
d1 \cdot \left(\left(d2 - d1\right) + \left(d4 - d3\right)\right)
\end{array}
Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--90.6%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.02e+16)
(* d1 (- d2 d3))
(if (<= d2 -9.5e-34)
(* d1 (- d4 d1))
(if (or (<= d2 -6.4e-94) (not (<= d2 -3.3e-120)))
(* d1 (- d4 d3))
(* d1 (- d1))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.02e+16) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -9.5e-34) {
tmp = d1 * (d4 - d1);
} else if ((d2 <= -6.4e-94) || !(d2 <= -3.3e-120)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * -d1;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-1.02d+16)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-9.5d-34)) then
tmp = d1 * (d4 - d1)
else if ((d2 <= (-6.4d-94)) .or. (.not. (d2 <= (-3.3d-120)))) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * -d1
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.02e+16) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -9.5e-34) {
tmp = d1 * (d4 - d1);
} else if ((d2 <= -6.4e-94) || !(d2 <= -3.3e-120)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * -d1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.02e+16: tmp = d1 * (d2 - d3) elif d2 <= -9.5e-34: tmp = d1 * (d4 - d1) elif (d2 <= -6.4e-94) or not (d2 <= -3.3e-120): tmp = d1 * (d4 - d3) else: tmp = d1 * -d1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.02e+16) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -9.5e-34) tmp = Float64(d1 * Float64(d4 - d1)); elseif ((d2 <= -6.4e-94) || !(d2 <= -3.3e-120)) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(-d1)); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -1.02e+16)
tmp = d1 * (d2 - d3);
elseif (d2 <= -9.5e-34)
tmp = d1 * (d4 - d1);
elseif ((d2 <= -6.4e-94) || ~((d2 <= -3.3e-120)))
tmp = d1 * (d4 - d3);
else
tmp = d1 * -d1;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.02e+16], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -9.5e-34], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -6.4e-94], N[Not[LessEqual[d2, -3.3e-120]], $MachinePrecision]], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * (-d1)), $MachinePrecision]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.02 \cdot 10^{+16}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -9.5 \cdot 10^{-34}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{elif}\;d2 \leq -6.4 \cdot 10^{-94} \lor \neg \left(d2 \leq -3.3 \cdot 10^{-120}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\end{array}
\end{array}
if d2 < -1.02e16Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
*-commutative79.6%
+-commutative79.6%
*-commutative79.6%
sub-neg79.6%
+-commutative79.6%
associate--l+79.6%
distribute-lft-out--79.6%
fma-define83.1%
distribute-rgt-out--96.6%
Simplified96.6%
Taylor expanded in d4 around 0 83.5%
mul-1-neg83.5%
+-commutative83.5%
unsub-neg83.5%
Simplified83.5%
Taylor expanded in d1 around 0 80.2%
if -1.02e16 < d2 < -9.49999999999999985e-34Initial program 99.8%
sub-neg99.8%
associate-+l+99.8%
*-commutative99.8%
+-commutative99.8%
*-commutative99.8%
sub-neg99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-out--99.8%
distribute-rgt-out--99.8%
distribute-lft-out99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in d2 around 0 99.8%
Taylor expanded in d3 around 0 72.2%
if -9.49999999999999985e-34 < d2 < -6.39999999999999993e-94 or -3.29999999999999967e-120 < d2 Initial program 93.9%
sub-neg93.9%
associate-+l+93.9%
*-commutative93.9%
+-commutative93.9%
*-commutative93.9%
sub-neg93.9%
+-commutative93.9%
associate--l+93.9%
distribute-lft-out--93.9%
distribute-rgt-out--96.1%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around 0 85.1%
Taylor expanded in d1 around 0 65.8%
if -6.39999999999999993e-94 < d2 < -3.29999999999999967e-120Initial program 85.7%
sub-neg85.7%
associate-+l+85.7%
*-commutative85.7%
+-commutative85.7%
*-commutative85.7%
sub-neg85.7%
+-commutative85.7%
associate--l+85.7%
distribute-lft-out--85.7%
distribute-rgt-out--85.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 58.6%
neg-mul-158.6%
Simplified58.6%
Final simplification69.1%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.4e+28)
(* d1 d2)
(if (or (<= d2 -9.5e-214) (and (not (<= d2 -1.3e-258)) (<= d2 1.15e-270)))
(* d1 (- d3))
(* d1 d4))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+28) {
tmp = d1 * d2;
} else if ((d2 <= -9.5e-214) || (!(d2 <= -1.3e-258) && (d2 <= 1.15e-270))) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-1.4d+28)) then
tmp = d1 * d2
else if ((d2 <= (-9.5d-214)) .or. (.not. (d2 <= (-1.3d-258))) .and. (d2 <= 1.15d-270)) then
tmp = d1 * -d3
else
tmp = d1 * d4
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+28) {
tmp = d1 * d2;
} else if ((d2 <= -9.5e-214) || (!(d2 <= -1.3e-258) && (d2 <= 1.15e-270))) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.4e+28: tmp = d1 * d2 elif (d2 <= -9.5e-214) or (not (d2 <= -1.3e-258) and (d2 <= 1.15e-270)): tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.4e+28) tmp = Float64(d1 * d2); elseif ((d2 <= -9.5e-214) || (!(d2 <= -1.3e-258) && (d2 <= 1.15e-270))) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * d4); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -1.4e+28)
tmp = d1 * d2;
elseif ((d2 <= -9.5e-214) || (~((d2 <= -1.3e-258)) && (d2 <= 1.15e-270)))
tmp = d1 * -d3;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.4e+28], N[(d1 * d2), $MachinePrecision], If[Or[LessEqual[d2, -9.5e-214], And[N[Not[LessEqual[d2, -1.3e-258]], $MachinePrecision], LessEqual[d2, 1.15e-270]]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{+28}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -9.5 \cdot 10^{-214} \lor \neg \left(d2 \leq -1.3 \cdot 10^{-258}\right) \land d2 \leq 1.15 \cdot 10^{-270}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.4000000000000001e28Initial program 79.3%
sub-neg79.3%
associate-+l+79.3%
*-commutative79.3%
+-commutative79.3%
*-commutative79.3%
sub-neg79.3%
+-commutative79.3%
associate--l+79.3%
distribute-lft-out--79.3%
distribute-rgt-out--89.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 61.8%
if -1.4000000000000001e28 < d2 < -9.4999999999999999e-214 or -1.30000000000000009e-258 < d2 < 1.1500000000000001e-270Initial program 95.6%
sub-neg95.6%
associate-+l+95.6%
*-commutative95.6%
+-commutative95.6%
*-commutative95.6%
sub-neg95.6%
+-commutative95.6%
associate--l+95.6%
distribute-lft-out--95.6%
distribute-rgt-out--95.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around inf 47.0%
mul-1-neg47.0%
*-commutative47.0%
distribute-rgt-neg-out47.0%
Simplified47.0%
if -9.4999999999999999e-214 < d2 < -1.30000000000000009e-258 or 1.1500000000000001e-270 < d2 Initial program 93.0%
sub-neg93.0%
associate-+l+93.0%
*-commutative93.0%
+-commutative93.0%
*-commutative93.0%
sub-neg93.0%
+-commutative93.0%
associate--l+93.0%
distribute-lft-out--93.0%
distribute-rgt-out--96.1%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d4 around inf 37.2%
Final simplification45.4%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d4 2.1e+71) (and (not (<= d4 2.65e+126)) (<= d4 2.8e+137))) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d4 <= 2.1e+71) || (!(d4 <= 2.65e+126) && (d4 <= 2.8e+137))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if ((d4 <= 2.1d+71) .or. (.not. (d4 <= 2.65d+126)) .and. (d4 <= 2.8d+137)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d4 <= 2.1e+71) || (!(d4 <= 2.65e+126) && (d4 <= 2.8e+137))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if (d4 <= 2.1e+71) or (not (d4 <= 2.65e+126) and (d4 <= 2.8e+137)): tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if ((d4 <= 2.1e+71) || (!(d4 <= 2.65e+126) && (d4 <= 2.8e+137))) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if ((d4 <= 2.1e+71) || (~((d4 <= 2.65e+126)) && (d4 <= 2.8e+137)))
tmp = d1 * (d2 - d3);
else
tmp = d1 * (d2 + d4);
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d4, 2.1e+71], And[N[Not[LessEqual[d4, 2.65e+126]], $MachinePrecision], LessEqual[d4, 2.8e+137]]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.1 \cdot 10^{+71} \lor \neg \left(d4 \leq 2.65 \cdot 10^{+126}\right) \land d4 \leq 2.8 \cdot 10^{+137}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 2.09999999999999989e71 or 2.65000000000000014e126 < d4 < 2.80000000000000001e137Initial program 90.5%
sub-neg90.5%
associate-+l+90.5%
*-commutative90.5%
+-commutative90.5%
*-commutative90.5%
sub-neg90.5%
+-commutative90.5%
associate--l+90.5%
distribute-lft-out--90.5%
fma-define92.9%
distribute-rgt-out--98.6%
Simplified98.6%
Taylor expanded in d4 around 0 78.2%
mul-1-neg78.2%
+-commutative78.2%
unsub-neg78.2%
Simplified78.2%
Taylor expanded in d1 around 0 60.3%
if 2.09999999999999989e71 < d4 < 2.65000000000000014e126 or 2.80000000000000001e137 < d4 Initial program 91.1%
sub-neg91.1%
associate-+l+91.1%
*-commutative91.1%
+-commutative91.1%
*-commutative91.1%
sub-neg91.1%
+-commutative91.1%
associate--l+91.1%
distribute-lft-out--91.1%
distribute-rgt-out--91.1%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 86.9%
Taylor expanded in d3 around 0 79.3%
+-commutative79.3%
Simplified79.3%
Final simplification63.6%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -235000000.0)
(* d1 (- d2 d3))
(if (or (<= d2 -2.3e-36) (not (<= d2 -4.4e-161)))
(* d1 (- d4 d1))
(* d1 (- d3)))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -235000000.0) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -2.3e-36) || !(d2 <= -4.4e-161)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * -d3;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-235000000.0d0)) then
tmp = d1 * (d2 - d3)
else if ((d2 <= (-2.3d-36)) .or. (.not. (d2 <= (-4.4d-161)))) then
tmp = d1 * (d4 - d1)
else
tmp = d1 * -d3
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -235000000.0) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -2.3e-36) || !(d2 <= -4.4e-161)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * -d3;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -235000000.0: tmp = d1 * (d2 - d3) elif (d2 <= -2.3e-36) or not (d2 <= -4.4e-161): tmp = d1 * (d4 - d1) else: tmp = d1 * -d3 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -235000000.0) tmp = Float64(d1 * Float64(d2 - d3)); elseif ((d2 <= -2.3e-36) || !(d2 <= -4.4e-161)) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(-d3)); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -235000000.0)
tmp = d1 * (d2 - d3);
elseif ((d2 <= -2.3e-36) || ~((d2 <= -4.4e-161)))
tmp = d1 * (d4 - d1);
else
tmp = d1 * -d3;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -235000000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -2.3e-36], N[Not[LessEqual[d2, -4.4e-161]], $MachinePrecision]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * (-d3)), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -235000000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -2.3 \cdot 10^{-36} \lor \neg \left(d2 \leq -4.4 \cdot 10^{-161}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\end{array}
\end{array}
if d2 < -2.35e8Initial program 79.9%
sub-neg79.9%
associate-+l+79.9%
*-commutative79.9%
+-commutative79.9%
*-commutative79.9%
sub-neg79.9%
+-commutative79.9%
associate--l+79.9%
distribute-lft-out--79.9%
fma-define83.3%
distribute-rgt-out--96.6%
Simplified96.6%
Taylor expanded in d4 around 0 82.5%
mul-1-neg82.5%
+-commutative82.5%
unsub-neg82.5%
Simplified82.5%
Taylor expanded in d1 around 0 79.2%
if -2.35e8 < d2 < -2.29999999999999996e-36 or -4.40000000000000004e-161 < d2 Initial program 94.1%
sub-neg94.1%
associate-+l+94.1%
*-commutative94.1%
+-commutative94.1%
*-commutative94.1%
sub-neg94.1%
+-commutative94.1%
associate--l+94.1%
distribute-lft-out--94.1%
distribute-rgt-out--96.4%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around 0 84.2%
Taylor expanded in d3 around 0 59.9%
if -2.29999999999999996e-36 < d2 < -4.40000000000000004e-161Initial program 92.3%
sub-neg92.3%
associate-+l+92.3%
*-commutative92.3%
+-commutative92.3%
*-commutative92.3%
sub-neg92.3%
+-commutative92.3%
associate--l+92.3%
distribute-lft-out--92.3%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around inf 51.4%
mul-1-neg51.4%
*-commutative51.4%
distribute-rgt-neg-out51.4%
Simplified51.4%
Final simplification63.6%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.4e-6) (* d1 (- d2 d3)) (if (<= d2 -2.5e-215) (* d1 (- (- d3) d1)) (* d1 (- d4 d3)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e-6) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -2.5e-215) {
tmp = d1 * (-d3 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-1.4d-6)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-2.5d-215)) then
tmp = d1 * (-d3 - d1)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e-6) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -2.5e-215) {
tmp = d1 * (-d3 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.4e-6: tmp = d1 * (d2 - d3) elif d2 <= -2.5e-215: tmp = d1 * (-d3 - d1) else: tmp = d1 * (d4 - d3) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.4e-6) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -2.5e-215) tmp = Float64(d1 * Float64(Float64(-d3) - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -1.4e-6)
tmp = d1 * (d2 - d3);
elseif (d2 <= -2.5e-215)
tmp = d1 * (-d3 - d1);
else
tmp = d1 * (d4 - d3);
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.4e-6], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -2.5e-215], N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{-6}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -2.5 \cdot 10^{-215}:\\
\;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.39999999999999994e-6Initial program 80.6%
sub-neg80.6%
associate-+l+80.6%
*-commutative80.6%
+-commutative80.6%
*-commutative80.6%
sub-neg80.6%
+-commutative80.6%
associate--l+80.6%
distribute-lft-out--80.6%
fma-define83.8%
distribute-rgt-out--96.7%
Simplified96.7%
Taylor expanded in d4 around 0 81.5%
mul-1-neg81.5%
+-commutative81.5%
unsub-neg81.5%
Simplified81.5%
Taylor expanded in d1 around 0 78.3%
if -1.39999999999999994e-6 < d2 < -2.49999999999999978e-215Initial program 95.7%
sub-neg95.7%
associate-+l+95.7%
*-commutative95.7%
+-commutative95.7%
*-commutative95.7%
sub-neg95.7%
+-commutative95.7%
associate--l+95.7%
distribute-lft-out--95.7%
distribute-rgt-out--95.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d4 around 0 73.5%
mul-1-neg73.5%
+-commutative73.5%
distribute-rgt-neg-out73.5%
distribute-neg-in73.5%
unsub-neg73.5%
Simplified73.5%
if -2.49999999999999978e-215 < d2 Initial program 93.2%
sub-neg93.2%
associate-+l+93.2%
*-commutative93.2%
+-commutative93.2%
*-commutative93.2%
sub-neg93.2%
+-commutative93.2%
associate--l+93.2%
distribute-lft-out--93.2%
distribute-rgt-out--95.9%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around 0 81.7%
Taylor expanded in d1 around 0 63.9%
Final simplification69.2%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -4.1e+139) (not (<= d3 1e+92))) (* d1 (- d3)) (* d1 (+ d2 d4))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.1e+139) || !(d3 <= 1e+92)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if ((d3 <= (-4.1d+139)) .or. (.not. (d3 <= 1d+92))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.1e+139) || !(d3 <= 1e+92)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -4.1e+139) or not (d3 <= 1e+92): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -4.1e+139) || !(d3 <= 1e+92)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if ((d3 <= -4.1e+139) || ~((d3 <= 1e+92)))
tmp = d1 * -d3;
else
tmp = d1 * (d2 + d4);
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -4.1e+139], N[Not[LessEqual[d3, 1e+92]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -4.1 \cdot 10^{+139} \lor \neg \left(d3 \leq 10^{+92}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -4.1000000000000002e139 or 1e92 < d3 Initial program 88.1%
sub-neg88.1%
associate-+l+88.1%
*-commutative88.1%
+-commutative88.1%
*-commutative88.1%
sub-neg88.1%
+-commutative88.1%
associate--l+88.1%
distribute-lft-out--88.1%
distribute-rgt-out--92.0%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d3 around inf 72.9%
mul-1-neg72.9%
*-commutative72.9%
distribute-rgt-neg-out72.9%
Simplified72.9%
if -4.1000000000000002e139 < d3 < 1e92Initial program 91.7%
sub-neg91.7%
associate-+l+91.7%
*-commutative91.7%
+-commutative91.7%
*-commutative91.7%
sub-neg91.7%
+-commutative91.7%
associate--l+91.7%
distribute-lft-out--91.7%
distribute-rgt-out--95.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.4%
Taylor expanded in d3 around 0 69.9%
+-commutative69.9%
Simplified69.9%
Final simplification70.8%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.5e+71) (* d1 d2) (if (<= d2 -2.1e-215) (* d1 (- d1)) (* d1 d4))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.5e+71) {
tmp = d1 * d2;
} else if (d2 <= -2.1e-215) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-5.5d+71)) then
tmp = d1 * d2
else if (d2 <= (-2.1d-215)) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.5e+71) {
tmp = d1 * d2;
} else if (d2 <= -2.1e-215) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.5e+71: tmp = d1 * d2 elif d2 <= -2.1e-215: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.5e+71) tmp = Float64(d1 * d2); elseif (d2 <= -2.1e-215) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -5.5e+71)
tmp = d1 * d2;
elseif (d2 <= -2.1e-215)
tmp = d1 * -d1;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.5e+71], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -2.1e-215], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.5 \cdot 10^{+71}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -2.1 \cdot 10^{-215}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -5.5e71Initial program 80.4%
sub-neg80.4%
associate-+l+80.4%
*-commutative80.4%
+-commutative80.4%
*-commutative80.4%
sub-neg80.4%
+-commutative80.4%
associate--l+80.4%
distribute-lft-out--80.4%
distribute-rgt-out--91.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 70.9%
if -5.5e71 < d2 < -2.1e-215Initial program 92.0%
sub-neg92.0%
associate-+l+92.0%
*-commutative92.0%
+-commutative92.0%
*-commutative92.0%
sub-neg92.0%
+-commutative92.0%
associate--l+92.0%
distribute-lft-out--92.0%
distribute-rgt-out--93.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 43.7%
neg-mul-143.7%
Simplified43.7%
if -2.1e-215 < d2 Initial program 93.2%
sub-neg93.2%
associate-+l+93.2%
*-commutative93.2%
+-commutative93.2%
*-commutative93.2%
sub-neg93.2%
+-commutative93.2%
associate--l+93.2%
distribute-lft-out--93.2%
distribute-rgt-out--95.9%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d4 around inf 35.7%
Final simplification44.0%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2e+73) (* d1 (- d2 d3)) (* d1 (- d4 (+ d1 d3)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2e+73) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-2d+73)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2e+73) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2e+73: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2e+73) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -2e+73)
tmp = d1 * (d2 - d3);
else
tmp = d1 * (d4 - (d1 + d3));
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2e+73], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2 \cdot 10^{+73}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -1.99999999999999997e73Initial program 80.0%
sub-neg80.0%
associate-+l+80.0%
*-commutative80.0%
+-commutative80.0%
*-commutative80.0%
sub-neg80.0%
+-commutative80.0%
associate--l+80.0%
distribute-lft-out--80.0%
fma-define80.0%
distribute-rgt-out--95.6%
Simplified95.6%
Taylor expanded in d4 around 0 89.0%
mul-1-neg89.0%
+-commutative89.0%
unsub-neg89.0%
Simplified89.0%
Taylor expanded in d1 around 0 89.1%
if -1.99999999999999997e73 < d2 Initial program 92.9%
sub-neg92.9%
associate-+l+92.9%
*-commutative92.9%
+-commutative92.9%
*-commutative92.9%
sub-neg92.9%
+-commutative92.9%
associate--l+92.9%
distribute-lft-out--92.9%
distribute-rgt-out--95.2%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around 0 86.0%
Final simplification86.5%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -7.5e-8) (* d1 (- (+ d2 d4) d3)) (* d1 (- d4 (+ d1 d3)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.5e-8) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-7.5d-8)) then
tmp = d1 * ((d2 + d4) - d3)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.5e-8) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -7.5e-8: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -7.5e-8) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -7.5e-8)
tmp = d1 * ((d2 + d4) - d3);
else
tmp = d1 * (d4 - (d1 + d3));
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -7.5e-8], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -7.5 \cdot 10^{-8}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -7.4999999999999997e-8Initial program 80.6%
sub-neg80.6%
associate-+l+80.6%
*-commutative80.6%
+-commutative80.6%
*-commutative80.6%
sub-neg80.6%
+-commutative80.6%
associate--l+80.6%
distribute-lft-out--80.6%
distribute-rgt-out--90.2%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 90.3%
if -7.4999999999999997e-8 < d2 Initial program 93.8%
sub-neg93.8%
associate-+l+93.8%
*-commutative93.8%
+-commutative93.8%
*-commutative93.8%
sub-neg93.8%
+-commutative93.8%
associate--l+93.8%
distribute-lft-out--93.8%
distribute-rgt-out--95.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 86.1%
Final simplification87.1%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.4e+18) (* d1 d2) (* d1 d4)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+18) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
real(8) :: tmp
if (d2 <= (-1.4d+18)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+18) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.4e+18: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.4e+18) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -1.4e+18)
tmp = d1 * d2;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.4e+18], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{+18}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.4e18Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
*-commutative79.6%
+-commutative79.6%
*-commutative79.6%
sub-neg79.6%
+-commutative79.6%
associate--l+79.6%
distribute-lft-out--79.6%
distribute-rgt-out--89.8%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 60.7%
if -1.4e18 < d2 Initial program 93.9%
sub-neg93.9%
associate-+l+93.9%
*-commutative93.9%
+-commutative93.9%
*-commutative93.9%
sub-neg93.9%
+-commutative93.9%
associate--l+93.9%
distribute-lft-out--93.9%
distribute-rgt-out--95.9%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d4 around inf 37.5%
Final simplification42.9%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this 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
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): return d1 * d2
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return Float64(d1 * d2) end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * d2;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
d1 \cdot d2
\end{array}
Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--90.6%
distribute-rgt-out--94.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 29.1%
Final simplification29.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + 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 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2024080
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))