
(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 11 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 (- (+ d4 (- d2 d3)) d1)))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - 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 * ((d4 + (d2 - d3)) - d1)
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - d1);
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): return d1 * ((d4 + (d2 - d3)) - d1)
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 + Float64(d2 - d3)) - d1)) end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * ((d4 + (d2 - d3)) - 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[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
d1 \cdot \left(\left(d4 + \left(d2 - d3\right)\right) - d1\right)
\end{array}
Initial program 84.7%
+-commutative84.7%
*-commutative84.7%
distribute-lft-out--86.7%
distribute-lft-out88.2%
distribute-lft-out--100.0%
Simplified100.0%
Final simplification100.0%
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- (- d3) d1))))
(if (<= d4 -3.5e-238)
t_0
(if (<= d4 1.7e-198)
t_1
(if (<= d4 4.6e-151)
t_0
(if (<= d4 1.85e+47)
t_1
(if (<= d4 1.02e+107) (* 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 <= -3.5e-238) {
tmp = t_0;
} else if (d4 <= 1.7e-198) {
tmp = t_1;
} else if (d4 <= 4.6e-151) {
tmp = t_0;
} else if (d4 <= 1.85e+47) {
tmp = t_1;
} else if (d4 <= 1.02e+107) {
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 <= (-3.5d-238)) then
tmp = t_0
else if (d4 <= 1.7d-198) then
tmp = t_1
else if (d4 <= 4.6d-151) then
tmp = t_0
else if (d4 <= 1.85d+47) then
tmp = t_1
else if (d4 <= 1.02d+107) 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 <= -3.5e-238) {
tmp = t_0;
} else if (d4 <= 1.7e-198) {
tmp = t_1;
} else if (d4 <= 4.6e-151) {
tmp = t_0;
} else if (d4 <= 1.85e+47) {
tmp = t_1;
} else if (d4 <= 1.02e+107) {
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 <= -3.5e-238: tmp = t_0 elif d4 <= 1.7e-198: tmp = t_1 elif d4 <= 4.6e-151: tmp = t_0 elif d4 <= 1.85e+47: tmp = t_1 elif d4 <= 1.02e+107: 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 <= -3.5e-238) tmp = t_0; elseif (d4 <= 1.7e-198) tmp = t_1; elseif (d4 <= 4.6e-151) tmp = t_0; elseif (d4 <= 1.85e+47) tmp = t_1; elseif (d4 <= 1.02e+107) 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 <= -3.5e-238)
tmp = t_0;
elseif (d4 <= 1.7e-198)
tmp = t_1;
elseif (d4 <= 4.6e-151)
tmp = t_0;
elseif (d4 <= 1.85e+47)
tmp = t_1;
elseif (d4 <= 1.02e+107)
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, -3.5e-238], t$95$0, If[LessEqual[d4, 1.7e-198], t$95$1, If[LessEqual[d4, 4.6e-151], t$95$0, If[LessEqual[d4, 1.85e+47], t$95$1, If[LessEqual[d4, 1.02e+107], 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 -3.5 \cdot 10^{-238}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.7 \cdot 10^{-198}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 4.6 \cdot 10^{-151}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.85 \cdot 10^{+47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 1.02 \cdot 10^{+107}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -3.49999999999999997e-238 or 1.6999999999999999e-198 < d4 < 4.59999999999999992e-151Initial program 84.0%
+-commutative84.0%
*-commutative84.0%
distribute-lft-out--86.4%
distribute-lft-out88.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 57.5%
if -3.49999999999999997e-238 < d4 < 1.6999999999999999e-198 or 4.59999999999999992e-151 < d4 < 1.8500000000000002e47Initial program 85.9%
+-commutative85.9%
*-commutative85.9%
distribute-lft-out--88.4%
distribute-lft-out88.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 75.3%
neg-mul-175.3%
Simplified75.3%
if 1.8500000000000002e47 < d4 < 1.01999999999999994e107Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 62.0%
if 1.01999999999999994e107 < d4 Initial program 80.4%
+-commutative80.4%
*-commutative80.4%
distribute-lft-out--80.4%
distribute-lft-out82.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 100.0%
Taylor expanded in d2 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 -510000.0)
t_0
(if (<= d3 2.1e-271)
t_1
(if (<= d3 2.1e+82) (* d1 (+ d4 d2)) (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 <= -510000.0) {
tmp = t_0;
} else if (d3 <= 2.1e-271) {
tmp = t_1;
} else if (d3 <= 2.1e+82) {
tmp = d1 * (d4 + d2);
} 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 <= (-510000.0d0)) then
tmp = t_0
else if (d3 <= 2.1d-271) then
tmp = t_1
else if (d3 <= 2.1d+82) then
tmp = d1 * (d4 + d2)
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 <= -510000.0) {
tmp = t_0;
} else if (d3 <= 2.1e-271) {
tmp = t_1;
} else if (d3 <= 2.1e+82) {
tmp = d1 * (d4 + d2);
} 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 <= -510000.0: tmp = t_0 elif d3 <= 2.1e-271: tmp = t_1 elif d3 <= 2.1e+82: tmp = d1 * (d4 + d2) 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 <= -510000.0) tmp = t_0; elseif (d3 <= 2.1e-271) tmp = t_1; elseif (d3 <= 2.1e+82) tmp = Float64(d1 * Float64(d4 + d2)); 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 <= -510000.0)
tmp = t_0;
elseif (d3 <= 2.1e-271)
tmp = t_1;
elseif (d3 <= 2.1e+82)
tmp = d1 * (d4 + d2);
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, -510000.0], t$95$0, If[LessEqual[d3, 2.1e-271], t$95$1, If[LessEqual[d3, 2.1e+82], N[(d1 * N[(d4 + d2), $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 -510000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 2.1 \cdot 10^{-271}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq 2.1 \cdot 10^{+82}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\mathbf{elif}\;d3 \leq 1.1 \cdot 10^{+199}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -5.1e5 or 1.1000000000000001e199 < d3 Initial program 83.1%
+-commutative83.1%
*-commutative83.1%
distribute-lft-out--86.7%
distribute-lft-out87.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.9%
Taylor expanded in d4 around 0 81.9%
if -5.1e5 < d3 < 2.1000000000000001e-271 or 2.1e82 < d3 < 1.1000000000000001e199Initial program 82.5%
+-commutative82.5%
*-commutative82.5%
distribute-lft-out--83.5%
distribute-lft-out86.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 66.4%
if 2.1000000000000001e-271 < d3 < 2.1e82Initial program 90.0%
+-commutative90.0%
*-commutative90.0%
distribute-lft-out--91.4%
distribute-lft-out91.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 82.5%
Taylor expanded in d3 around 0 74.3%
Final simplification73.6%
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 -3.1e-262)
(* d1 d2)
(if (<= d4 4.5e-188)
t_0
(if (<= d4 3.3e-149) (* d1 d2) (if (<= d4 1.75e+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 <= -3.1e-262) {
tmp = d1 * d2;
} else if (d4 <= 4.5e-188) {
tmp = t_0;
} else if (d4 <= 3.3e-149) {
tmp = d1 * d2;
} else if (d4 <= 1.75e+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 <= (-3.1d-262)) then
tmp = d1 * d2
else if (d4 <= 4.5d-188) then
tmp = t_0
else if (d4 <= 3.3d-149) then
tmp = d1 * d2
else if (d4 <= 1.75d+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 <= -3.1e-262) {
tmp = d1 * d2;
} else if (d4 <= 4.5e-188) {
tmp = t_0;
} else if (d4 <= 3.3e-149) {
tmp = d1 * d2;
} else if (d4 <= 1.75e+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 <= -3.1e-262: tmp = d1 * d2 elif d4 <= 4.5e-188: tmp = t_0 elif d4 <= 3.3e-149: tmp = d1 * d2 elif d4 <= 1.75e+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 <= -3.1e-262) tmp = Float64(d1 * d2); elseif (d4 <= 4.5e-188) tmp = t_0; elseif (d4 <= 3.3e-149) tmp = Float64(d1 * d2); elseif (d4 <= 1.75e+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 <= -3.1e-262)
tmp = d1 * d2;
elseif (d4 <= 4.5e-188)
tmp = t_0;
elseif (d4 <= 3.3e-149)
tmp = d1 * d2;
elseif (d4 <= 1.75e+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, -3.1e-262], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.5e-188], t$95$0, If[LessEqual[d4, 3.3e-149], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.75e+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 -3.1 \cdot 10^{-262}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.5 \cdot 10^{-188}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 3.3 \cdot 10^{-149}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.75 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -3.0999999999999998e-262 or 4.49999999999999993e-188 < d4 < 3.30000000000000017e-149Initial program 84.4%
+-commutative84.4%
*-commutative84.4%
distribute-lft-out--86.7%
distribute-lft-out89.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 37.7%
if -3.0999999999999998e-262 < d4 < 4.49999999999999993e-188 or 3.30000000000000017e-149 < d4 < 1.75000000000000008e47Initial program 85.3%
+-commutative85.3%
*-commutative85.3%
distribute-lft-out--88.0%
distribute-lft-out88.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 46.5%
mul-1-neg46.5%
distribute-rgt-neg-out46.5%
Simplified46.5%
if 1.75000000000000008e47 < d4 Initial program 84.8%
+-commutative84.8%
*-commutative84.8%
distribute-lft-out--84.8%
distribute-lft-out86.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 61.0%
Final simplification45.1%
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 3.2e-100)
(* d1 (- d3))
(if (<= d4 2.15e+105) t_0 (* d1 (+ d4 d2)))))))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 <= 3.2e-100) {
tmp = d1 * -d3;
} else if (d4 <= 2.15e+105) {
tmp = t_0;
} else {
tmp = d1 * (d4 + d2);
}
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 <= 3.2d-100) then
tmp = d1 * -d3
else if (d4 <= 2.15d+105) then
tmp = t_0
else
tmp = d1 * (d4 + d2)
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 <= 3.2e-100) {
tmp = d1 * -d3;
} else if (d4 <= 2.15e+105) {
tmp = t_0;
} else {
tmp = d1 * (d4 + d2);
}
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 <= 3.2e-100: tmp = d1 * -d3 elif d4 <= 2.15e+105: tmp = t_0 else: tmp = d1 * (d4 + d2) 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 <= 3.2e-100) tmp = Float64(d1 * Float64(-d3)); elseif (d4 <= 2.15e+105) tmp = t_0; else tmp = Float64(d1 * Float64(d4 + d2)); 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 <= 3.2e-100)
tmp = d1 * -d3;
elseif (d4 <= 2.15e+105)
tmp = t_0;
else
tmp = d1 * (d4 + d2);
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, 3.2e-100], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d4, 2.15e+105], t$95$0, N[(d1 * N[(d4 + d2), $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 3.2 \cdot 10^{-100}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d4 \leq 2.15 \cdot 10^{+105}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 6.8000000000000001e-124 or 3.20000000000000017e-100 < d4 < 2.1500000000000001e105Initial program 85.0%
+-commutative85.0%
*-commutative85.0%
distribute-lft-out--87.4%
distribute-lft-out88.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 60.4%
if 6.8000000000000001e-124 < d4 < 3.20000000000000017e-100Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 63.7%
mul-1-neg63.7%
distribute-rgt-neg-out63.7%
Simplified63.7%
if 2.1500000000000001e105 < d4 Initial program 80.4%
+-commutative80.4%
*-commutative80.4%
distribute-lft-out--80.4%
distribute-lft-out82.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 100.0%
Taylor expanded in d3 around 0 78.3%
Final simplification63.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 -2.9e+165) (* d1 (- (- d3) d1)) (if (<= d1 3e+141) (* d1 (- (+ d4 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 (d1 <= -2.9e+165) {
tmp = d1 * (-d3 - d1);
} else if (d1 <= 3e+141) {
tmp = d1 * ((d4 + 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 (d1 <= (-2.9d+165)) then
tmp = d1 * (-d3 - d1)
else if (d1 <= 3d+141) then
tmp = d1 * ((d4 + 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 (d1 <= -2.9e+165) {
tmp = d1 * (-d3 - d1);
} else if (d1 <= 3e+141) {
tmp = d1 * ((d4 + 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 d1 <= -2.9e+165: tmp = d1 * (-d3 - d1) elif d1 <= 3e+141: tmp = d1 * ((d4 + 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 (d1 <= -2.9e+165) tmp = Float64(d1 * Float64(Float64(-d3) - d1)); elseif (d1 <= 3e+141) tmp = Float64(d1 * Float64(Float64(d4 + 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 (d1 <= -2.9e+165)
tmp = d1 * (-d3 - d1);
elseif (d1 <= 3e+141)
tmp = d1 * ((d4 + 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[d1, -2.9e+165], N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 3e+141], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - 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}\;d1 \leq -2.9 \cdot 10^{+165}:\\
\;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\
\mathbf{elif}\;d1 \leq 3 \cdot 10^{+141}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -2.90000000000000006e165Initial program 42.3%
+-commutative42.3%
*-commutative42.3%
distribute-lft-out--46.2%
distribute-lft-out50.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 92.3%
neg-mul-192.3%
Simplified92.3%
if -2.90000000000000006e165 < d1 < 2.9999999999999999e141Initial program 97.8%
+-commutative97.8%
*-commutative97.8%
distribute-lft-out--98.3%
distribute-lft-out99.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.2%
if 2.9999999999999999e141 < d1 Initial program 53.5%
+-commutative53.5%
*-commutative53.5%
distribute-lft-out--60.5%
distribute-lft-out62.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 90.7%
Final simplification91.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.25e+173) (not (<= d3 1.9e+126))) (* d1 (- d3)) (* d1 (+ d4 d2))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.25e+173) || !(d3 <= 1.9e+126)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
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.25d+173)) .or. (.not. (d3 <= 1.9d+126))) then
tmp = d1 * -d3
else
tmp = d1 * (d4 + d2)
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.25e+173) || !(d3 <= 1.9e+126)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.25e+173) or not (d3 <= 1.9e+126): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.25e+173) || !(d3 <= 1.9e+126)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d4 + d2)); 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.25e+173) || ~((d3 <= 1.9e+126)))
tmp = d1 * -d3;
else
tmp = d1 * (d4 + d2);
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.25e+173], N[Not[LessEqual[d3, 1.9e+126]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.25 \cdot 10^{+173} \lor \neg \left(d3 \leq 1.9 \cdot 10^{+126}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -1.25000000000000009e173 or 1.90000000000000008e126 < d3 Initial program 80.6%
+-commutative80.6%
*-commutative80.6%
distribute-lft-out--83.6%
distribute-lft-out85.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 76.6%
mul-1-neg76.6%
distribute-rgt-neg-out76.6%
Simplified76.6%
if -1.25000000000000009e173 < d3 < 1.90000000000000008e126Initial program 86.2%
+-commutative86.2%
*-commutative86.2%
distribute-lft-out--87.8%
distribute-lft-out89.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 76.5%
Taylor expanded in d3 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 6.4e+37) (* d1 (- d2 d3)) (if (<= d4 4.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 <= 6.4e+37) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 4.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 <= 6.4d+37) then
tmp = d1 * (d2 - d3)
else if (d4 <= 4.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 <= 6.4e+37) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 4.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 <= 6.4e+37: tmp = d1 * (d2 - d3) elif d4 <= 4.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 <= 6.4e+37) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 4.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 <= 6.4e+37)
tmp = d1 * (d2 - d3);
elseif (d4 <= 4.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, 6.4e+37], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 4.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 6.4 \cdot 10^{+37}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 4.2 \cdot 10^{+106}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 6.40000000000000027e37Initial program 84.8%
+-commutative84.8%
*-commutative84.8%
distribute-lft-out--87.3%
distribute-lft-out88.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.2%
Taylor expanded in d4 around 0 63.2%
if 6.40000000000000027e37 < d4 < 4.2000000000000001e106Initial program 94.0%
+-commutative94.0%
*-commutative94.0%
distribute-lft-out--94.0%
distribute-lft-out94.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 61.5%
if 4.2000000000000001e106 < d4 Initial program 80.4%
+-commutative80.4%
*-commutative80.4%
distribute-lft-out--80.4%
distribute-lft-out82.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 100.0%
Taylor expanded in d2 around 0 87.0%
Final simplification66.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 (<= d4 1.25e+47) (* d1 (- d2 d3)) (* d1 (+ d4 d2))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.25e+47) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
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.25d+47) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 + d2)
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.25e+47) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.25e+47: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.25e+47) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 + d2)); 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.25e+47)
tmp = d1 * (d2 - d3);
else
tmp = d1 * (d4 + d2);
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.25e+47], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.25 \cdot 10^{+47}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 1.25000000000000005e47Initial program 84.7%
+-commutative84.7%
*-commutative84.7%
distribute-lft-out--87.2%
distribute-lft-out88.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 76.8%
Taylor expanded in d4 around 0 62.7%
if 1.25000000000000005e47 < d4 Initial program 84.8%
+-commutative84.8%
*-commutative84.8%
distribute-lft-out--84.8%
distribute-lft-out86.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 97.5%
Taylor expanded in d3 around 0 77.5%
Final simplification65.7%
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 6.6e+34) (* 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 <= 6.6e+34) {
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 <= 6.6d+34) 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 <= 6.6e+34) {
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 <= 6.6e+34: 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 <= 6.6e+34) 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 <= 6.6e+34)
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, 6.6e+34], 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 6.6 \cdot 10^{+34}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 6.59999999999999976e34Initial program 85.3%
+-commutative85.3%
*-commutative85.3%
distribute-lft-out--87.8%
distribute-lft-out89.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.9%
if 6.59999999999999976e34 < d4 Initial program 83.0%
+-commutative83.0%
*-commutative83.0%
distribute-lft-out--83.0%
distribute-lft-out84.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 56.8%
Final simplification40.8%
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 84.7%
+-commutative84.7%
*-commutative84.7%
distribute-lft-out--86.7%
distribute-lft-out88.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.6%
Final simplification31.6%
(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)))