
(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 15 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 88.6%
sub-neg88.6%
associate-+l+88.6%
*-commutative88.6%
+-commutative88.6%
*-commutative88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
distribute-lft-out--89.4%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (+ d2 d4))) (t_1 (* d1 (- d2 d3))) (t_2 (* d1 (- d2 d1))))
(if (<= d3 -7e+128)
t_1
(if (<= d3 -5e-215)
t_2
(if (<= d3 -5e-310)
t_0
(if (<= d3 7.8e-125) t_2 (if (<= d3 1e+70) t_0 t_1)))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d1 * (d2 - d3);
double t_2 = d1 * (d2 - d1);
double tmp;
if (d3 <= -7e+128) {
tmp = t_1;
} else if (d3 <= -5e-215) {
tmp = t_2;
} else if (d3 <= -5e-310) {
tmp = t_0;
} else if (d3 <= 7.8e-125) {
tmp = t_2;
} else if (d3 <= 1e+70) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = d1 * (d2 + d4)
t_1 = d1 * (d2 - d3)
t_2 = d1 * (d2 - d1)
if (d3 <= (-7d+128)) then
tmp = t_1
else if (d3 <= (-5d-215)) then
tmp = t_2
else if (d3 <= (-5d-310)) then
tmp = t_0
else if (d3 <= 7.8d-125) then
tmp = t_2
else if (d3 <= 1d+70) then
tmp = t_0
else
tmp = t_1
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 t_0 = d1 * (d2 + d4);
double t_1 = d1 * (d2 - d3);
double t_2 = d1 * (d2 - d1);
double tmp;
if (d3 <= -7e+128) {
tmp = t_1;
} else if (d3 <= -5e-215) {
tmp = t_2;
} else if (d3 <= -5e-310) {
tmp = t_0;
} else if (d3 <= 7.8e-125) {
tmp = t_2;
} else if (d3 <= 1e+70) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 + d4) t_1 = d1 * (d2 - d3) t_2 = d1 * (d2 - d1) tmp = 0 if d3 <= -7e+128: tmp = t_1 elif d3 <= -5e-215: tmp = t_2 elif d3 <= -5e-310: tmp = t_0 elif d3 <= 7.8e-125: tmp = t_2 elif d3 <= 1e+70: tmp = t_0 else: tmp = t_1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 + d4)) t_1 = Float64(d1 * Float64(d2 - d3)) t_2 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d3 <= -7e+128) tmp = t_1; elseif (d3 <= -5e-215) tmp = t_2; elseif (d3 <= -5e-310) tmp = t_0; elseif (d3 <= 7.8e-125) tmp = t_2; elseif (d3 <= 1e+70) tmp = t_0; else tmp = t_1; end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = d1 * (d2 + d4);
t_1 = d1 * (d2 - d3);
t_2 = d1 * (d2 - d1);
tmp = 0.0;
if (d3 <= -7e+128)
tmp = t_1;
elseif (d3 <= -5e-215)
tmp = t_2;
elseif (d3 <= -5e-310)
tmp = t_0;
elseif (d3 <= 7.8e-125)
tmp = t_2;
elseif (d3 <= 1e+70)
tmp = t_0;
else
tmp = t_1;
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_] := Block[{t$95$0 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -7e+128], t$95$1, If[LessEqual[d3, -5e-215], t$95$2, If[LessEqual[d3, -5e-310], t$95$0, If[LessEqual[d3, 7.8e-125], t$95$2, If[LessEqual[d3, 1e+70], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 + d4\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
t_2 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -7 \cdot 10^{+128}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq -5 \cdot 10^{-215}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d3 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 7.8 \cdot 10^{-125}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d3 \leq 10^{+70}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d3 < -6.99999999999999937e128 or 1.00000000000000007e70 < d3 Initial program 87.8%
sub-neg87.8%
associate-+l+87.8%
*-commutative87.8%
+-commutative87.8%
*-commutative87.8%
sub-neg87.8%
+-commutative87.8%
associate--l+87.8%
distribute-lft-out--90.2%
distribute-rgt-out--90.2%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 96.3%
associate--l+96.3%
Simplified96.3%
Taylor expanded in d4 around 0 86.8%
if -6.99999999999999937e128 < d3 < -4.99999999999999956e-215 or -4.999999999999985e-310 < d3 < 7.79999999999999965e-125Initial program 88.0%
sub-neg88.0%
associate-+l+88.0%
*-commutative88.0%
+-commutative88.0%
*-commutative88.0%
sub-neg88.0%
+-commutative88.0%
associate--l+88.0%
distribute-lft-out--88.0%
distribute-rgt-out--89.0%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.5%
Taylor expanded in d4 around 0 70.6%
if -4.99999999999999956e-215 < d3 < -4.999999999999985e-310 or 7.79999999999999965e-125 < d3 < 1.00000000000000007e70Initial 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%
distribute-rgt-out--95.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.0%
associate--l+80.0%
Simplified80.0%
Taylor expanded in d3 around 0 75.5%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (+ d2 d4))) (t_1 (* d1 (- d3))) (t_2 (* d1 (- d2 d1))))
(if (<= d3 -8.5e+178)
t_1
(if (<= d3 -2.3e-212)
t_2
(if (<= d3 -9e-309)
t_0
(if (<= d3 1.25e-124) t_2 (if (<= d3 5.8e+149) t_0 t_1)))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d1 * -d3;
double t_2 = d1 * (d2 - d1);
double tmp;
if (d3 <= -8.5e+178) {
tmp = t_1;
} else if (d3 <= -2.3e-212) {
tmp = t_2;
} else if (d3 <= -9e-309) {
tmp = t_0;
} else if (d3 <= 1.25e-124) {
tmp = t_2;
} else if (d3 <= 5.8e+149) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = d1 * (d2 + d4)
t_1 = d1 * -d3
t_2 = d1 * (d2 - d1)
if (d3 <= (-8.5d+178)) then
tmp = t_1
else if (d3 <= (-2.3d-212)) then
tmp = t_2
else if (d3 <= (-9d-309)) then
tmp = t_0
else if (d3 <= 1.25d-124) then
tmp = t_2
else if (d3 <= 5.8d+149) then
tmp = t_0
else
tmp = t_1
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 t_0 = d1 * (d2 + d4);
double t_1 = d1 * -d3;
double t_2 = d1 * (d2 - d1);
double tmp;
if (d3 <= -8.5e+178) {
tmp = t_1;
} else if (d3 <= -2.3e-212) {
tmp = t_2;
} else if (d3 <= -9e-309) {
tmp = t_0;
} else if (d3 <= 1.25e-124) {
tmp = t_2;
} else if (d3 <= 5.8e+149) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 + d4) t_1 = d1 * -d3 t_2 = d1 * (d2 - d1) tmp = 0 if d3 <= -8.5e+178: tmp = t_1 elif d3 <= -2.3e-212: tmp = t_2 elif d3 <= -9e-309: tmp = t_0 elif d3 <= 1.25e-124: tmp = t_2 elif d3 <= 5.8e+149: tmp = t_0 else: tmp = t_1 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 + d4)) t_1 = Float64(d1 * Float64(-d3)) t_2 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d3 <= -8.5e+178) tmp = t_1; elseif (d3 <= -2.3e-212) tmp = t_2; elseif (d3 <= -9e-309) tmp = t_0; elseif (d3 <= 1.25e-124) tmp = t_2; elseif (d3 <= 5.8e+149) tmp = t_0; else tmp = t_1; end return tmp end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = d1 * (d2 + d4);
t_1 = d1 * -d3;
t_2 = d1 * (d2 - d1);
tmp = 0.0;
if (d3 <= -8.5e+178)
tmp = t_1;
elseif (d3 <= -2.3e-212)
tmp = t_2;
elseif (d3 <= -9e-309)
tmp = t_0;
elseif (d3 <= 1.25e-124)
tmp = t_2;
elseif (d3 <= 5.8e+149)
tmp = t_0;
else
tmp = t_1;
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_] := Block[{t$95$0 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * (-d3)), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -8.5e+178], t$95$1, If[LessEqual[d3, -2.3e-212], t$95$2, If[LessEqual[d3, -9e-309], t$95$0, If[LessEqual[d3, 1.25e-124], t$95$2, If[LessEqual[d3, 5.8e+149], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 + d4\right)\\
t_1 := d1 \cdot \left(-d3\right)\\
t_2 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -8.5 \cdot 10^{+178}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq -2.3 \cdot 10^{-212}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d3 \leq -9 \cdot 10^{-309}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 1.25 \cdot 10^{-124}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d3 \leq 5.8 \cdot 10^{+149}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d3 < -8.49999999999999991e178 or 5.8000000000000004e149 < d3 Initial program 87.5%
sub-neg87.5%
associate-+l+87.5%
*-commutative87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
+-commutative87.5%
associate--l+87.5%
distribute-lft-out--90.6%
distribute-rgt-out--90.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around inf 82.9%
mul-1-neg82.9%
distribute-rgt-neg-out82.9%
Simplified82.9%
if -8.49999999999999991e178 < d3 < -2.3000000000000001e-212 or -9.0000000000000021e-309 < d3 < 1.2500000000000001e-124Initial program 87.4%
sub-neg87.4%
associate-+l+87.4%
*-commutative87.4%
+-commutative87.4%
*-commutative87.4%
sub-neg87.4%
+-commutative87.4%
associate--l+87.4%
distribute-lft-out--87.4%
distribute-rgt-out--88.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.7%
Taylor expanded in d4 around 0 69.6%
if -2.3000000000000001e-212 < d3 < -9.0000000000000021e-309 or 1.2500000000000001e-124 < d3 < 5.8000000000000004e149Initial program 91.0%
sub-neg91.0%
associate-+l+91.0%
*-commutative91.0%
+-commutative91.0%
*-commutative91.0%
sub-neg91.0%
+-commutative91.0%
associate--l+91.0%
distribute-lft-out--91.0%
distribute-rgt-out--95.5%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 82.3%
associate--l+82.3%
Simplified82.3%
Taylor expanded in d3 around 0 70.8%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))))
(if (<= d2 -3.4e+96)
(* d1 d2)
(if (<= d2 -3.6e-6)
t_0
(if (<= d2 -4.6e-152)
(* d1 (- d3))
(if (<= d2 1.1e-249) t_0 (* d1 d4)))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d2 <= -3.4e+96) {
tmp = d1 * d2;
} else if (d2 <= -3.6e-6) {
tmp = t_0;
} else if (d2 <= -4.6e-152) {
tmp = d1 * -d3;
} else if (d2 <= 1.1e-249) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * -d1
if (d2 <= (-3.4d+96)) then
tmp = d1 * d2
else if (d2 <= (-3.6d-6)) then
tmp = t_0
else if (d2 <= (-4.6d-152)) then
tmp = d1 * -d3
else if (d2 <= 1.1d-249) then
tmp = t_0
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 t_0 = d1 * -d1;
double tmp;
if (d2 <= -3.4e+96) {
tmp = d1 * d2;
} else if (d2 <= -3.6e-6) {
tmp = t_0;
} else if (d2 <= -4.6e-152) {
tmp = d1 * -d3;
} else if (d2 <= 1.1e-249) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = d1 * -d1 tmp = 0 if d2 <= -3.4e+96: tmp = d1 * d2 elif d2 <= -3.6e-6: tmp = t_0 elif d2 <= -4.6e-152: tmp = d1 * -d3 elif d2 <= 1.1e-249: tmp = t_0 else: tmp = d1 * d4 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) tmp = 0.0 if (d2 <= -3.4e+96) tmp = Float64(d1 * d2); elseif (d2 <= -3.6e-6) tmp = t_0; elseif (d2 <= -4.6e-152) tmp = Float64(d1 * Float64(-d3)); elseif (d2 <= 1.1e-249) tmp = t_0; 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)
t_0 = d1 * -d1;
tmp = 0.0;
if (d2 <= -3.4e+96)
tmp = d1 * d2;
elseif (d2 <= -3.6e-6)
tmp = t_0;
elseif (d2 <= -4.6e-152)
tmp = d1 * -d3;
elseif (d2 <= 1.1e-249)
tmp = t_0;
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_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, If[LessEqual[d2, -3.4e+96], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -3.6e-6], t$95$0, If[LessEqual[d2, -4.6e-152], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d2, 1.1e-249], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d2 \leq -3.4 \cdot 10^{+96}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d2 \leq -4.6 \cdot 10^{-152}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d2 \leq 1.1 \cdot 10^{-249}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -3.4000000000000001e96Initial program 82.2%
sub-neg82.2%
associate-+l+82.2%
*-commutative82.2%
+-commutative82.2%
*-commutative82.2%
sub-neg82.2%
+-commutative82.2%
associate--l+82.2%
distribute-lft-out--82.2%
distribute-rgt-out--86.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 61.2%
if -3.4000000000000001e96 < d2 < -3.59999999999999984e-6 or -4.6000000000000003e-152 < d2 < 1.1e-249Initial program 89.2%
sub-neg89.2%
associate-+l+89.2%
*-commutative89.2%
+-commutative89.2%
*-commutative89.2%
sub-neg89.2%
+-commutative89.2%
associate--l+89.2%
distribute-lft-out--90.8%
distribute-rgt-out--90.8%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 48.0%
neg-mul-148.0%
Simplified48.0%
if -3.59999999999999984e-6 < d2 < -4.6000000000000003e-152Initial program 85.1%
sub-neg85.1%
associate-+l+85.1%
*-commutative85.1%
+-commutative85.1%
*-commutative85.1%
sub-neg85.1%
+-commutative85.1%
associate--l+85.1%
distribute-lft-out--85.1%
distribute-rgt-out--85.1%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d3 around inf 48.0%
mul-1-neg48.0%
distribute-rgt-neg-out48.0%
Simplified48.0%
if 1.1e-249 < d2 Initial program 91.6%
sub-neg91.6%
associate-+l+91.6%
*-commutative91.6%
+-commutative91.6%
*-commutative91.6%
sub-neg91.6%
+-commutative91.6%
associate--l+91.6%
distribute-lft-out--92.4%
distribute-rgt-out--94.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 28.3%
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 -2.8e+95)
(* d1 (- d2 d3))
(if (<= d2 -4.6e-5)
(* d1 (- d2 d1))
(if (<= d2 -4.2e-152) (* d1 (- d4 d3)) (* d1 (- d4 d1))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.8e+95) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -4.6e-5) {
tmp = d1 * (d2 - d1);
} else if (d2 <= -4.2e-152) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - 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 <= (-2.8d+95)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-4.6d-5)) then
tmp = d1 * (d2 - d1)
else if (d2 <= (-4.2d-152)) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * (d4 - 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 <= -2.8e+95) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -4.6e-5) {
tmp = d1 * (d2 - d1);
} else if (d2 <= -4.2e-152) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.8e+95: tmp = d1 * (d2 - d3) elif d2 <= -4.6e-5: tmp = d1 * (d2 - d1) elif d2 <= -4.2e-152: tmp = d1 * (d4 - d3) else: tmp = d1 * (d4 - d1) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.8e+95) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -4.6e-5) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d2 <= -4.2e-152) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(d4 - 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 <= -2.8e+95)
tmp = d1 * (d2 - d3);
elseif (d2 <= -4.6e-5)
tmp = d1 * (d2 - d1);
elseif (d2 <= -4.2e-152)
tmp = d1 * (d4 - d3);
else
tmp = d1 * (d4 - 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, -2.8e+95], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -4.6e-5], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -4.2e-152], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.8 \cdot 10^{+95}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -4.6 \cdot 10^{-5}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d2 \leq -4.2 \cdot 10^{-152}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -2.7999999999999998e95Initial program 82.2%
sub-neg82.2%
associate-+l+82.2%
*-commutative82.2%
+-commutative82.2%
*-commutative82.2%
sub-neg82.2%
+-commutative82.2%
associate--l+82.2%
distribute-lft-out--82.2%
distribute-rgt-out--86.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.1%
associate--l+91.1%
Simplified91.1%
Taylor expanded in d4 around 0 81.8%
if -2.7999999999999998e95 < d2 < -4.6e-5Initial program 90.9%
sub-neg90.9%
associate-+l+90.9%
*-commutative90.9%
+-commutative90.9%
*-commutative90.9%
sub-neg90.9%
+-commutative90.9%
associate--l+90.9%
distribute-lft-out--90.9%
distribute-rgt-out--90.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.1%
Taylor expanded in d4 around 0 56.3%
if -4.6e-5 < d2 < -4.19999999999999998e-152Initial program 85.1%
sub-neg85.1%
associate-+l+85.1%
*-commutative85.1%
+-commutative85.1%
*-commutative85.1%
sub-neg85.1%
+-commutative85.1%
associate--l+85.1%
distribute-lft-out--85.1%
distribute-rgt-out--85.1%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 82.3%
associate--l+82.3%
Simplified82.3%
Taylor expanded in d2 around 0 78.6%
if -4.19999999999999998e-152 < d2 Initial program 90.7%
sub-neg90.7%
associate-+l+90.7%
*-commutative90.7%
+-commutative90.7%
*-commutative90.7%
sub-neg90.7%
+-commutative90.7%
associate--l+90.7%
distribute-lft-out--91.9%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 81.0%
+-commutative81.0%
associate--r+81.0%
Simplified81.0%
Taylor expanded in d3 around 0 59.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 (or (<= d3 -7e+128) (not (<= d3 6.7e+56))) (* d1 (+ d2 (- d4 d3))) (* d1 (- (+ d2 d4) d1))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -7e+128) || !(d3 <= 6.7e+56)) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * ((d2 + d4) - 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 ((d3 <= (-7d+128)) .or. (.not. (d3 <= 6.7d+56))) then
tmp = d1 * (d2 + (d4 - d3))
else
tmp = d1 * ((d2 + d4) - 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 ((d3 <= -7e+128) || !(d3 <= 6.7e+56)) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -7e+128) or not (d3 <= 6.7e+56): tmp = d1 * (d2 + (d4 - d3)) else: tmp = d1 * ((d2 + d4) - d1) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -7e+128) || !(d3 <= 6.7e+56)) tmp = Float64(d1 * Float64(d2 + Float64(d4 - d3))); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - 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 ((d3 <= -7e+128) || ~((d3 <= 6.7e+56)))
tmp = d1 * (d2 + (d4 - d3));
else
tmp = d1 * ((d2 + d4) - 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[Or[LessEqual[d3, -7e+128], N[Not[LessEqual[d3, 6.7e+56]], $MachinePrecision]], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -7 \cdot 10^{+128} \lor \neg \left(d3 \leq 6.7 \cdot 10^{+56}\right):\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -6.99999999999999937e128 or 6.7e56 < d3 Initial program 87.6%
sub-neg87.6%
associate-+l+87.6%
*-commutative87.6%
+-commutative87.6%
*-commutative87.6%
sub-neg87.6%
+-commutative87.6%
associate--l+87.6%
distribute-lft-out--89.9%
distribute-rgt-out--89.9%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 95.6%
associate--l+95.6%
Simplified95.6%
if -6.99999999999999937e128 < d3 < 6.7e56Initial program 89.2%
sub-neg89.2%
associate-+l+89.2%
*-commutative89.2%
+-commutative89.2%
*-commutative89.2%
sub-neg89.2%
+-commutative89.2%
associate--l+89.2%
distribute-lft-out--89.2%
distribute-rgt-out--92.2%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.6%
Final simplification96.9%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -1.8e+122) (* d1 (- (- d4 d3) d1)) (if (<= d3 1.02e+49) (* d1 (- (+ d2 d4) d1)) (* d1 (+ d2 (- d4 d3))))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -1.8e+122) {
tmp = d1 * ((d4 - d3) - d1);
} else if (d3 <= 1.02e+49) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d2 + (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 (d3 <= (-1.8d+122)) then
tmp = d1 * ((d4 - d3) - d1)
else if (d3 <= 1.02d+49) then
tmp = d1 * ((d2 + d4) - d1)
else
tmp = d1 * (d2 + (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 (d3 <= -1.8e+122) {
tmp = d1 * ((d4 - d3) - d1);
} else if (d3 <= 1.02e+49) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d2 + (d4 - d3));
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d3 <= -1.8e+122: tmp = d1 * ((d4 - d3) - d1) elif d3 <= 1.02e+49: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * (d2 + (d4 - d3)) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -1.8e+122) tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1)); elseif (d3 <= 1.02e+49) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); else tmp = Float64(d1 * Float64(d2 + 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 (d3 <= -1.8e+122)
tmp = d1 * ((d4 - d3) - d1);
elseif (d3 <= 1.02e+49)
tmp = d1 * ((d2 + d4) - d1);
else
tmp = d1 * (d2 + (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[d3, -1.8e+122], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.02e+49], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.8 \cdot 10^{+122}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\mathbf{elif}\;d3 \leq 1.02 \cdot 10^{+49}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\end{array}
\end{array}
if d3 < -1.8000000000000001e122Initial 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--89.2%
distribute-rgt-out--89.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 93.3%
+-commutative93.3%
associate--r+93.3%
Simplified93.3%
if -1.8000000000000001e122 < d3 < 1.02e49Initial program 89.0%
sub-neg89.0%
associate-+l+89.0%
*-commutative89.0%
+-commutative89.0%
*-commutative89.0%
sub-neg89.0%
+-commutative89.0%
associate--l+89.0%
distribute-lft-out--89.0%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.9%
if 1.02e49 < d3 Initial program 89.0%
sub-neg89.0%
associate-+l+89.0%
*-commutative89.0%
+-commutative89.0%
*-commutative89.0%
sub-neg89.0%
+-commutative89.0%
associate--l+89.0%
distribute-lft-out--90.6%
distribute-rgt-out--90.6%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 95.4%
associate--l+95.4%
Simplified95.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 (<= d1 -1.56e+125) (* d1 (- d2 d1)) (if (<= d1 6.5e+113) (* d1 (+ d2 (- d4 d3))) (* d1 (- d4 d1)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.56e+125) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 6.5e+113) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - 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 (d1 <= (-1.56d+125)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 6.5d+113) then
tmp = d1 * (d2 + (d4 - d3))
else
tmp = d1 * (d4 - 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 (d1 <= -1.56e+125) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 6.5e+113) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.56e+125: tmp = d1 * (d2 - d1) elif d1 <= 6.5e+113: tmp = d1 * (d2 + (d4 - d3)) else: tmp = d1 * (d4 - d1) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.56e+125) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 6.5e+113) tmp = Float64(d1 * Float64(d2 + Float64(d4 - d3))); else tmp = Float64(d1 * Float64(d4 - 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 (d1 <= -1.56e+125)
tmp = d1 * (d2 - d1);
elseif (d1 <= 6.5e+113)
tmp = d1 * (d2 + (d4 - d3));
else
tmp = d1 * (d4 - 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[d1, -1.56e+125], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 6.5e+113], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.56 \cdot 10^{+125}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 6.5 \cdot 10^{+113}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -1.56e125Initial program 59.3%
sub-neg59.3%
associate-+l+59.3%
*-commutative59.3%
+-commutative59.3%
*-commutative59.3%
sub-neg59.3%
+-commutative59.3%
associate--l+59.3%
distribute-lft-out--59.3%
distribute-rgt-out--66.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.3%
Taylor expanded in d4 around 0 75.8%
if -1.56e125 < d1 < 6.5000000000000001e113Initial program 99.4%
sub-neg99.4%
associate-+l+99.4%
*-commutative99.4%
+-commutative99.4%
*-commutative99.4%
sub-neg99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 89.6%
associate--l+89.6%
Simplified89.6%
if 6.5000000000000001e113 < d1 Initial program 61.3%
sub-neg61.3%
associate-+l+61.3%
*-commutative61.3%
+-commutative61.3%
*-commutative61.3%
sub-neg61.3%
+-commutative61.3%
associate--l+61.3%
distribute-lft-out--63.6%
distribute-rgt-out--70.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 91.1%
+-commutative91.1%
associate--r+91.1%
Simplified91.1%
Taylor expanded in d3 around 0 88.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 -1.45e+99) (* d1 (- d2 d3)) (if (<= d2 -1.65e-282) (* d1 (- (- d3) d1)) (* d1 (- d4 d1)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.45e+99) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.65e-282) {
tmp = d1 * (-d3 - d1);
} else {
tmp = d1 * (d4 - 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.45d+99)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-1.65d-282)) then
tmp = d1 * (-d3 - d1)
else
tmp = d1 * (d4 - 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.45e+99) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.65e-282) {
tmp = d1 * (-d3 - d1);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.45e+99: tmp = d1 * (d2 - d3) elif d2 <= -1.65e-282: tmp = d1 * (-d3 - d1) else: tmp = d1 * (d4 - d1) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.45e+99) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -1.65e-282) tmp = Float64(d1 * Float64(Float64(-d3) - d1)); else tmp = Float64(d1 * Float64(d4 - 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.45e+99)
tmp = d1 * (d2 - d3);
elseif (d2 <= -1.65e-282)
tmp = d1 * (-d3 - d1);
else
tmp = d1 * (d4 - 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.45e+99], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -1.65e-282], N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.45 \cdot 10^{+99}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -1.65 \cdot 10^{-282}:\\
\;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -1.4500000000000001e99Initial program 81.8%
sub-neg81.8%
associate-+l+81.8%
*-commutative81.8%
+-commutative81.8%
*-commutative81.8%
sub-neg81.8%
+-commutative81.8%
associate--l+81.8%
distribute-lft-out--81.8%
distribute-rgt-out--86.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.9%
associate--l+90.9%
Simplified90.9%
Taylor expanded in d4 around 0 81.4%
if -1.4500000000000001e99 < d2 < -1.65e-282Initial program 89.3%
sub-neg89.3%
associate-+l+89.3%
*-commutative89.3%
+-commutative89.3%
*-commutative89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
distribute-lft-out--90.6%
distribute-rgt-out--90.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 94.7%
+-commutative94.7%
associate--r+94.7%
Simplified94.7%
Taylor expanded in d4 around 0 64.9%
associate-*r*64.9%
mul-1-neg64.9%
Simplified64.9%
if -1.65e-282 < d2 Initial 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--91.2%
distribute-rgt-out--93.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 77.6%
+-commutative77.6%
associate--r+77.6%
Simplified77.6%
Taylor expanded in d3 around 0 56.4%
Final simplification63.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 -1.1e+140) (not (<= d3 8.2e+149))) (* 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 <= -1.1e+140) || !(d3 <= 8.2e+149)) {
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 <= (-1.1d+140)) .or. (.not. (d3 <= 8.2d+149))) 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 <= -1.1e+140) || !(d3 <= 8.2e+149)) {
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 <= -1.1e+140) or not (d3 <= 8.2e+149): 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 <= -1.1e+140) || !(d3 <= 8.2e+149)) 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 <= -1.1e+140) || ~((d3 <= 8.2e+149)))
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, -1.1e+140], N[Not[LessEqual[d3, 8.2e+149]], $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 -1.1 \cdot 10^{+140} \lor \neg \left(d3 \leq 8.2 \cdot 10^{+149}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -1.0999999999999999e140 or 8.1999999999999992e149 < d3 Initial program 86.5%
sub-neg86.5%
associate-+l+86.5%
*-commutative86.5%
+-commutative86.5%
*-commutative86.5%
sub-neg86.5%
+-commutative86.5%
associate--l+86.5%
distribute-lft-out--89.5%
distribute-rgt-out--89.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around inf 82.1%
mul-1-neg82.1%
distribute-rgt-neg-out82.1%
Simplified82.1%
if -1.0999999999999999e140 < d3 < 8.1999999999999992e149Initial program 89.4%
sub-neg89.4%
associate-+l+89.4%
*-commutative89.4%
+-commutative89.4%
*-commutative89.4%
sub-neg89.4%
+-commutative89.4%
associate--l+89.4%
distribute-lft-out--89.4%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 71.2%
associate--l+71.2%
Simplified71.2%
Taylor expanded in d3 around 0 64.4%
Final simplification69.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 (<= d4 2.1e-185) (* d1 d2) (if (<= d4 2.5e+45) (* d1 (- d1)) (* d1 d4))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.1e-185) {
tmp = d1 * d2;
} else if (d4 <= 2.5e+45) {
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 (d4 <= 2.1d-185) then
tmp = d1 * d2
else if (d4 <= 2.5d+45) 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 (d4 <= 2.1e-185) {
tmp = d1 * d2;
} else if (d4 <= 2.5e+45) {
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 d4 <= 2.1e-185: tmp = d1 * d2 elif d4 <= 2.5e+45: 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 (d4 <= 2.1e-185) tmp = Float64(d1 * d2); elseif (d4 <= 2.5e+45) 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 (d4 <= 2.1e-185)
tmp = d1 * d2;
elseif (d4 <= 2.5e+45)
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[d4, 2.1e-185], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.5e+45], 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}\;d4 \leq 2.1 \cdot 10^{-185}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.5 \cdot 10^{+45}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.1e-185Initial program 89.0%
sub-neg89.0%
associate-+l+89.0%
*-commutative89.0%
+-commutative89.0%
*-commutative89.0%
sub-neg89.0%
+-commutative89.0%
associate--l+89.0%
distribute-lft-out--89.7%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.2%
if 2.1e-185 < d4 < 2.5e45Initial program 95.9%
sub-neg95.9%
associate-+l+95.9%
*-commutative95.9%
+-commutative95.9%
*-commutative95.9%
sub-neg95.9%
+-commutative95.9%
associate--l+95.9%
distribute-lft-out--95.9%
distribute-rgt-out--97.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 52.2%
neg-mul-152.2%
Simplified52.2%
if 2.5e45 < d4 Initial program 81.9%
sub-neg81.9%
associate-+l+81.9%
*-commutative81.9%
+-commutative81.9%
*-commutative81.9%
sub-neg81.9%
+-commutative81.9%
associate--l+81.9%
distribute-lft-out--83.6%
distribute-rgt-out--85.2%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 49.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 -4.3e+71) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.3e+71) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - 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 <= (-4.3d+71)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - 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 <= -4.3e+71) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.3e+71: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.3e+71) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - 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 <= -4.3e+71)
tmp = d1 * (d2 - d3);
else
tmp = d1 * (d4 - 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, -4.3e+71], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4.3 \cdot 10^{+71}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -4.29999999999999984e71Initial program 83.9%
sub-neg83.9%
associate-+l+83.9%
*-commutative83.9%
+-commutative83.9%
*-commutative83.9%
sub-neg83.9%
+-commutative83.9%
associate--l+83.9%
distribute-lft-out--83.9%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 87.7%
associate--l+87.7%
Simplified87.7%
Taylor expanded in d4 around 0 73.4%
if -4.29999999999999984e71 < d2 Initial program 90.0%
sub-neg90.0%
associate-+l+90.0%
*-commutative90.0%
+-commutative90.0%
*-commutative90.0%
sub-neg90.0%
+-commutative90.0%
associate--l+90.0%
distribute-lft-out--91.0%
distribute-rgt-out--92.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.2%
+-commutative83.2%
associate--r+83.2%
Simplified83.2%
Taylor expanded in d3 around 0 59.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 -4.5e+43) (* 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 <= -4.5e+43) {
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 <= (-4.5d+43)) 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 <= -4.5e+43) {
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 <= -4.5e+43: 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 <= -4.5e+43) 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 <= -4.5e+43)
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, -4.5e+43], 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 -4.5 \cdot 10^{+43}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -4.5e43Initial program 85.0%
sub-neg85.0%
associate-+l+85.0%
*-commutative85.0%
+-commutative85.0%
*-commutative85.0%
sub-neg85.0%
+-commutative85.0%
associate--l+85.0%
distribute-lft-out--85.0%
distribute-rgt-out--88.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 53.6%
if -4.5e43 < d2 Initial program 89.8%
sub-neg89.8%
associate-+l+89.8%
*-commutative89.8%
+-commutative89.8%
*-commutative89.8%
sub-neg89.8%
+-commutative89.8%
associate--l+89.8%
distribute-lft-out--90.8%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 32.2%
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 88.6%
sub-neg88.6%
associate-+l+88.6%
*-commutative88.6%
+-commutative88.6%
*-commutative88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
distribute-lft-out--89.4%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 29.5%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
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 * d1
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): return d1 * d1
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return Float64(d1 * d1) end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * d1;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
d1 \cdot d1
\end{array}
Initial program 88.6%
sub-neg88.6%
associate-+l+88.6%
*-commutative88.6%
+-commutative88.6%
*-commutative88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
distribute-lft-out--89.4%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 32.4%
neg-mul-132.4%
Simplified32.4%
neg-sub032.4%
sub-neg32.4%
add-sqr-sqrt11.9%
sqrt-unprod15.8%
sqr-neg15.8%
sqrt-unprod3.9%
add-sqr-sqrt7.1%
Applied egg-rr7.1%
+-lft-identity7.1%
Simplified7.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 2024181
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))