
(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 d3) (- d4 d1))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - 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 * ((d2 - d3) + (d4 - d1))
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): return d1 * ((d2 - d3) + (d4 - d1))
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1))) end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * ((d2 - d3) + (d4 - 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 * N[(N[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 84.7%
associate--l+84.7%
distribute-lft-out--86.7%
distribute-rgt-out--90.2%
distribute-lft-out100.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 d1))) (t_1 (* d1 (- (- d3) d1))))
(if (<= d4 -2.8e-237)
t_0
(if (<= d4 1.35e-196)
t_1
(if (<= d4 1.35e-151)
t_0
(if (<= d4 1.3e+47)
t_1
(if (<= d4 8.8e+104) (* d1 (- d4 d1)) (* d1 (- d4 d3)))))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (-d3 - d1);
double tmp;
if (d4 <= -2.8e-237) {
tmp = t_0;
} else if (d4 <= 1.35e-196) {
tmp = t_1;
} else if (d4 <= 1.35e-151) {
tmp = t_0;
} else if (d4 <= 1.3e+47) {
tmp = t_1;
} else if (d4 <= 8.8e+104) {
tmp = d1 * (d4 - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d1 * (d2 - d1)
t_1 = d1 * (-d3 - d1)
if (d4 <= (-2.8d-237)) then
tmp = t_0
else if (d4 <= 1.35d-196) then
tmp = t_1
else if (d4 <= 1.35d-151) then
tmp = t_0
else if (d4 <= 1.3d+47) then
tmp = t_1
else if (d4 <= 8.8d+104) then
tmp = d1 * (d4 - 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 t_0 = d1 * (d2 - d1);
double t_1 = d1 * (-d3 - d1);
double tmp;
if (d4 <= -2.8e-237) {
tmp = t_0;
} else if (d4 <= 1.35e-196) {
tmp = t_1;
} else if (d4 <= 1.35e-151) {
tmp = t_0;
} else if (d4 <= 1.3e+47) {
tmp = t_1;
} else if (d4 <= 8.8e+104) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (-d3 - d1) tmp = 0 if d4 <= -2.8e-237: tmp = t_0 elif d4 <= 1.35e-196: tmp = t_1 elif d4 <= 1.35e-151: tmp = t_0 elif d4 <= 1.3e+47: tmp = t_1 elif d4 <= 8.8e+104: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(Float64(-d3) - d1)) tmp = 0.0 if (d4 <= -2.8e-237) tmp = t_0; elseif (d4 <= 1.35e-196) tmp = t_1; elseif (d4 <= 1.35e-151) tmp = t_0; elseif (d4 <= 1.3e+47) tmp = t_1; elseif (d4 <= 8.8e+104) tmp = Float64(d1 * Float64(d4 - 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)
t_0 = d1 * (d2 - d1);
t_1 = d1 * (-d3 - d1);
tmp = 0.0;
if (d4 <= -2.8e-237)
tmp = t_0;
elseif (d4 <= 1.35e-196)
tmp = t_1;
elseif (d4 <= 1.35e-151)
tmp = t_0;
elseif (d4 <= 1.3e+47)
tmp = t_1;
elseif (d4 <= 8.8e+104)
tmp = d1 * (d4 - 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_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -2.8e-237], t$95$0, If[LessEqual[d4, 1.35e-196], t$95$1, If[LessEqual[d4, 1.35e-151], t$95$0, If[LessEqual[d4, 1.3e+47], t$95$1, If[LessEqual[d4, 8.8e+104], N[(d1 * N[(d4 - 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}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(\left(-d3\right) - d1\right)\\
\mathbf{if}\;d4 \leq -2.8 \cdot 10^{-237}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.35 \cdot 10^{-196}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 1.35 \cdot 10^{-151}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.3 \cdot 10^{+47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 8.8 \cdot 10^{+104}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -2.79999999999999997e-237 or 1.34999999999999991e-196 < d4 < 1.35000000000000004e-151Initial program 83.8%
associate--l+83.8%
distribute-lft-out--86.3%
distribute-rgt-out--88.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.8%
Taylor expanded in d4 around 0 57.2%
if -2.79999999999999997e-237 < d4 < 1.34999999999999991e-196 or 1.35000000000000004e-151 < d4 < 1.30000000000000002e47Initial program 86.0%
associate--l+86.0%
distribute-lft-out--88.6%
distribute-rgt-out--88.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 77.0%
associate--r+77.0%
Simplified77.0%
Taylor expanded in d4 around 0 75.6%
associate-*r*75.6%
mul-1-neg75.6%
Simplified75.6%
if 1.30000000000000002e47 < d4 < 8.80000000000000002e104Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.0%
Taylor expanded in d2 around 0 62.0%
if 8.80000000000000002e104 < d4 Initial program 80.4%
associate--l+80.4%
distribute-lft-out--80.4%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 87.0%
associate--r+87.0%
Simplified87.0%
Taylor expanded in d1 around 0 87.0%
Final simplification67.9%
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 d3))) (t_1 (* d1 (- d4 d1))))
(if (<= d3 -820000.0)
t_0
(if (<= d3 1.6e-272)
t_1
(if (<= d3 5.5e+78) (* d1 (+ d2 d4)) (if (<= d3 1.1e+199) t_1 t_0))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double t_1 = d1 * (d4 - d1);
double tmp;
if (d3 <= -820000.0) {
tmp = t_0;
} else if (d3 <= 1.6e-272) {
tmp = t_1;
} else if (d3 <= 5.5e+78) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 1.1e+199) {
tmp = t_1;
} else {
tmp = t_0;
}
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) :: tmp
t_0 = d1 * (d2 - d3)
t_1 = d1 * (d4 - d1)
if (d3 <= (-820000.0d0)) then
tmp = t_0
else if (d3 <= 1.6d-272) then
tmp = t_1
else if (d3 <= 5.5d+78) then
tmp = d1 * (d2 + d4)
else if (d3 <= 1.1d+199) then
tmp = t_1
else
tmp = t_0
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 - d3);
double t_1 = d1 * (d4 - d1);
double tmp;
if (d3 <= -820000.0) {
tmp = t_0;
} else if (d3 <= 1.6e-272) {
tmp = t_1;
} else if (d3 <= 5.5e+78) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 1.1e+199) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) t_1 = d1 * (d4 - d1) tmp = 0 if d3 <= -820000.0: tmp = t_0 elif d3 <= 1.6e-272: tmp = t_1 elif d3 <= 5.5e+78: tmp = d1 * (d2 + d4) elif d3 <= 1.1e+199: tmp = t_1 else: tmp = t_0 return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) t_1 = Float64(d1 * Float64(d4 - d1)) tmp = 0.0 if (d3 <= -820000.0) tmp = t_0; elseif (d3 <= 1.6e-272) tmp = t_1; elseif (d3 <= 5.5e+78) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d3 <= 1.1e+199) tmp = t_1; else tmp = t_0; 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 - d3);
t_1 = d1 * (d4 - d1);
tmp = 0.0;
if (d3 <= -820000.0)
tmp = t_0;
elseif (d3 <= 1.6e-272)
tmp = t_1;
elseif (d3 <= 5.5e+78)
tmp = d1 * (d2 + d4);
elseif (d3 <= 1.1e+199)
tmp = t_1;
else
tmp = t_0;
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 - d3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -820000.0], t$95$0, If[LessEqual[d3, 1.6e-272], t$95$1, If[LessEqual[d3, 5.5e+78], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.1e+199], t$95$1, t$95$0]]]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
t_1 := d1 \cdot \left(d4 - d1\right)\\
\mathbf{if}\;d3 \leq -820000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 1.6 \cdot 10^{-272}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq 5.5 \cdot 10^{+78}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq 1.1 \cdot 10^{+199}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -8.2e5 or 1.1000000000000001e199 < d3 Initial program 83.1%
associate--l+83.1%
distribute-lft-out--86.7%
distribute-rgt-out--87.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.9%
Taylor expanded in d4 around 0 81.9%
if -8.2e5 < d3 < 1.6e-272 or 5.4999999999999997e78 < d3 < 1.1000000000000001e199Initial program 82.5%
associate--l+82.5%
distribute-lft-out--83.5%
distribute-rgt-out--86.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 90.9%
Taylor expanded in d2 around 0 66.4%
if 1.6e-272 < d3 < 5.4999999999999997e78Initial program 90.0%
associate--l+90.0%
distribute-lft-out--91.4%
distribute-rgt-out--98.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.9%
Taylor expanded in d1 around 0 74.3%
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 (- d3))))
(if (<= d4 -5.2e-264)
(* d1 d2)
(if (<= d4 4.5e-196)
t_0
(if (<= d4 1.12e-148)
(* d1 (- d1))
(if (<= d4 1.85e+47) 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 * -d3;
double tmp;
if (d4 <= -5.2e-264) {
tmp = d1 * d2;
} else if (d4 <= 4.5e-196) {
tmp = t_0;
} else if (d4 <= 1.12e-148) {
tmp = d1 * -d1;
} else if (d4 <= 1.85e+47) {
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 * -d3
if (d4 <= (-5.2d-264)) then
tmp = d1 * d2
else if (d4 <= 4.5d-196) then
tmp = t_0
else if (d4 <= 1.12d-148) then
tmp = d1 * -d1
else if (d4 <= 1.85d+47) 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 * -d3;
double tmp;
if (d4 <= -5.2e-264) {
tmp = d1 * d2;
} else if (d4 <= 4.5e-196) {
tmp = t_0;
} else if (d4 <= 1.12e-148) {
tmp = d1 * -d1;
} else if (d4 <= 1.85e+47) {
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 * -d3 tmp = 0 if d4 <= -5.2e-264: tmp = d1 * d2 elif d4 <= 4.5e-196: tmp = t_0 elif d4 <= 1.12e-148: tmp = d1 * -d1 elif d4 <= 1.85e+47: 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(-d3)) tmp = 0.0 if (d4 <= -5.2e-264) tmp = Float64(d1 * d2); elseif (d4 <= 4.5e-196) tmp = t_0; elseif (d4 <= 1.12e-148) tmp = Float64(d1 * Float64(-d1)); elseif (d4 <= 1.85e+47) 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 * -d3;
tmp = 0.0;
if (d4 <= -5.2e-264)
tmp = d1 * d2;
elseif (d4 <= 4.5e-196)
tmp = t_0;
elseif (d4 <= 1.12e-148)
tmp = d1 * -d1;
elseif (d4 <= 1.85e+47)
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 * (-d3)), $MachinePrecision]}, If[LessEqual[d4, -5.2e-264], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.5e-196], t$95$0, If[LessEqual[d4, 1.12e-148], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d4, 1.85e+47], 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(-d3\right)\\
\mathbf{if}\;d4 \leq -5.2 \cdot 10^{-264}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.5 \cdot 10^{-196}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.12 \cdot 10^{-148}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 1.85 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -5.2000000000000004e-264Initial program 83.2%
associate--l+83.2%
distribute-lft-out--85.7%
distribute-rgt-out--88.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 37.7%
if -5.2000000000000004e-264 < d4 < 4.5e-196 or 1.1199999999999999e-148 < d4 < 1.8500000000000002e47Initial program 85.1%
associate--l+85.1%
distribute-lft-out--87.8%
distribute-rgt-out--87.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 47.1%
mul-1-neg47.1%
distribute-rgt-neg-out47.1%
Simplified47.1%
if 4.5e-196 < d4 < 1.1199999999999999e-148Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 62.4%
neg-mul-162.4%
Simplified62.4%
if 1.8500000000000002e47 < d4 Initial program 84.8%
associate--l+84.8%
distribute-lft-out--84.8%
distribute-rgt-out--96.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 61.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 d1))))
(if (<= d4 6.8e-124)
t_0
(if (<= d4 1.75e-100)
(* d1 (- d3))
(if (<= d4 4.9e+104) t_0 (* d1 (+ d2 d4)))))))assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= 6.8e-124) {
tmp = t_0;
} else if (d4 <= 1.75e-100) {
tmp = d1 * -d3;
} else if (d4 <= 4.9e+104) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d4 <= 6.8d-124) then
tmp = t_0
else if (d4 <= 1.75d-100) then
tmp = d1 * -d3
else if (d4 <= 4.9d+104) then
tmp = t_0
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 t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= 6.8e-124) {
tmp = t_0;
} else if (d4 <= 1.75e-100) {
tmp = d1 * -d3;
} else if (d4 <= 4.9e+104) {
tmp = t_0;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d4 <= 6.8e-124: tmp = t_0 elif d4 <= 1.75e-100: tmp = d1 * -d3 elif d4 <= 4.9e+104: tmp = t_0 else: tmp = d1 * (d2 + d4) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d4 <= 6.8e-124) tmp = t_0; elseif (d4 <= 1.75e-100) tmp = Float64(d1 * Float64(-d3)); elseif (d4 <= 4.9e+104) tmp = t_0; 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)
t_0 = d1 * (d2 - d1);
tmp = 0.0;
if (d4 <= 6.8e-124)
tmp = t_0;
elseif (d4 <= 1.75e-100)
tmp = d1 * -d3;
elseif (d4 <= 4.9e+104)
tmp = t_0;
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_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 6.8e-124], t$95$0, If[LessEqual[d4, 1.75e-100], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d4, 4.9e+104], t$95$0, N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d4 \leq 6.8 \cdot 10^{-124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.75 \cdot 10^{-100}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d4 \leq 4.9 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 6.8000000000000001e-124 or 1.75e-100 < d4 < 4.89999999999999985e104Initial program 85.0%
associate--l+85.0%
distribute-lft-out--87.4%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.2%
Taylor expanded in d4 around 0 60.4%
if 6.8000000000000001e-124 < d4 < 1.75e-100Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 63.7%
mul-1-neg63.7%
distribute-rgt-neg-out63.7%
Simplified63.7%
if 4.89999999999999985e104 < d4 Initial program 80.4%
associate--l+80.4%
distribute-lft-out--80.4%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.3%
Taylor expanded in d1 around 0 78.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 (or (<= d3 -1500000000.0) (not (<= d3 10500.0))) (* 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 <= -1500000000.0) || !(d3 <= 10500.0)) {
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 <= (-1500000000.0d0)) .or. (.not. (d3 <= 10500.0d0))) 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 <= -1500000000.0) || !(d3 <= 10500.0)) {
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 <= -1500000000.0) or not (d3 <= 10500.0): 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 <= -1500000000.0) || !(d3 <= 10500.0)) tmp = Float64(d1 * Float64(Float64(d2 + 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 <= -1500000000.0) || ~((d3 <= 10500.0)))
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, -1500000000.0], N[Not[LessEqual[d3, 10500.0]], $MachinePrecision]], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $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 -1500000000 \lor \neg \left(d3 \leq 10500\right):\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -1.5e9 or 10500 < d3 Initial program 80.3%
associate--l+80.3%
distribute-lft-out--84.0%
distribute-rgt-out--87.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 90.9%
if -1.5e9 < d3 < 10500Initial program 89.5%
associate--l+89.5%
distribute-lft-out--89.5%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.7%
Final simplification94.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 (<= d3 -1.9e+103) (* d1 (- d2 d3)) (if (<= d3 5e+161) (* d1 (- (+ d2 d4) d1)) (* d1 (- d4 d3)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -1.9e+103) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 5e+161) {
tmp = d1 * ((d2 + d4) - 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 (d3 <= (-1.9d+103)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 5d+161) then
tmp = d1 * ((d2 + d4) - 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 (d3 <= -1.9e+103) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 5e+161) {
tmp = d1 * ((d2 + d4) - 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 d3 <= -1.9e+103: tmp = d1 * (d2 - d3) elif d3 <= 5e+161: tmp = d1 * ((d2 + d4) - 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 (d3 <= -1.9e+103) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 5e+161) tmp = Float64(d1 * Float64(Float64(d2 + d4) - 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 (d3 <= -1.9e+103)
tmp = d1 * (d2 - d3);
elseif (d3 <= 5e+161)
tmp = d1 * ((d2 + d4) - 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[d3, -1.9e+103], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 5e+161], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - 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}\;d3 \leq -1.9 \cdot 10^{+103}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 5 \cdot 10^{+161}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -1.8999999999999998e103Initial program 81.4%
associate--l+81.4%
distribute-lft-out--86.0%
distribute-rgt-out--88.3%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 93.0%
Taylor expanded in d4 around 0 84.0%
if -1.8999999999999998e103 < d3 < 4.9999999999999997e161Initial program 86.0%
associate--l+86.0%
distribute-lft-out--87.6%
distribute-rgt-out--91.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 90.4%
if 4.9999999999999997e161 < d3 Initial program 81.5%
associate--l+81.5%
distribute-lft-out--81.5%
distribute-rgt-out--81.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 89.4%
associate--r+89.4%
Simplified89.4%
Taylor expanded in d1 around 0 89.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 (<= d3 -1.18e+170) (not (<= d3 3.6e+126))) (* 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.18e+170) || !(d3 <= 3.6e+126)) {
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.18d+170)) .or. (.not. (d3 <= 3.6d+126))) 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.18e+170) || !(d3 <= 3.6e+126)) {
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.18e+170) or not (d3 <= 3.6e+126): 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.18e+170) || !(d3 <= 3.6e+126)) 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.18e+170) || ~((d3 <= 3.6e+126)))
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.18e+170], N[Not[LessEqual[d3, 3.6e+126]], $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.18 \cdot 10^{+170} \lor \neg \left(d3 \leq 3.6 \cdot 10^{+126}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -1.18e170 or 3.6e126 < d3 Initial program 80.6%
associate--l+80.6%
distribute-lft-out--83.6%
distribute-rgt-out--85.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 76.6%
mul-1-neg76.6%
distribute-rgt-neg-out76.6%
Simplified76.6%
if -1.18e170 < d3 < 3.6e126Initial program 86.2%
associate--l+86.2%
distribute-lft-out--87.8%
distribute-rgt-out--92.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.0%
Taylor expanded in d1 around 0 66.0%
Final simplification68.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 (<= d4 1.45e+37) (* d1 (- d2 d3)) (if (<= d4 7.2e+106) (* d1 (- d4 d1)) (* d1 (- d4 d3)))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.45e+37) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 7.2e+106) {
tmp = d1 * (d4 - 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 (d4 <= 1.45d+37) then
tmp = d1 * (d2 - d3)
else if (d4 <= 7.2d+106) then
tmp = d1 * (d4 - 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 (d4 <= 1.45e+37) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 7.2e+106) {
tmp = d1 * (d4 - 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 d4 <= 1.45e+37: tmp = d1 * (d2 - d3) elif d4 <= 7.2e+106: tmp = d1 * (d4 - 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 (d4 <= 1.45e+37) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 7.2e+106) tmp = Float64(d1 * Float64(d4 - 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 (d4 <= 1.45e+37)
tmp = d1 * (d2 - d3);
elseif (d4 <= 7.2e+106)
tmp = d1 * (d4 - 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[d4, 1.45e+37], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 7.2e+106], N[(d1 * N[(d4 - 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}\;d4 \leq 1.45 \cdot 10^{+37}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 7.2 \cdot 10^{+106}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.44999999999999989e37Initial program 84.8%
associate--l+84.8%
distribute-lft-out--87.3%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.2%
Taylor expanded in d4 around 0 63.2%
if 1.44999999999999989e37 < d4 < 7.2000000000000002e106Initial program 94.0%
associate--l+94.0%
distribute-lft-out--94.0%
distribute-rgt-out--94.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 84.1%
Taylor expanded in d2 around 0 61.5%
if 7.2000000000000002e106 < d4 Initial program 80.4%
associate--l+80.4%
distribute-lft-out--80.4%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 87.0%
associate--r+87.0%
Simplified87.0%
Taylor expanded in d1 around 0 87.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 -4.7e-256) (* d1 d2) (if (<= d4 3.5e+104) (* 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 <= -4.7e-256) {
tmp = d1 * d2;
} else if (d4 <= 3.5e+104) {
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 <= (-4.7d-256)) then
tmp = d1 * d2
else if (d4 <= 3.5d+104) 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 <= -4.7e-256) {
tmp = d1 * d2;
} else if (d4 <= 3.5e+104) {
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 <= -4.7e-256: tmp = d1 * d2 elif d4 <= 3.5e+104: 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 <= -4.7e-256) tmp = Float64(d1 * d2); elseif (d4 <= 3.5e+104) 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 <= -4.7e-256)
tmp = d1 * d2;
elseif (d4 <= 3.5e+104)
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, -4.7e-256], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 3.5e+104], 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 -4.7 \cdot 10^{-256}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 3.5 \cdot 10^{+104}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -4.69999999999999982e-256Initial program 83.0%
associate--l+83.0%
distribute-lft-out--85.6%
distribute-rgt-out--88.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 37.2%
if -4.69999999999999982e-256 < d4 < 3.5000000000000002e104Initial program 88.6%
associate--l+88.6%
distribute-lft-out--90.7%
distribute-rgt-out--90.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 40.6%
neg-mul-140.6%
Simplified40.6%
if 3.5000000000000002e104 < d4 Initial program 80.4%
associate--l+80.4%
distribute-lft-out--80.4%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 66.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 (<= d2 -3.1e+128) (* 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 <= -3.1e+128) {
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 <= (-3.1d+128)) 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 <= -3.1e+128) {
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 <= -3.1e+128: 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 <= -3.1e+128) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); else tmp = Float64(d1 * Float64(Float64(d4 - 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 <= -3.1e+128)
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, -3.1e+128], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.1 \cdot 10^{+128}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d2 < -3.10000000000000004e128Initial program 77.7%
associate--l+77.7%
distribute-lft-out--86.0%
distribute-rgt-out--86.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.4%
if -3.10000000000000004e128 < d2 Initial program 85.9%
associate--l+85.9%
distribute-lft-out--86.8%
distribute-rgt-out--90.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.3%
associate--r+82.3%
Simplified82.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 (<= d4 1.06e+47) (* 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 <= 1.06e+47) {
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 <= 1.06d+47) 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 <= 1.06e+47) {
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 <= 1.06e+47: 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 <= 1.06e+47) 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 <= 1.06e+47)
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[LessEqual[d4, 1.06e+47], 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 1.06 \cdot 10^{+47}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.05999999999999996e47Initial program 84.7%
associate--l+84.7%
distribute-lft-out--87.2%
distribute-rgt-out--88.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 76.8%
Taylor expanded in d4 around 0 62.7%
if 1.05999999999999996e47 < d4 Initial program 84.8%
associate--l+84.8%
distribute-lft-out--84.8%
distribute-rgt-out--96.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 81.9%
Taylor expanded in d1 around 0 77.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 (<= d4 1.65e+32) (* d1 d2) (* d1 d4)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.65e+32) {
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 (d4 <= 1.65d+32) 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 (d4 <= 1.65e+32) {
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 d4 <= 1.65e+32: 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 (d4 <= 1.65e+32) 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 (d4 <= 1.65e+32)
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[d4, 1.65e+32], 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}\;d4 \leq 1.65 \cdot 10^{+32}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.6500000000000001e32Initial program 85.3%
associate--l+85.3%
distribute-lft-out--87.8%
distribute-rgt-out--89.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.9%
if 1.6500000000000001e32 < d4 Initial program 83.0%
associate--l+83.0%
distribute-lft-out--83.0%
distribute-rgt-out--93.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 56.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.15e-263) (* d1 d2) (* d1 d1)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.15e-263) {
tmp = d1 * d2;
} 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.15d-263)) then
tmp = d1 * d2
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.15e-263) {
tmp = d1 * d2;
} 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.15e-263: tmp = d1 * d2 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.15e-263) tmp = Float64(d1 * d2); else tmp = Float64(d1 * 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.15e-263)
tmp = d1 * d2;
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.15e-263], N[(d1 * d2), $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.15 \cdot 10^{-263}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d1\\
\end{array}
\end{array}
if d2 < -1.15000000000000001e-263Initial program 83.4%
associate--l+83.4%
distribute-lft-out--86.2%
distribute-rgt-out--88.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 36.3%
if -1.15000000000000001e-263 < d2 Initial program 85.7%
associate--l+85.7%
distribute-lft-out--87.1%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 28.1%
neg-mul-128.1%
Simplified28.1%
neg-sub028.1%
sub-neg28.1%
add-sqr-sqrt12.9%
sqrt-unprod21.0%
sqr-neg21.0%
sqrt-unprod8.0%
add-sqr-sqrt10.4%
Applied egg-rr10.4%
+-lft-identity10.4%
Simplified10.4%
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 84.7%
associate--l+84.7%
distribute-lft-out--86.7%
distribute-rgt-out--90.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 29.9%
neg-mul-129.9%
Simplified29.9%
neg-sub029.9%
sub-neg29.9%
add-sqr-sqrt13.3%
sqrt-unprod19.1%
sqr-neg19.1%
sqrt-unprod5.8%
add-sqr-sqrt10.3%
Applied egg-rr10.3%
+-lft-identity10.3%
Simplified10.3%
(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 2024110
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))