
(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 13 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 (* d1 (+ (- d2 d3) (- d4 d1))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
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 * ((d2 - d3) + (d4 - d1))
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): return d1 * ((d2 - d3) + (d4 - d1))
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1))) end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * ((d2 - d3) + (d4 - d1));
end
NOTE: d2 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}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 86.7%
associate--l+86.7%
distribute-lft-out--87.5%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.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 d3))) (t_1 (* d1 (+ d2 d4))))
(if (<= d3 -9e+139)
t_0
(if (<= d3 1.95e-90)
t_1
(if (<= d3 3.6e+31)
(* d1 (- d2 d1))
(if (or (<= d3 1.2e+82)
(and (not (<= d3 1.35e+117)) (<= d3 4.2e+133)))
t_1
t_0))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * (d2 + d4);
double tmp;
if (d3 <= -9e+139) {
tmp = t_0;
} else if (d3 <= 1.95e-90) {
tmp = t_1;
} else if (d3 <= 3.6e+31) {
tmp = d1 * (d2 - d1);
} else if ((d3 <= 1.2e+82) || (!(d3 <= 1.35e+117) && (d3 <= 4.2e+133))) {
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 * d3)
t_1 = d1 * (d2 + d4)
if (d3 <= (-9d+139)) then
tmp = t_0
else if (d3 <= 1.95d-90) then
tmp = t_1
else if (d3 <= 3.6d+31) then
tmp = d1 * (d2 - d1)
else if ((d3 <= 1.2d+82) .or. (.not. (d3 <= 1.35d+117)) .and. (d3 <= 4.2d+133)) 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 * d3);
double t_1 = d1 * (d2 + d4);
double tmp;
if (d3 <= -9e+139) {
tmp = t_0;
} else if (d3 <= 1.95e-90) {
tmp = t_1;
} else if (d3 <= 3.6e+31) {
tmp = d1 * (d2 - d1);
} else if ((d3 <= 1.2e+82) || (!(d3 <= 1.35e+117) && (d3 <= 4.2e+133))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = -(d1 * d3) t_1 = d1 * (d2 + d4) tmp = 0 if d3 <= -9e+139: tmp = t_0 elif d3 <= 1.95e-90: tmp = t_1 elif d3 <= 3.6e+31: tmp = d1 * (d2 - d1) elif (d3 <= 1.2e+82) or (not (d3 <= 1.35e+117) and (d3 <= 4.2e+133)): tmp = t_1 else: tmp = t_0 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) t_1 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d3 <= -9e+139) tmp = t_0; elseif (d3 <= 1.95e-90) tmp = t_1; elseif (d3 <= 3.6e+31) tmp = Float64(d1 * Float64(d2 - d1)); elseif ((d3 <= 1.2e+82) || (!(d3 <= 1.35e+117) && (d3 <= 4.2e+133))) 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 * d3);
t_1 = d1 * (d2 + d4);
tmp = 0.0;
if (d3 <= -9e+139)
tmp = t_0;
elseif (d3 <= 1.95e-90)
tmp = t_1;
elseif (d3 <= 3.6e+31)
tmp = d1 * (d2 - d1);
elseif ((d3 <= 1.2e+82) || (~((d3 <= 1.35e+117)) && (d3 <= 4.2e+133)))
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 * d3), $MachinePrecision])}, Block[{t$95$1 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -9e+139], t$95$0, If[LessEqual[d3, 1.95e-90], t$95$1, If[LessEqual[d3, 3.6e+31], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d3, 1.2e+82], And[N[Not[LessEqual[d3, 1.35e+117]], $MachinePrecision], LessEqual[d3, 4.2e+133]]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
t_1 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d3 \leq -9 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 1.95 \cdot 10^{-90}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 3.6 \cdot 10^{+31}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 1.2 \cdot 10^{+82} \lor \neg \left(d3 \leq 1.35 \cdot 10^{+117}\right) \land d3 \leq 4.2 \cdot 10^{+133}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -8.9999999999999999e139 or 1.19999999999999999e82 < d3 < 1.3500000000000001e117 or 4.2e133 < d3 Initial program 76.4%
associate--l+76.4%
distribute-lft-out--78.8%
distribute-rgt-out--82.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 85.7%
mul-1-neg85.7%
distribute-rgt-neg-out85.7%
Simplified85.7%
if -8.9999999999999999e139 < d3 < 1.95000000000000002e-90 or 3.59999999999999996e31 < d3 < 1.19999999999999999e82 or 1.3500000000000001e117 < d3 < 4.2e133Initial program 94.3%
associate--l+94.3%
distribute-lft-out--94.3%
distribute-rgt-out--97.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 93.6%
associate--l+93.6%
Simplified93.6%
Taylor expanded in d1 around 0 73.5%
if 1.95000000000000002e-90 < d3 < 3.59999999999999996e31Initial program 79.9%
associate--l+79.9%
distribute-lft-out--80.0%
distribute-rgt-out--86.7%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 89.8%
associate--l+89.8%
Simplified89.8%
Taylor expanded in d4 around 0 62.8%
Final simplification76.3%
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 d3))))
(if (<= d4 -1.65e-74)
(* d1 d2)
(if (<= d4 -3.8e-103)
t_0
(if (<= d4 -1.7e-236)
(* d1 d2)
(if (<= d4 1.32e+17)
t_0
(if (<= d4 2.3e+41)
(* d1 d2)
(if (<= d4 4.8e+58) t_0 (* d1 d4)))))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double tmp;
if (d4 <= -1.65e-74) {
tmp = d1 * d2;
} else if (d4 <= -3.8e-103) {
tmp = t_0;
} else if (d4 <= -1.7e-236) {
tmp = d1 * d2;
} else if (d4 <= 1.32e+17) {
tmp = t_0;
} else if (d4 <= 2.3e+41) {
tmp = d1 * d2;
} else if (d4 <= 4.8e+58) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = -(d1 * d3)
if (d4 <= (-1.65d-74)) then
tmp = d1 * d2
else if (d4 <= (-3.8d-103)) then
tmp = t_0
else if (d4 <= (-1.7d-236)) then
tmp = d1 * d2
else if (d4 <= 1.32d+17) then
tmp = t_0
else if (d4 <= 2.3d+41) then
tmp = d1 * d2
else if (d4 <= 4.8d+58) then
tmp = t_0
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 t_0 = -(d1 * d3);
double tmp;
if (d4 <= -1.65e-74) {
tmp = d1 * d2;
} else if (d4 <= -3.8e-103) {
tmp = t_0;
} else if (d4 <= -1.7e-236) {
tmp = d1 * d2;
} else if (d4 <= 1.32e+17) {
tmp = t_0;
} else if (d4 <= 2.3e+41) {
tmp = d1 * d2;
} else if (d4 <= 4.8e+58) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = -(d1 * d3) tmp = 0 if d4 <= -1.65e-74: tmp = d1 * d2 elif d4 <= -3.8e-103: tmp = t_0 elif d4 <= -1.7e-236: tmp = d1 * d2 elif d4 <= 1.32e+17: tmp = t_0 elif d4 <= 2.3e+41: tmp = d1 * d2 elif d4 <= 4.8e+58: tmp = t_0 else: tmp = d1 * d4 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) tmp = 0.0 if (d4 <= -1.65e-74) tmp = Float64(d1 * d2); elseif (d4 <= -3.8e-103) tmp = t_0; elseif (d4 <= -1.7e-236) tmp = Float64(d1 * d2); elseif (d4 <= 1.32e+17) tmp = t_0; elseif (d4 <= 2.3e+41) tmp = Float64(d1 * d2); elseif (d4 <= 4.8e+58) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
t_0 = -(d1 * d3);
tmp = 0.0;
if (d4 <= -1.65e-74)
tmp = d1 * d2;
elseif (d4 <= -3.8e-103)
tmp = t_0;
elseif (d4 <= -1.7e-236)
tmp = d1 * d2;
elseif (d4 <= 1.32e+17)
tmp = t_0;
elseif (d4 <= 2.3e+41)
tmp = d1 * d2;
elseif (d4 <= 4.8e+58)
tmp = t_0;
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_] := Block[{t$95$0 = (-N[(d1 * d3), $MachinePrecision])}, If[LessEqual[d4, -1.65e-74], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, -3.8e-103], t$95$0, If[LessEqual[d4, -1.7e-236], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.32e+17], t$95$0, If[LessEqual[d4, 2.3e+41], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.8e+58], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
\mathbf{if}\;d4 \leq -1.65 \cdot 10^{-74}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq -1.7 \cdot 10^{-236}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.32 \cdot 10^{+17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 2.3 \cdot 10^{+41}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.8 \cdot 10^{+58}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -1.64999999999999998e-74 or -3.8000000000000001e-103 < d4 < -1.6999999999999999e-236 or 1.32e17 < d4 < 2.2999999999999998e41Initial program 87.6%
associate--l+87.6%
distribute-lft-out--87.6%
distribute-rgt-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.0%
if -1.64999999999999998e-74 < d4 < -3.8000000000000001e-103 or -1.6999999999999999e-236 < d4 < 1.32e17 or 2.2999999999999998e41 < d4 < 4.8e58Initial program 88.5%
associate--l+88.5%
distribute-lft-out--89.6%
distribute-rgt-out--89.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 55.8%
mul-1-neg55.8%
distribute-rgt-neg-out55.8%
Simplified55.8%
if 4.8e58 < d4 Initial program 82.1%
associate--l+82.1%
distribute-lft-out--83.9%
distribute-rgt-out--92.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 72.6%
Final simplification48.9%
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 d3))) (t_1 (* d1 (+ d2 d4))))
(if (<= d3 -3.2e+136)
t_0
(if (<= d3 2.7e-9)
t_1
(if (<= d3 8.5e+27) (* d1 (- d1)) (if (<= d3 5.4e+101) t_1 t_0))))))assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * (d2 + d4);
double tmp;
if (d3 <= -3.2e+136) {
tmp = t_0;
} else if (d3 <= 2.7e-9) {
tmp = t_1;
} else if (d3 <= 8.5e+27) {
tmp = d1 * -d1;
} else if (d3 <= 5.4e+101) {
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 * d3)
t_1 = d1 * (d2 + d4)
if (d3 <= (-3.2d+136)) then
tmp = t_0
else if (d3 <= 2.7d-9) then
tmp = t_1
else if (d3 <= 8.5d+27) then
tmp = d1 * -d1
else if (d3 <= 5.4d+101) 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 * d3);
double t_1 = d1 * (d2 + d4);
double tmp;
if (d3 <= -3.2e+136) {
tmp = t_0;
} else if (d3 <= 2.7e-9) {
tmp = t_1;
} else if (d3 <= 8.5e+27) {
tmp = d1 * -d1;
} else if (d3 <= 5.4e+101) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): t_0 = -(d1 * d3) t_1 = d1 * (d2 + d4) tmp = 0 if d3 <= -3.2e+136: tmp = t_0 elif d3 <= 2.7e-9: tmp = t_1 elif d3 <= 8.5e+27: tmp = d1 * -d1 elif d3 <= 5.4e+101: tmp = t_1 else: tmp = t_0 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) t_1 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d3 <= -3.2e+136) tmp = t_0; elseif (d3 <= 2.7e-9) tmp = t_1; elseif (d3 <= 8.5e+27) tmp = Float64(d1 * Float64(-d1)); elseif (d3 <= 5.4e+101) 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 * d3);
t_1 = d1 * (d2 + d4);
tmp = 0.0;
if (d3 <= -3.2e+136)
tmp = t_0;
elseif (d3 <= 2.7e-9)
tmp = t_1;
elseif (d3 <= 8.5e+27)
tmp = d1 * -d1;
elseif (d3 <= 5.4e+101)
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 * d3), $MachinePrecision])}, Block[{t$95$1 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -3.2e+136], t$95$0, If[LessEqual[d3, 2.7e-9], t$95$1, If[LessEqual[d3, 8.5e+27], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d3, 5.4e+101], t$95$1, t$95$0]]]]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
t_1 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d3 \leq -3.2 \cdot 10^{+136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 2.7 \cdot 10^{-9}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq 8.5 \cdot 10^{+27}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d3 \leq 5.4 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -3.19999999999999988e136 or 5.40000000000000012e101 < d3 Initial program 77.2%
associate--l+77.2%
distribute-lft-out--79.5%
distribute-rgt-out--82.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 82.8%
mul-1-neg82.8%
distribute-rgt-neg-out82.8%
Simplified82.8%
if -3.19999999999999988e136 < d3 < 2.7000000000000002e-9 or 8.5e27 < d3 < 5.40000000000000012e101Initial program 93.1%
associate--l+93.1%
distribute-lft-out--93.1%
distribute-rgt-out--95.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 92.9%
associate--l+92.9%
Simplified92.9%
Taylor expanded in d1 around 0 71.2%
if 2.7000000000000002e-9 < d3 < 8.5e27Initial program 62.5%
associate--l+62.5%
distribute-lft-out--62.5%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 71.7%
mul-1-neg71.7%
unpow271.7%
distribute-rgt-neg-out71.7%
Simplified71.7%
Final simplification75.2%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.1e+84) (not (<= d3 5.2e+101))) (* d1 (- d2 (+ d1 d3))) (* d1 (+ d2 (- d4 d1)))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.1e+84) || !(d3 <= 5.2e+101)) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d2 + (d4 - 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 ((d3 <= (-2.1d+84)) .or. (.not. (d3 <= 5.2d+101))) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * (d2 + (d4 - 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 ((d3 <= -2.1e+84) || !(d3 <= 5.2e+101)) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d2 + (d4 - d1));
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.1e+84) or not (d3 <= 5.2e+101): tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d2 + (d4 - d1)) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.1e+84) || !(d3 <= 5.2e+101)) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(d2 + Float64(d4 - d1))); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if ((d3 <= -2.1e+84) || ~((d3 <= 5.2e+101)))
tmp = d1 * (d2 - (d1 + d3));
else
tmp = d1 * (d2 + (d4 - 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[Or[LessEqual[d3, -2.1e+84], N[Not[LessEqual[d3, 5.2e+101]], $MachinePrecision]], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.1 \cdot 10^{+84} \lor \neg \left(d3 \leq 5.2 \cdot 10^{+101}\right):\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d1\right)\right)\\
\end{array}
\end{array}
if d3 < -2.10000000000000019e84 or 5.2e101 < d3 Initial program 78.2%
associate--l+78.2%
distribute-lft-out--80.2%
distribute-rgt-out--83.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 91.8%
if -2.10000000000000019e84 < d3 < 5.2e101Initial program 92.2%
associate--l+92.2%
distribute-lft-out--92.2%
distribute-rgt-out--96.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.0%
associate--l+95.0%
Simplified95.0%
Final simplification93.7%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -1.46e+85) (* d1 (- d2 d3)) (if (<= d3 5.8e+134) (* d1 (+ d2 (- d4 d1))) (* d1 (- (- d1) d3)))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -1.46e+85) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 5.8e+134) {
tmp = d1 * (d2 + (d4 - d1));
} else {
tmp = d1 * (-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) :: tmp
if (d3 <= (-1.46d+85)) then
tmp = d1 * (d2 - d3)
else if (d3 <= 5.8d+134) then
tmp = d1 * (d2 + (d4 - d1))
else
tmp = d1 * (-d1 - 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 (d3 <= -1.46e+85) {
tmp = d1 * (d2 - d3);
} else if (d3 <= 5.8e+134) {
tmp = d1 * (d2 + (d4 - d1));
} else {
tmp = d1 * (-d1 - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d3 <= -1.46e+85: tmp = d1 * (d2 - d3) elif d3 <= 5.8e+134: tmp = d1 * (d2 + (d4 - d1)) else: tmp = d1 * (-d1 - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -1.46e+85) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d3 <= 5.8e+134) tmp = Float64(d1 * Float64(d2 + Float64(d4 - d1))); else tmp = Float64(d1 * Float64(Float64(-d1) - d3)); end return tmp end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
tmp = 0.0;
if (d3 <= -1.46e+85)
tmp = d1 * (d2 - d3);
elseif (d3 <= 5.8e+134)
tmp = d1 * (d2 + (d4 - d1));
else
tmp = d1 * (-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_] := If[LessEqual[d3, -1.46e+85], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 5.8e+134], N[(d1 * N[(d2 + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.46 \cdot 10^{+85}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d3 \leq 5.8 \cdot 10^{+134}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\end{array}
\end{array}
if d3 < -1.46e85Initial program 79.1%
associate--l+79.1%
distribute-lft-out--83.3%
distribute-rgt-out--85.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.8%
Taylor expanded in d4 around 0 85.9%
if -1.46e85 < d3 < 5.80000000000000023e134Initial program 92.1%
associate--l+92.1%
distribute-lft-out--92.1%
distribute-rgt-out--96.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 93.0%
associate--l+93.0%
Simplified93.0%
if 5.80000000000000023e134 < d3 Initial program 74.4%
associate--l+74.4%
distribute-lft-out--74.4%
distribute-rgt-out--76.7%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in76.7%
Applied egg-rr76.7%
Taylor expanded in d4 around 0 72.1%
+-commutative72.1%
mul-1-neg72.1%
unpow272.1%
distribute-rgt-neg-in72.1%
distribute-lft-out95.4%
unsub-neg95.4%
Simplified95.4%
Taylor expanded in d2 around 0 92.5%
associate-*r*92.5%
neg-mul-192.5%
*-commutative92.5%
Simplified92.5%
Final simplification91.6%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -9e+36) (* d1 (- d2 d3)) (if (<= d2 7e-295) (* d1 (- (- d1) d3)) (* d1 (- d4 d3)))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -9e+36) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 7e-295) {
tmp = d1 * (-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 (d2 <= (-9d+36)) then
tmp = d1 * (d2 - d3)
else if (d2 <= 7d-295) then
tmp = d1 * (-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 (d2 <= -9e+36) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 7e-295) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -9e+36: tmp = d1 * (d2 - d3) elif d2 <= 7e-295: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -9e+36) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= 7e-295) tmp = Float64(d1 * Float64(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 (d2 <= -9e+36)
tmp = d1 * (d2 - d3);
elseif (d2 <= 7e-295)
tmp = d1 * (-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[d2, -9e+36], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 7e-295], N[(d1 * N[((-d1) - d3), $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 -9 \cdot 10^{+36}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq 7 \cdot 10^{-295}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -8.99999999999999994e36Initial program 79.6%
associate--l+79.6%
distribute-lft-out--83.3%
distribute-rgt-out--83.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 85.7%
Taylor expanded in d4 around 0 74.5%
if -8.99999999999999994e36 < d2 < 6.99999999999999977e-295Initial program 85.2%
associate--l+85.2%
distribute-lft-out--85.2%
distribute-rgt-out--90.1%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in90.1%
Applied egg-rr90.1%
Taylor expanded in d4 around 0 62.1%
+-commutative62.1%
mul-1-neg62.1%
unpow262.1%
distribute-rgt-neg-in62.1%
distribute-lft-out73.2%
unsub-neg73.2%
Simplified73.2%
Taylor expanded in d2 around 0 73.0%
associate-*r*73.0%
neg-mul-173.0%
*-commutative73.0%
Simplified73.0%
if 6.99999999999999977e-295 < d2 Initial program 90.9%
associate--l+90.9%
distribute-lft-out--90.9%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 83.2%
Taylor expanded in d2 around 0 64.7%
Final simplification69.4%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6.2e+54) (* 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 <= 6.2e+54) {
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 <= 6.2d+54) 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 <= 6.2e+54) {
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 <= 6.2e+54: 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 <= 6.2e+54) 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 <= 6.2e+54)
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, 6.2e+54], 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 6.2 \cdot 10^{+54}:\\
\;\;\;\;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 < 6.1999999999999999e54Initial program 87.9%
associate--l+87.9%
distribute-lft-out--88.4%
distribute-rgt-out--90.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.9%
if 6.1999999999999999e54 < d4 Initial program 82.5%
associate--l+82.5%
distribute-lft-out--84.2%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 84.5%
Final simplification83.3%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -8.8e+36) (* d1 d2) (if (<= d2 1.4e-293) (* d1 (- d1)) (* d1 d4))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.8e+36) {
tmp = d1 * d2;
} else if (d2 <= 1.4e-293) {
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 <= (-8.8d+36)) then
tmp = d1 * d2
else if (d2 <= 1.4d-293) 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 <= -8.8e+36) {
tmp = d1 * d2;
} else if (d2 <= 1.4e-293) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8.8e+36: tmp = d1 * d2 elif d2 <= 1.4e-293: 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 <= -8.8e+36) tmp = Float64(d1 * d2); elseif (d2 <= 1.4e-293) 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 <= -8.8e+36)
tmp = d1 * d2;
elseif (d2 <= 1.4e-293)
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, -8.8e+36], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 1.4e-293], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -8.8 \cdot 10^{+36}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 1.4 \cdot 10^{-293}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -8.80000000000000002e36Initial program 79.6%
associate--l+79.6%
distribute-lft-out--83.3%
distribute-rgt-out--83.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 53.8%
if -8.80000000000000002e36 < d2 < 1.40000000000000013e-293Initial program 85.2%
associate--l+85.2%
distribute-lft-out--85.2%
distribute-rgt-out--90.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 33.2%
mul-1-neg33.2%
unpow233.2%
distribute-rgt-neg-out33.2%
Simplified33.2%
if 1.40000000000000013e-293 < d2 Initial program 90.9%
associate--l+90.9%
distribute-lft-out--90.9%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 36.9%
Final simplification39.3%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.7e+57) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.7e+57) {
tmp = d1 * (d2 - d3);
} 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 (d4 <= 4.7d+57) then
tmp = d1 * (d2 - d3)
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 (d4 <= 4.7e+57) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.7e+57: tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.7e+57) tmp = Float64(d1 * Float64(d2 - d3)); 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 (d4 <= 4.7e+57)
tmp = d1 * (d2 - d3);
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[LessEqual[d4, 4.7e+57], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.7 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 4.7000000000000003e57Initial program 88.0%
associate--l+88.0%
distribute-lft-out--88.5%
distribute-rgt-out--90.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.6%
Taylor expanded in d4 around 0 63.4%
if 4.7000000000000003e57 < d4 Initial program 82.1%
associate--l+82.1%
distribute-lft-out--83.9%
distribute-rgt-out--92.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.5%
associate--l+89.5%
Simplified89.5%
Taylor expanded in d1 around 0 75.7%
Final simplification66.1%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4.5e+36) (* d1 (- d2 d3)) (* d1 (- d4 d3))))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.5e+36) {
tmp = d1 * (d2 - 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 (d2 <= (-4.5d+36)) then
tmp = d1 * (d2 - 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 (d2 <= -4.5e+36) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.5e+36: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.5e+36) tmp = Float64(d1 * Float64(d2 - 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 (d2 <= -4.5e+36)
tmp = d1 * (d2 - 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[d2, -4.5e+36], N[(d1 * N[(d2 - d3), $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 -4.5 \cdot 10^{+36}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -4.49999999999999997e36Initial program 79.6%
associate--l+79.6%
distribute-lft-out--83.3%
distribute-rgt-out--83.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 85.7%
Taylor expanded in d4 around 0 74.5%
if -4.49999999999999997e36 < d2 Initial program 88.6%
associate--l+88.6%
distribute-lft-out--88.6%
distribute-rgt-out--93.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.2%
Taylor expanded in d2 around 0 69.1%
Final simplification70.3%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3e+37) (* d1 d2) (* d1 d4)))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e+37) {
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 (d4 <= 3d+37) 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 (d4 <= 3e+37) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3e+37: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3e+37) 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 (d4 <= 3e+37)
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[d4, 3e+37], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3 \cdot 10^{+37}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 3.00000000000000022e37Initial program 87.7%
associate--l+87.7%
distribute-lft-out--88.2%
distribute-rgt-out--90.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 27.9%
if 3.00000000000000022e37 < d4 Initial program 83.3%
associate--l+83.3%
distribute-lft-out--85.0%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 68.2%
Final simplification37.3%
NOTE: d2 and d4 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
assert(d2 < d4);
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
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 * d2
end function
assert d2 < d4;
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
[d2, d4] = sort([d2, d4]) def code(d1, d2, d3, d4): return d1 * d2
d2, d4 = sort([d2, d4]) function code(d1, d2, d3, d4) return Float64(d1 * d2) end
d2, d4 = num2cell(sort([d2, d4])){:}
function tmp = code(d1, d2, d3, d4)
tmp = d1 * d2;
end
NOTE: d2 and d4 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
[d2, d4] = \mathsf{sort}([d2, d4])\\
\\
d1 \cdot d2
\end{array}
Initial program 86.7%
associate--l+86.7%
distribute-lft-out--87.5%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 23.3%
Final simplification23.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 2023297
(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)))