
(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 14 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: d2 and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d1 -1.4e+101)
(* d1 (- d2 (+ d1 d3)))
(if (<= d1 7.6e+192)
(+ (* d1 (- d4 d1)) (* d1 (- d2 d3)))
(* d1 (- (- d3) d1)))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.4e+101) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d1 <= 7.6e+192) {
tmp = (d1 * (d4 - d1)) + (d1 * (d2 - d3));
} else {
tmp = d1 * (-d3 - d1);
}
return tmp;
}
NOTE: d2 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.4d+101)) then
tmp = d1 * (d2 - (d1 + d3))
else if (d1 <= 7.6d+192) then
tmp = (d1 * (d4 - d1)) + (d1 * (d2 - d3))
else
tmp = d1 * (-d3 - d1)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.4e+101) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d1 <= 7.6e+192) {
tmp = (d1 * (d4 - d1)) + (d1 * (d2 - d3));
} else {
tmp = d1 * (-d3 - d1);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.4e+101: tmp = d1 * (d2 - (d1 + d3)) elif d1 <= 7.6e+192: tmp = (d1 * (d4 - d1)) + (d1 * (d2 - d3)) else: tmp = d1 * (-d3 - d1) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.4e+101) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); elseif (d1 <= 7.6e+192) tmp = Float64(Float64(d1 * Float64(d4 - d1)) + Float64(d1 * Float64(d2 - d3))); else tmp = Float64(d1 * Float64(Float64(-d3) - d1)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d1 <= -1.4e+101)
tmp = d1 * (d2 - (d1 + d3));
elseif (d1 <= 7.6e+192)
tmp = (d1 * (d4 - d1)) + (d1 * (d2 - d3));
else
tmp = d1 * (-d3 - d1);
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.4e+101], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 7.6e+192], N[(N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.4 \cdot 10^{+101}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{elif}\;d1 \leq 7.6 \cdot 10^{+192}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right) + d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\
\end{array}
\end{array}
if d1 < -1.39999999999999991e101Initial program 73.0%
Taylor expanded in d4 around 0 73.0%
sub-neg73.0%
*-commutative73.0%
unpow273.0%
+-commutative73.0%
distribute-neg-in73.0%
distribute-rgt-neg-out73.0%
distribute-rgt-neg-out73.0%
associate-+l+73.0%
distribute-lft-out75.7%
sub-neg75.7%
distribute-lft-out94.6%
sub-neg94.6%
associate--l-94.6%
Simplified94.6%
if -1.39999999999999991e101 < d1 < 7.5999999999999999e192Initial program 96.3%
associate--l+96.3%
+-commutative96.3%
distribute-rgt-out--97.9%
distribute-lft-out--98.4%
Applied egg-rr98.4%
if 7.5999999999999999e192 < d1 Initial program 44.4%
Taylor expanded in d4 around 0 59.3%
sub-neg59.3%
*-commutative59.3%
unpow259.3%
+-commutative59.3%
distribute-neg-in59.3%
distribute-rgt-neg-out59.3%
distribute-rgt-neg-out59.3%
associate-+l+59.3%
distribute-lft-out63.0%
sub-neg63.0%
distribute-lft-out96.3%
sub-neg96.3%
associate--l-96.3%
Simplified96.3%
Taylor expanded in d2 around 0 96.3%
mul-1-neg96.3%
distribute-rgt-neg-in96.3%
Simplified96.3%
Final simplification97.6%
NOTE: d2 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 d3)) (* d1 d4)) (* d1 d1)))) (if (<= t_0 1e+308) t_0 (* d1 (- d2 (+ d1 d3))))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d1 * d4)) - (d1 * d1);
double tmp;
if (t_0 <= 1e+308) {
tmp = t_0;
} else {
tmp = d1 * (d2 - (d1 + d3));
}
return tmp;
}
NOTE: d2 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 * d3)) + (d1 * d4)) - (d1 * d1)
if (t_0 <= 1d+308) then
tmp = t_0
else
tmp = d1 * (d2 - (d1 + d3))
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d1 * d4)) - (d1 * d1);
double tmp;
if (t_0 <= 1e+308) {
tmp = t_0;
} else {
tmp = d1 * (d2 - (d1 + d3));
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = (((d1 * d2) - (d1 * d3)) + (d1 * d4)) - (d1 * d1) tmp = 0 if t_0 <= 1e+308: tmp = t_0 else: tmp = d1 * (d2 - (d1 + d3)) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d1 * d4)) - Float64(d1 * d1)) tmp = 0.0 if (t_0 <= 1e+308) tmp = t_0; else tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = (((d1 * d2) - (d1 * d3)) + (d1 * d4)) - (d1 * d1);
tmp = 0.0;
if (t_0 <= 1e+308)
tmp = t_0;
else
tmp = d1 * (d2 - (d1 + d3));
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d1 * d4), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+308], t$95$0, N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d1 \cdot d4\right) - d1 \cdot d1\\
\mathbf{if}\;t_0 \leq 10^{+308}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < 1e308Initial program 100.0%
if 1e308 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 15.8%
Taylor expanded in d4 around 0 31.6%
sub-neg31.6%
*-commutative31.6%
unpow231.6%
+-commutative31.6%
distribute-neg-in31.6%
distribute-rgt-neg-out31.6%
distribute-rgt-neg-out31.6%
associate-+l+31.6%
distribute-lft-out39.5%
sub-neg39.5%
distribute-lft-out86.8%
sub-neg86.8%
associate--l-86.8%
Simplified86.8%
Final simplification98.0%
NOTE: d2 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 (- d1))) (t_2 (* d1 (- d2 d3))))
(if (<= d1 -1.4e+115)
t_1
(if (<= d1 -2.2e-10)
t_2
(if (<= d1 6.5e-269)
t_0
(if (<= d1 4.8e-190)
t_2
(if (<= d1 3.8e-43) t_0 (if (<= d1 3.1e+139) t_2 t_1))))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d1 * -d1;
double t_2 = d1 * (d2 - d3);
double tmp;
if (d1 <= -1.4e+115) {
tmp = t_1;
} else if (d1 <= -2.2e-10) {
tmp = t_2;
} else if (d1 <= 6.5e-269) {
tmp = t_0;
} else if (d1 <= 4.8e-190) {
tmp = t_2;
} else if (d1 <= 3.8e-43) {
tmp = t_0;
} else if (d1 <= 3.1e+139) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: d2 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 * -d1
t_2 = d1 * (d2 - d3)
if (d1 <= (-1.4d+115)) then
tmp = t_1
else if (d1 <= (-2.2d-10)) then
tmp = t_2
else if (d1 <= 6.5d-269) then
tmp = t_0
else if (d1 <= 4.8d-190) then
tmp = t_2
else if (d1 <= 3.8d-43) then
tmp = t_0
else if (d1 <= 3.1d+139) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d1 * -d1;
double t_2 = d1 * (d2 - d3);
double tmp;
if (d1 <= -1.4e+115) {
tmp = t_1;
} else if (d1 <= -2.2e-10) {
tmp = t_2;
} else if (d1 <= 6.5e-269) {
tmp = t_0;
} else if (d1 <= 4.8e-190) {
tmp = t_2;
} else if (d1 <= 3.8e-43) {
tmp = t_0;
} else if (d1 <= 3.1e+139) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 + d4) t_1 = d1 * -d1 t_2 = d1 * (d2 - d3) tmp = 0 if d1 <= -1.4e+115: tmp = t_1 elif d1 <= -2.2e-10: tmp = t_2 elif d1 <= 6.5e-269: tmp = t_0 elif d1 <= 4.8e-190: tmp = t_2 elif d1 <= 3.8e-43: tmp = t_0 elif d1 <= 3.1e+139: tmp = t_2 else: tmp = t_1 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 + d4)) t_1 = Float64(d1 * Float64(-d1)) t_2 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d1 <= -1.4e+115) tmp = t_1; elseif (d1 <= -2.2e-10) tmp = t_2; elseif (d1 <= 6.5e-269) tmp = t_0; elseif (d1 <= 4.8e-190) tmp = t_2; elseif (d1 <= 3.8e-43) tmp = t_0; elseif (d1 <= 3.1e+139) tmp = t_2; else tmp = t_1; end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = d1 * (d2 + d4);
t_1 = d1 * -d1;
t_2 = d1 * (d2 - d3);
tmp = 0.0;
if (d1 <= -1.4e+115)
tmp = t_1;
elseif (d1 <= -2.2e-10)
tmp = t_2;
elseif (d1 <= 6.5e-269)
tmp = t_0;
elseif (d1 <= 4.8e-190)
tmp = t_2;
elseif (d1 <= 3.8e-43)
tmp = t_0;
elseif (d1 <= 3.1e+139)
tmp = t_2;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: d2 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 * (-d1)), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -1.4e+115], t$95$1, If[LessEqual[d1, -2.2e-10], t$95$2, If[LessEqual[d1, 6.5e-269], t$95$0, If[LessEqual[d1, 4.8e-190], t$95$2, If[LessEqual[d1, 3.8e-43], t$95$0, If[LessEqual[d1, 3.1e+139], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 + d4\right)\\
t_1 := d1 \cdot \left(-d1\right)\\
t_2 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d1 \leq -1.4 \cdot 10^{+115}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d1 \leq -2.2 \cdot 10^{-10}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d1 \leq 6.5 \cdot 10^{-269}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 4.8 \cdot 10^{-190}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d1 \leq 3.8 \cdot 10^{-43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 3.1 \cdot 10^{+139}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d1 < -1.4e115 or 3.1e139 < d1 Initial program 62.5%
Taylor expanded in d1 around inf 85.0%
unpow285.0%
mul-1-neg85.0%
distribute-rgt-neg-out85.0%
Simplified85.0%
if -1.4e115 < d1 < -2.1999999999999999e-10 or 6.50000000000000006e-269 < d1 < 4.8000000000000001e-190 or 3.7999999999999997e-43 < d1 < 3.1e139Initial program 97.6%
Taylor expanded in d4 around 0 76.0%
sub-neg76.0%
*-commutative76.0%
unpow276.0%
+-commutative76.0%
distribute-neg-in76.0%
distribute-rgt-neg-out76.0%
distribute-rgt-neg-out76.0%
associate-+l+76.0%
distribute-lft-out78.4%
sub-neg78.4%
distribute-lft-out78.4%
sub-neg78.4%
associate--l-78.4%
Simplified78.4%
Taylor expanded in d1 around 0 62.7%
if -2.1999999999999999e-10 < d1 < 6.50000000000000006e-269 or 4.8000000000000001e-190 < d1 < 3.7999999999999997e-43Initial program 100.0%
Taylor expanded in d1 around 0 96.0%
Taylor expanded in d3 around 0 77.1%
+-commutative77.1%
Simplified77.1%
Final simplification74.8%
NOTE: d2 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 (- d2 d1))))
(if (<= d3 -1.45e+79)
t_0
(if (<= d3 -6e-288)
t_1
(if (<= d3 9.5e-253) (* d1 (+ d2 d4)) (if (<= d3 2.5e+37) t_1 t_0))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double t_1 = d1 * (d2 - d1);
double tmp;
if (d3 <= -1.45e+79) {
tmp = t_0;
} else if (d3 <= -6e-288) {
tmp = t_1;
} else if (d3 <= 9.5e-253) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 2.5e+37) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: d2 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 * (d2 - d1)
if (d3 <= (-1.45d+79)) then
tmp = t_0
else if (d3 <= (-6d-288)) then
tmp = t_1
else if (d3 <= 9.5d-253) then
tmp = d1 * (d2 + d4)
else if (d3 <= 2.5d+37) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double t_1 = d1 * (d2 - d1);
double tmp;
if (d3 <= -1.45e+79) {
tmp = t_0;
} else if (d3 <= -6e-288) {
tmp = t_1;
} else if (d3 <= 9.5e-253) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 2.5e+37) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) t_1 = d1 * (d2 - d1) tmp = 0 if d3 <= -1.45e+79: tmp = t_0 elif d3 <= -6e-288: tmp = t_1 elif d3 <= 9.5e-253: tmp = d1 * (d2 + d4) elif d3 <= 2.5e+37: tmp = t_1 else: tmp = t_0 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) t_1 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d3 <= -1.45e+79) tmp = t_0; elseif (d3 <= -6e-288) tmp = t_1; elseif (d3 <= 9.5e-253) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d3 <= 2.5e+37) tmp = t_1; else tmp = t_0; end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = d1 * (d2 - d3);
t_1 = d1 * (d2 - d1);
tmp = 0.0;
if (d3 <= -1.45e+79)
tmp = t_0;
elseif (d3 <= -6e-288)
tmp = t_1;
elseif (d3 <= 9.5e-253)
tmp = d1 * (d2 + d4);
elseif (d3 <= 2.5e+37)
tmp = t_1;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: d2 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[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -1.45e+79], t$95$0, If[LessEqual[d3, -6e-288], t$95$1, If[LessEqual[d3, 9.5e-253], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 2.5e+37], t$95$1, t$95$0]]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
t_1 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -1.45 \cdot 10^{+79}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -6 \cdot 10^{-288}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 9.5 \cdot 10^{-253}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq 2.5 \cdot 10^{+37}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -1.44999999999999996e79 or 2.49999999999999994e37 < d3 Initial program 82.1%
Taylor expanded in d4 around 0 76.4%
sub-neg76.4%
*-commutative76.4%
unpow276.4%
+-commutative76.4%
distribute-neg-in76.4%
distribute-rgt-neg-out76.4%
distribute-rgt-neg-out76.4%
associate-+l+76.4%
distribute-lft-out79.4%
sub-neg79.4%
distribute-lft-out92.3%
sub-neg92.3%
associate--l-92.3%
Simplified92.3%
Taylor expanded in d1 around 0 80.8%
if -1.44999999999999996e79 < d3 < -5.99999999999999998e-288 or 9.5e-253 < d3 < 2.49999999999999994e37Initial program 90.3%
Taylor expanded in d4 around 0 68.6%
sub-neg68.6%
*-commutative68.6%
unpow268.6%
+-commutative68.6%
distribute-neg-in68.6%
distribute-rgt-neg-out68.6%
distribute-rgt-neg-out68.6%
associate-+l+68.6%
distribute-lft-out68.6%
sub-neg68.6%
distribute-lft-out72.3%
sub-neg72.3%
associate--l-72.3%
Simplified72.3%
Taylor expanded in d3 around 0 71.1%
if -5.99999999999999998e-288 < d3 < 9.5e-253Initial program 95.2%
Taylor expanded in d1 around 0 90.7%
Taylor expanded in d3 around 0 90.7%
+-commutative90.7%
Simplified90.7%
Final simplification76.5%
NOTE: d2 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 (<= d3 -3e+78)
(* d1 (- d2 d3))
(if (<= d3 -2.45e-288)
t_0
(if (<= d3 1.55e-252)
(* d1 (+ d2 d4))
(if (<= d3 6.5e+16) t_0 (* d1 (- d4 d3))))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d3 <= -3e+78) {
tmp = d1 * (d2 - d3);
} else if (d3 <= -2.45e-288) {
tmp = t_0;
} else if (d3 <= 1.55e-252) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 6.5e+16) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
NOTE: d2 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 (d3 <= (-3d+78)) then
tmp = d1 * (d2 - d3)
else if (d3 <= (-2.45d-288)) then
tmp = t_0
else if (d3 <= 1.55d-252) then
tmp = d1 * (d2 + d4)
else if (d3 <= 6.5d+16) then
tmp = t_0
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d3 <= -3e+78) {
tmp = d1 * (d2 - d3);
} else if (d3 <= -2.45e-288) {
tmp = t_0;
} else if (d3 <= 1.55e-252) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 6.5e+16) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d3 <= -3e+78: tmp = d1 * (d2 - d3) elif d3 <= -2.45e-288: tmp = t_0 elif d3 <= 1.55e-252: tmp = d1 * (d2 + d4) elif d3 <= 6.5e+16: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d3 <= -3e+78) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= -2.45e-288) tmp = t_0; elseif (d3 <= 1.55e-252) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d3 <= 6.5e+16) tmp = t_0; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = d1 * (d2 - d1);
tmp = 0.0;
if (d3 <= -3e+78)
tmp = d1 * (d2 - d3);
elseif (d3 <= -2.45e-288)
tmp = t_0;
elseif (d3 <= 1.55e-252)
tmp = d1 * (d2 + d4);
elseif (d3 <= 6.5e+16)
tmp = t_0;
else
tmp = d1 * (d4 - d3);
end
tmp_2 = tmp;
end
NOTE: d2 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[d3, -3e+78], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, -2.45e-288], t$95$0, If[LessEqual[d3, 1.55e-252], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 6.5e+16], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -3 \cdot 10^{+78}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq -2.45 \cdot 10^{-288}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 1.55 \cdot 10^{-252}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq 6.5 \cdot 10^{+16}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d3 < -2.99999999999999982e78Initial program 76.5%
Taylor expanded in d4 around 0 72.5%
sub-neg72.5%
*-commutative72.5%
unpow272.5%
+-commutative72.5%
distribute-neg-in72.5%
distribute-rgt-neg-out72.5%
distribute-rgt-neg-out72.5%
associate-+l+72.5%
distribute-lft-out74.6%
sub-neg74.6%
distribute-lft-out91.7%
sub-neg91.7%
associate--l-91.7%
Simplified91.7%
Taylor expanded in d1 around 0 77.7%
if -2.99999999999999982e78 < d3 < -2.45000000000000013e-288 or 1.5499999999999999e-252 < d3 < 6.5e16Initial program 90.0%
Taylor expanded in d4 around 0 69.1%
sub-neg69.1%
*-commutative69.1%
unpow269.1%
+-commutative69.1%
distribute-neg-in69.1%
distribute-rgt-neg-out69.1%
distribute-rgt-neg-out69.1%
associate-+l+69.1%
distribute-lft-out69.1%
sub-neg69.1%
distribute-lft-out72.9%
sub-neg72.9%
associate--l-72.9%
Simplified72.9%
Taylor expanded in d3 around 0 72.4%
if -2.45000000000000013e-288 < d3 < 1.5499999999999999e-252Initial program 95.2%
Taylor expanded in d1 around 0 90.7%
Taylor expanded in d3 around 0 90.7%
+-commutative90.7%
Simplified90.7%
if 6.5e16 < d3 Initial program 87.9%
Taylor expanded in d2 around 0 77.3%
distribute-lft-out--77.3%
Simplified77.3%
Taylor expanded in d1 around 0 75.6%
Final simplification75.6%
NOTE: d2 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 d3)))))
(if (<= d4 5e-8)
t_0
(if (<= d4 1.25e+34)
(+ (* d1 (- d4 d1)) (* d1 d2))
(if (<= d4 6.8e+56) t_0 (* d1 (- (+ d2 d4) d3)))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - (d1 + d3));
double tmp;
if (d4 <= 5e-8) {
tmp = t_0;
} else if (d4 <= 1.25e+34) {
tmp = (d1 * (d4 - d1)) + (d1 * d2);
} else if (d4 <= 6.8e+56) {
tmp = t_0;
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
NOTE: d2 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 + d3))
if (d4 <= 5d-8) then
tmp = t_0
else if (d4 <= 1.25d+34) then
tmp = (d1 * (d4 - d1)) + (d1 * d2)
else if (d4 <= 6.8d+56) then
tmp = t_0
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - (d1 + d3));
double tmp;
if (d4 <= 5e-8) {
tmp = t_0;
} else if (d4 <= 1.25e+34) {
tmp = (d1 * (d4 - d1)) + (d1 * d2);
} else if (d4 <= 6.8e+56) {
tmp = t_0;
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = d1 * (d2 - (d1 + d3)) tmp = 0 if d4 <= 5e-8: tmp = t_0 elif d4 <= 1.25e+34: tmp = (d1 * (d4 - d1)) + (d1 * d2) elif d4 <= 6.8e+56: tmp = t_0 else: tmp = d1 * ((d2 + d4) - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - Float64(d1 + d3))) tmp = 0.0 if (d4 <= 5e-8) tmp = t_0; elseif (d4 <= 1.25e+34) tmp = Float64(Float64(d1 * Float64(d4 - d1)) + Float64(d1 * d2)); elseif (d4 <= 6.8e+56) tmp = t_0; else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = d1 * (d2 - (d1 + d3));
tmp = 0.0;
if (d4 <= 5e-8)
tmp = t_0;
elseif (d4 <= 1.25e+34)
tmp = (d1 * (d4 - d1)) + (d1 * d2);
elseif (d4 <= 6.8e+56)
tmp = t_0;
else
tmp = d1 * ((d2 + d4) - d3);
end
tmp_2 = tmp;
end
NOTE: d2 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 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 5e-8], t$95$0, If[LessEqual[d4, 1.25e+34], N[(N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * d2), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 6.8e+56], t$95$0, N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{if}\;d4 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.25 \cdot 10^{+34}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right) + d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 6.8 \cdot 10^{+56}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 4.9999999999999998e-8 or 1.25e34 < d4 < 6.80000000000000002e56Initial program 89.8%
Taylor expanded in d4 around 0 76.2%
sub-neg76.2%
*-commutative76.2%
unpow276.2%
+-commutative76.2%
distribute-neg-in76.2%
distribute-rgt-neg-out76.2%
distribute-rgt-neg-out76.2%
associate-+l+76.2%
distribute-lft-out77.7%
sub-neg77.7%
distribute-lft-out85.4%
sub-neg85.4%
associate--l-85.4%
Simplified85.4%
if 4.9999999999999998e-8 < d4 < 1.25e34Initial program 92.7%
associate--l+92.7%
+-commutative92.7%
distribute-rgt-out--99.9%
distribute-lft-out--100.0%
Applied egg-rr100.0%
Taylor expanded in d3 around 0 86.8%
if 6.80000000000000002e56 < d4 Initial program 76.1%
Taylor expanded in d1 around 0 87.0%
Final simplification85.7%
NOTE: d2 and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.5e+80)
(* d1 d2)
(if (<= d2 -5.2e-147)
(* d1 (- d3))
(if (<= d2 2.05e-143) (* d1 (- d1)) (* d1 d4)))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.5e+80) {
tmp = d1 * d2;
} else if (d2 <= -5.2e-147) {
tmp = d1 * -d3;
} else if (d2 <= 2.05e-143) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d2 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.5d+80)) then
tmp = d1 * d2
else if (d2 <= (-5.2d-147)) then
tmp = d1 * -d3
else if (d2 <= 2.05d-143) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.5e+80) {
tmp = d1 * d2;
} else if (d2 <= -5.2e-147) {
tmp = d1 * -d3;
} else if (d2 <= 2.05e-143) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.5e+80: tmp = d1 * d2 elif d2 <= -5.2e-147: tmp = d1 * -d3 elif d2 <= 2.05e-143: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.5e+80) tmp = Float64(d1 * d2); elseif (d2 <= -5.2e-147) tmp = Float64(d1 * Float64(-d3)); elseif (d2 <= 2.05e-143) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -1.5e+80)
tmp = d1 * d2;
elseif (d2 <= -5.2e-147)
tmp = d1 * -d3;
elseif (d2 <= 2.05e-143)
tmp = d1 * -d1;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.5e+80], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -5.2e-147], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d2, 2.05e-143], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.5 \cdot 10^{+80}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -5.2 \cdot 10^{-147}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d2 \leq 2.05 \cdot 10^{-143}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.49999999999999993e80Initial program 84.7%
Taylor expanded in d2 around inf 71.0%
if -1.49999999999999993e80 < d2 < -5.1999999999999997e-147Initial program 92.4%
Taylor expanded in d3 around inf 47.3%
mul-1-neg47.3%
*-commutative47.3%
distribute-rgt-neg-in47.3%
Simplified47.3%
if -5.1999999999999997e-147 < d2 < 2.05e-143Initial program 88.2%
Taylor expanded in d1 around inf 54.9%
unpow254.9%
mul-1-neg54.9%
distribute-rgt-neg-out54.9%
Simplified54.9%
if 2.05e-143 < d2 Initial program 86.2%
Taylor expanded in d4 around inf 27.9%
Final simplification46.7%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.55e+80) (* d1 (- d2 d3)) (if (<= d2 2.3e-137) (* d1 (- (- d3) d1)) (* d1 (- d4 d3)))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.55e+80) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 2.3e-137) {
tmp = d1 * (-d3 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
NOTE: d2 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.55d+80)) then
tmp = d1 * (d2 - d3)
else if (d2 <= 2.3d-137) then
tmp = d1 * (-d3 - d1)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.55e+80) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 2.3e-137) {
tmp = d1 * (-d3 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.55e+80: tmp = d1 * (d2 - d3) elif d2 <= 2.3e-137: tmp = d1 * (-d3 - d1) else: tmp = d1 * (d4 - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.55e+80) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= 2.3e-137) tmp = Float64(d1 * Float64(Float64(-d3) - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -1.55e+80)
tmp = d1 * (d2 - d3);
elseif (d2 <= 2.3e-137)
tmp = d1 * (-d3 - d1);
else
tmp = d1 * (d4 - d3);
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.55e+80], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 2.3e-137], N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.55 \cdot 10^{+80}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq 2.3 \cdot 10^{-137}:\\
\;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.54999999999999994e80Initial program 84.7%
Taylor expanded in d4 around 0 79.1%
sub-neg79.1%
*-commutative79.1%
unpow279.1%
+-commutative79.1%
distribute-neg-in79.1%
distribute-rgt-neg-out79.1%
distribute-rgt-neg-out79.1%
associate-+l+79.1%
distribute-lft-out81.3%
sub-neg81.3%
distribute-lft-out90.0%
sub-neg90.0%
associate--l-90.0%
Simplified90.0%
Taylor expanded in d1 around 0 81.4%
if -1.54999999999999994e80 < d2 < 2.30000000000000008e-137Initial program 89.6%
Taylor expanded in d4 around 0 68.4%
sub-neg68.4%
*-commutative68.4%
unpow268.4%
+-commutative68.4%
distribute-neg-in68.4%
distribute-rgt-neg-out68.4%
distribute-rgt-neg-out68.4%
associate-+l+68.4%
distribute-lft-out68.4%
sub-neg68.4%
distribute-lft-out75.4%
sub-neg75.4%
associate--l-75.4%
Simplified75.4%
Taylor expanded in d2 around 0 73.6%
mul-1-neg73.6%
distribute-rgt-neg-in73.6%
Simplified73.6%
if 2.30000000000000008e-137 < d2 Initial program 86.2%
Taylor expanded in d2 around 0 57.6%
distribute-lft-out--59.7%
Simplified59.7%
Taylor expanded in d1 around 0 48.6%
Final simplification65.8%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -2.7e+101) (not (<= d1 2.15e+117))) (* d1 (- d1)) (* d1 (+ d2 d4))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.7e+101) || !(d1 <= 2.15e+117)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
NOTE: d2 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.7d+101)) .or. (.not. (d1 <= 2.15d+117))) then
tmp = d1 * -d1
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.7e+101) || !(d1 <= 2.15e+117)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -2.7e+101) or not (d1 <= 2.15e+117): tmp = d1 * -d1 else: tmp = d1 * (d2 + d4) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -2.7e+101) || !(d1 <= 2.15e+117)) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if ((d1 <= -2.7e+101) || ~((d1 <= 2.15e+117)))
tmp = d1 * -d1;
else
tmp = d1 * (d2 + d4);
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -2.7e+101], N[Not[LessEqual[d1, 2.15e+117]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.7 \cdot 10^{+101} \lor \neg \left(d1 \leq 2.15 \cdot 10^{+117}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d1 < -2.70000000000000006e101 or 2.14999999999999999e117 < d1 Initial program 64.8%
Taylor expanded in d1 around inf 81.0%
unpow281.0%
mul-1-neg81.0%
distribute-rgt-neg-out81.0%
Simplified81.0%
if -2.70000000000000006e101 < d1 < 2.14999999999999999e117Initial program 99.4%
Taylor expanded in d1 around 0 91.8%
Taylor expanded in d3 around 0 63.9%
+-commutative63.9%
Simplified63.9%
Final simplification69.8%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.3e+57) (* d1 (- d2 (+ d1 d3))) (* d1 (- d4 d3))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.3e+57) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
NOTE: d2 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 <= 3.3d+57) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.3e+57) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.3e+57: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d4 - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.3e+57) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d4 <= 3.3e+57)
tmp = d1 * (d2 - (d1 + d3));
else
tmp = d1 * (d4 - d3);
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.3e+57], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.3 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 3.3000000000000001e57Initial program 90.0%
Taylor expanded in d4 around 0 76.1%
sub-neg76.1%
*-commutative76.1%
unpow276.1%
+-commutative76.1%
distribute-neg-in76.1%
distribute-rgt-neg-out76.1%
distribute-rgt-neg-out76.1%
associate-+l+76.1%
distribute-lft-out77.5%
sub-neg77.5%
distribute-lft-out84.6%
sub-neg84.6%
associate--l-84.6%
Simplified84.6%
if 3.3000000000000001e57 < d4 Initial program 76.1%
Taylor expanded in d2 around 0 61.4%
distribute-lft-out--61.4%
Simplified61.4%
Taylor expanded in d1 around 0 70.1%
Final simplification82.0%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3e+57) (* d1 (- d2 (+ d1 d3))) (* d1 (- (+ d2 d4) d3))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e+57) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
NOTE: d2 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 <= 3d+57) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e+57) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3e+57: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * ((d2 + d4) - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3e+57) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d4 <= 3e+57)
tmp = d1 * (d2 - (d1 + d3));
else
tmp = d1 * ((d2 + d4) - d3);
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3e+57], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 3e57Initial program 90.0%
Taylor expanded in d4 around 0 76.1%
sub-neg76.1%
*-commutative76.1%
unpow276.1%
+-commutative76.1%
distribute-neg-in76.1%
distribute-rgt-neg-out76.1%
distribute-rgt-neg-out76.1%
associate-+l+76.1%
distribute-lft-out77.5%
sub-neg77.5%
distribute-lft-out84.6%
sub-neg84.6%
associate--l-84.6%
Simplified84.6%
if 3e57 < d4 Initial program 76.1%
Taylor expanded in d1 around 0 87.0%
Final simplification85.0%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4e+79) (* d1 d2) (if (<= d2 2.95e-142) (* d1 (- d1)) (* d1 d4))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4e+79) {
tmp = d1 * d2;
} else if (d2 <= 2.95e-142) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d2 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 <= (-4d+79)) then
tmp = d1 * d2
else if (d2 <= 2.95d-142) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4e+79) {
tmp = d1 * d2;
} else if (d2 <= 2.95e-142) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4e+79: tmp = d1 * d2 elif d2 <= 2.95e-142: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4e+79) tmp = Float64(d1 * d2); elseif (d2 <= 2.95e-142) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -4e+79)
tmp = d1 * d2;
elseif (d2 <= 2.95e-142)
tmp = d1 * -d1;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4e+79], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 2.95e-142], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4 \cdot 10^{+79}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 2.95 \cdot 10^{-142}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -3.99999999999999987e79Initial program 84.7%
Taylor expanded in d2 around inf 71.0%
if -3.99999999999999987e79 < d2 < 2.94999999999999983e-142Initial program 89.6%
Taylor expanded in d1 around inf 44.0%
unpow244.0%
mul-1-neg44.0%
distribute-rgt-neg-out44.0%
Simplified44.0%
if 2.94999999999999983e-142 < d2 Initial program 86.2%
Taylor expanded in d4 around inf 27.9%
Final simplification42.9%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.5e+65) (* d1 d2) (* d1 d4)))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+65) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
NOTE: d2 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.5d+65)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+65) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.5e+65: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.5e+65) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d2 <= -2.5e+65)
tmp = d1 * d2;
else
tmp = d1 * d4;
end
tmp_2 = tmp;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.5e+65], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.5 \cdot 10^{+65}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.49999999999999986e65Initial program 85.1%
Taylor expanded in d2 around inf 69.6%
if -2.49999999999999986e65 < d2 Initial program 88.0%
Taylor expanded in d4 around inf 30.3%
Final simplification37.5%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d4))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
NOTE: d2 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
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): return d1 * d4
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) return Float64(d1 * d4) end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * d4;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d1 * d4), $MachinePrecision]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
d1 \cdot d4
\end{array}
Initial program 87.5%
Taylor expanded in d4 around inf 28.4%
Final simplification28.4%
(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 2023174
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:herbie-target
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))