
(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}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (- d4 d3) (- d1 d2))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d3) - (d1 - d2));
}
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 - d3) - (d1 - d2))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d3) - (d1 - d2));
}
def code(d1, d2, d3, d4): return d1 * ((d4 - d3) - (d1 - d2))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 - d3) - Float64(d1 - d2))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 - d3) - (d1 - d2)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - N[(d1 - d2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 - d3\right) - \left(d1 - d2\right)\right)
\end{array}
Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--91.4%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))) (t_1 (* d1 (- d4 d1))))
(if (<= d2 -1.5e+137)
t_0
(if (<= d2 -1.02e+119)
t_1
(if (<= d2 -4.5e-57)
t_0
(if (or (<= d2 -5.8e-211) (not (<= d2 -1.2e-283)))
t_1
(* d1 (- d4 d3))))))))
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 (d2 <= -1.5e+137) {
tmp = t_0;
} else if (d2 <= -1.02e+119) {
tmp = t_1;
} else if (d2 <= -4.5e-57) {
tmp = t_0;
} else if ((d2 <= -5.8e-211) || !(d2 <= -1.2e-283)) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
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 (d2 <= (-1.5d+137)) then
tmp = t_0
else if (d2 <= (-1.02d+119)) then
tmp = t_1
else if (d2 <= (-4.5d-57)) then
tmp = t_0
else if ((d2 <= (-5.8d-211)) .or. (.not. (d2 <= (-1.2d-283)))) then
tmp = t_1
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
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 (d2 <= -1.5e+137) {
tmp = t_0;
} else if (d2 <= -1.02e+119) {
tmp = t_1;
} else if (d2 <= -4.5e-57) {
tmp = t_0;
} else if ((d2 <= -5.8e-211) || !(d2 <= -1.2e-283)) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) t_1 = d1 * (d4 - d1) tmp = 0 if d2 <= -1.5e+137: tmp = t_0 elif d2 <= -1.02e+119: tmp = t_1 elif d2 <= -4.5e-57: tmp = t_0 elif (d2 <= -5.8e-211) or not (d2 <= -1.2e-283): tmp = t_1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) t_1 = Float64(d1 * Float64(d4 - d1)) tmp = 0.0 if (d2 <= -1.5e+137) tmp = t_0; elseif (d2 <= -1.02e+119) tmp = t_1; elseif (d2 <= -4.5e-57) tmp = t_0; elseif ((d2 <= -5.8e-211) || !(d2 <= -1.2e-283)) tmp = t_1; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); t_1 = d1 * (d4 - d1); tmp = 0.0; if (d2 <= -1.5e+137) tmp = t_0; elseif (d2 <= -1.02e+119) tmp = t_1; elseif (d2 <= -4.5e-57) tmp = t_0; elseif ((d2 <= -5.8e-211) || ~((d2 <= -1.2e-283))) tmp = t_1; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
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[d2, -1.5e+137], t$95$0, If[LessEqual[d2, -1.02e+119], t$95$1, If[LessEqual[d2, -4.5e-57], t$95$0, If[Or[LessEqual[d2, -5.8e-211], N[Not[LessEqual[d2, -1.2e-283]], $MachinePrecision]], t$95$1, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
t_1 := d1 \cdot \left(d4 - d1\right)\\
\mathbf{if}\;d2 \leq -1.5 \cdot 10^{+137}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq -1.02 \cdot 10^{+119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d2 \leq -4.5 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq -5.8 \cdot 10^{-211} \lor \neg \left(d2 \leq -1.2 \cdot 10^{-283}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.5e137 or -1.02e119 < d2 < -4.49999999999999973e-57Initial program 95.7%
sub-neg95.7%
associate-+l+95.7%
*-commutative95.7%
+-commutative95.7%
*-commutative95.7%
sub-neg95.7%
+-commutative95.7%
associate--l+95.7%
distribute-lft-out--95.7%
distribute-rgt-out--98.5%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 83.8%
+-commutative83.8%
associate--r+83.8%
Simplified83.8%
Taylor expanded in d1 around 0 75.3%
if -1.5e137 < d2 < -1.02e119 or -4.49999999999999973e-57 < d2 < -5.80000000000000029e-211 or -1.2e-283 < d2 Initial program 89.5%
sub-neg89.5%
associate-+l+89.5%
*-commutative89.5%
+-commutative89.5%
*-commutative89.5%
sub-neg89.5%
+-commutative89.5%
associate--l+89.5%
distribute-lft-out--90.7%
fma-def94.7%
distribute-rgt-out--97.6%
Simplified97.6%
Taylor expanded in d3 around 0 76.7%
Taylor expanded in d2 around 0 59.0%
+-commutative59.0%
mul-1-neg59.0%
unsub-neg59.0%
unpow259.0%
distribute-lft-out--62.5%
Simplified62.5%
if -5.80000000000000029e-211 < d2 < -1.2e-283Initial program 78.6%
sub-neg78.6%
associate-+l+78.6%
*-commutative78.6%
+-commutative78.6%
*-commutative78.6%
sub-neg78.6%
+-commutative78.6%
associate--l+78.6%
distribute-lft-out--78.6%
distribute-rgt-out--78.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d1 around 0 72.6%
Final simplification66.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (or (<= d3 -3.2e+86)
(not
(or (<= d3 -1.6e+58) (and (not (<= d3 -0.046)) (<= d3 3.2e+231)))))
(* d1 (- d3))
(* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.2e+86) || !((d3 <= -1.6e+58) || (!(d3 <= -0.046) && (d3 <= 3.2e+231)))) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
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 <= (-3.2d+86)) .or. (.not. (d3 <= (-1.6d+58)) .or. (.not. (d3 <= (-0.046d0))) .and. (d3 <= 3.2d+231))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.2e+86) || !((d3 <= -1.6e+58) || (!(d3 <= -0.046) && (d3 <= 3.2e+231)))) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -3.2e+86) or not ((d3 <= -1.6e+58) or (not (d3 <= -0.046) and (d3 <= 3.2e+231))): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -3.2e+86) || !((d3 <= -1.6e+58) || (!(d3 <= -0.046) && (d3 <= 3.2e+231)))) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -3.2e+86) || ~(((d3 <= -1.6e+58) || (~((d3 <= -0.046)) && (d3 <= 3.2e+231))))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -3.2e+86], N[Not[Or[LessEqual[d3, -1.6e+58], And[N[Not[LessEqual[d3, -0.046]], $MachinePrecision], LessEqual[d3, 3.2e+231]]]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3.2 \cdot 10^{+86} \lor \neg \left(d3 \leq -1.6 \cdot 10^{+58} \lor \neg \left(d3 \leq -0.046\right) \land d3 \leq 3.2 \cdot 10^{+231}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -3.2e86 or -1.60000000000000008e58 < d3 < -0.045999999999999999 or 3.20000000000000032e231 < d3 Initial program 84.4%
sub-neg84.4%
associate-+l+84.4%
*-commutative84.4%
+-commutative84.4%
*-commutative84.4%
sub-neg84.4%
+-commutative84.4%
associate--l+84.4%
distribute-lft-out--85.7%
distribute-rgt-out--88.3%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 64.8%
mul-1-neg64.8%
distribute-rgt-neg-out64.8%
Simplified64.8%
if -3.2e86 < d3 < -1.60000000000000008e58 or -0.045999999999999999 < d3 < 3.20000000000000032e231Initial program 93.3%
sub-neg93.3%
associate-+l+93.3%
*-commutative93.3%
+-commutative93.3%
*-commutative93.3%
sub-neg93.3%
+-commutative93.3%
associate--l+93.3%
distribute-lft-out--93.8%
fma-def97.2%
distribute-rgt-out--98.9%
Simplified98.9%
Taylor expanded in d3 around 0 89.6%
Taylor expanded in d1 around 0 68.9%
Final simplification67.7%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d4 d3))))
(if (<= d3 -2.5e+61)
t_0
(if (<= d3 -3200.0)
(* d1 (- (- d1) d3))
(if (<= d3 1.15e+179) (* d1 (- (+ d2 d4) d1)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d3);
double tmp;
if (d3 <= -2.5e+61) {
tmp = t_0;
} else if (d3 <= -3200.0) {
tmp = d1 * (-d1 - d3);
} else if (d3 <= 1.15e+179) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = t_0;
}
return tmp;
}
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 * (d4 - d3)
if (d3 <= (-2.5d+61)) then
tmp = t_0
else if (d3 <= (-3200.0d0)) then
tmp = d1 * (-d1 - d3)
else if (d3 <= 1.15d+179) then
tmp = d1 * ((d2 + d4) - d1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d3);
double tmp;
if (d3 <= -2.5e+61) {
tmp = t_0;
} else if (d3 <= -3200.0) {
tmp = d1 * (-d1 - d3);
} else if (d3 <= 1.15e+179) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d4 - d3) tmp = 0 if d3 <= -2.5e+61: tmp = t_0 elif d3 <= -3200.0: tmp = d1 * (-d1 - d3) elif d3 <= 1.15e+179: tmp = d1 * ((d2 + d4) - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d4 - d3)) tmp = 0.0 if (d3 <= -2.5e+61) tmp = t_0; elseif (d3 <= -3200.0) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); elseif (d3 <= 1.15e+179) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d4 - d3); tmp = 0.0; if (d3 <= -2.5e+61) tmp = t_0; elseif (d3 <= -3200.0) tmp = d1 * (-d1 - d3); elseif (d3 <= 1.15e+179) tmp = d1 * ((d2 + d4) - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -2.5e+61], t$95$0, If[LessEqual[d3, -3200.0], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.15e+179], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d3\right)\\
\mathbf{if}\;d3 \leq -2.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -3200:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{elif}\;d3 \leq 1.15 \cdot 10^{+179}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -2.50000000000000009e61 or 1.14999999999999997e179 < d3 Initial program 83.7%
sub-neg83.7%
associate-+l+83.7%
*-commutative83.7%
+-commutative83.7%
*-commutative83.7%
sub-neg83.7%
+-commutative83.7%
associate--l+83.7%
distribute-lft-out--86.2%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.4%
+-commutative83.4%
associate--r+83.4%
Simplified83.4%
Taylor expanded in d1 around 0 73.6%
if -2.50000000000000009e61 < d3 < -3200Initial program 92.7%
sub-neg92.7%
associate-+l+92.7%
*-commutative92.7%
+-commutative92.7%
*-commutative92.7%
sub-neg92.7%
+-commutative92.7%
associate--l+92.7%
distribute-lft-out--92.7%
distribute-rgt-out--92.7%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d4 around 0 93.0%
+-commutative93.0%
associate--r+93.0%
Simplified93.0%
Taylor expanded in d2 around 0 93.0%
mul-1-neg93.0%
*-commutative93.0%
distribute-rgt-neg-in93.0%
Simplified93.0%
if -3200 < d3 < 1.14999999999999997e179Initial program 93.8%
sub-neg93.8%
associate-+l+93.8%
*-commutative93.8%
+-commutative93.8%
*-commutative93.8%
sub-neg93.8%
+-commutative93.8%
associate--l+93.8%
distribute-lft-out--93.8%
distribute-rgt-out--96.3%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.7%
Final simplification88.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -1.06e-131)
(* d1 (- d2 d3))
(if (<= d4 6.5e-257)
(* d1 (- d2 d1))
(if (<= d4 2.05e+30) (* d1 (- (- d1) d3)) (* d1 (- d4 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.06e-131) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 6.5e-257) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 2.05e+30) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= (-1.06d-131)) then
tmp = d1 * (d2 - d3)
else if (d4 <= 6.5d-257) then
tmp = d1 * (d2 - d1)
else if (d4 <= 2.05d+30) then
tmp = d1 * (-d1 - d3)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.06e-131) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 6.5e-257) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 2.05e+30) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.06e-131: tmp = d1 * (d2 - d3) elif d4 <= 6.5e-257: tmp = d1 * (d2 - d1) elif d4 <= 2.05e+30: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.06e-131) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 6.5e-257) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 2.05e+30) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -1.06e-131) tmp = d1 * (d2 - d3); elseif (d4 <= 6.5e-257) tmp = d1 * (d2 - d1); elseif (d4 <= 2.05e+30) tmp = d1 * (-d1 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.06e-131], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 6.5e-257], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 2.05e+30], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.06 \cdot 10^{-131}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 6.5 \cdot 10^{-257}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 2.05 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -1.06000000000000006e-131Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--91.6%
distribute-rgt-out--93.7%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 69.9%
+-commutative69.9%
associate--r+69.9%
Simplified69.9%
Taylor expanded in d1 around 0 57.7%
if -1.06000000000000006e-131 < d4 < 6.5000000000000002e-257Initial program 84.7%
sub-neg84.7%
associate-+l+84.7%
*-commutative84.7%
+-commutative84.7%
*-commutative84.7%
sub-neg84.7%
+-commutative84.7%
associate--l+84.7%
distribute-lft-out--84.7%
distribute-rgt-out--91.2%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 99.1%
+-commutative99.1%
associate--r+99.1%
Simplified99.1%
Taylor expanded in d3 around 0 82.9%
if 6.5000000000000002e-257 < d4 < 2.05000000000000003e30Initial program 96.6%
sub-neg96.6%
associate-+l+96.6%
*-commutative96.6%
+-commutative96.6%
*-commutative96.6%
sub-neg96.6%
+-commutative96.6%
associate--l+96.6%
distribute-lft-out--96.6%
distribute-rgt-out--96.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 96.9%
+-commutative96.9%
associate--r+96.9%
Simplified96.9%
Taylor expanded in d2 around 0 65.0%
mul-1-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
Simplified65.0%
if 2.05000000000000003e30 < d4 Initial program 89.3%
sub-neg89.3%
associate-+l+89.3%
*-commutative89.3%
+-commutative89.3%
*-commutative89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
distribute-lft-out--91.0%
distribute-rgt-out--91.0%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d2 around 0 93.1%
+-commutative93.1%
associate--r+93.1%
Simplified93.1%
Taylor expanded in d1 around 0 82.6%
Final simplification69.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d2 -2.8e+136) (and (not (<= d2 -2.6e+119)) (<= d2 -1.55e-56))) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d2 <= -2.8e+136) || (!(d2 <= -2.6e+119) && (d2 <= -1.55e-56))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d2 <= (-2.8d+136)) .or. (.not. (d2 <= (-2.6d+119))) .and. (d2 <= (-1.55d-56))) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d2 <= -2.8e+136) || (!(d2 <= -2.6e+119) && (d2 <= -1.55e-56))) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d2 <= -2.8e+136) or (not (d2 <= -2.6e+119) and (d2 <= -1.55e-56)): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d2 <= -2.8e+136) || (!(d2 <= -2.6e+119) && (d2 <= -1.55e-56))) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d2 <= -2.8e+136) || (~((d2 <= -2.6e+119)) && (d2 <= -1.55e-56))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d2, -2.8e+136], And[N[Not[LessEqual[d2, -2.6e+119]], $MachinePrecision], LessEqual[d2, -1.55e-56]]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.8 \cdot 10^{+136} \lor \neg \left(d2 \leq -2.6 \cdot 10^{+119}\right) \land d2 \leq -1.55 \cdot 10^{-56}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -2.8000000000000002e136 or -2.6e119 < d2 < -1.54999999999999994e-56Initial program 95.7%
sub-neg95.7%
associate-+l+95.7%
*-commutative95.7%
+-commutative95.7%
*-commutative95.7%
sub-neg95.7%
+-commutative95.7%
associate--l+95.7%
distribute-lft-out--95.7%
distribute-rgt-out--98.5%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 83.8%
+-commutative83.8%
associate--r+83.8%
Simplified83.8%
Taylor expanded in d1 around 0 75.3%
if -2.8000000000000002e136 < d2 < -2.6e119 or -1.54999999999999994e-56 < d2 Initial program 88.7%
sub-neg88.7%
associate-+l+88.7%
*-commutative88.7%
+-commutative88.7%
*-commutative88.7%
sub-neg88.7%
+-commutative88.7%
associate--l+88.7%
distribute-lft-out--89.8%
fma-def94.6%
distribute-rgt-out--97.3%
Simplified97.3%
Taylor expanded in d3 around 0 74.4%
Taylor expanded in d2 around 0 58.0%
+-commutative58.0%
mul-1-neg58.0%
unsub-neg58.0%
unpow258.0%
distribute-lft-out--62.3%
Simplified62.3%
Final simplification65.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -8.4e-132) (* d1 (- d2 d3)) (if (<= d4 4.1e+30) (* d1 (- d2 d1)) (* d1 (+ d2 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -8.4e-132) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 4.1e+30) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
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 <= (-8.4d-132)) then
tmp = d1 * (d2 - d3)
else if (d4 <= 4.1d+30) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -8.4e-132) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 4.1e+30) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -8.4e-132: tmp = d1 * (d2 - d3) elif d4 <= 4.1e+30: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -8.4e-132) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 4.1e+30) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -8.4e-132) tmp = d1 * (d2 - d3); elseif (d4 <= 4.1e+30) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -8.4e-132], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 4.1e+30], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -8.4 \cdot 10^{-132}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 4.1 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < -8.4000000000000004e-132Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--91.6%
distribute-rgt-out--93.7%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 69.9%
+-commutative69.9%
associate--r+69.9%
Simplified69.9%
Taylor expanded in d1 around 0 57.7%
if -8.4000000000000004e-132 < d4 < 4.10000000000000005e30Initial program 91.3%
sub-neg91.3%
associate-+l+91.3%
*-commutative91.3%
+-commutative91.3%
*-commutative91.3%
sub-neg91.3%
+-commutative91.3%
associate--l+91.3%
distribute-lft-out--91.3%
distribute-rgt-out--94.2%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 97.9%
+-commutative97.9%
associate--r+97.9%
Simplified97.9%
Taylor expanded in d3 around 0 75.7%
if 4.10000000000000005e30 < d4 Initial program 89.3%
sub-neg89.3%
associate-+l+89.3%
*-commutative89.3%
+-commutative89.3%
*-commutative89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
distribute-lft-out--91.0%
fma-def94.6%
distribute-rgt-out--94.6%
Simplified94.6%
Taylor expanded in d3 around 0 73.4%
Taylor expanded in d1 around 0 73.6%
Final simplification68.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.2e-253) (* d1 d2) (if (<= d4 3.8e+17) (* d1 (- d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.2e-253) {
tmp = d1 * d2;
} else if (d4 <= 3.8e+17) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
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.2d-253) then
tmp = d1 * d2
else if (d4 <= 3.8d+17) then
tmp = d1 * -d3
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.2e-253) {
tmp = d1 * d2;
} else if (d4 <= 3.8e+17) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.2e-253: tmp = d1 * d2 elif d4 <= 3.8e+17: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.2e-253) tmp = Float64(d1 * d2); elseif (d4 <= 3.8e+17) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.2e-253) tmp = d1 * d2; elseif (d4 <= 3.8e+17) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.2e-253], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 3.8e+17], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.2 \cdot 10^{-253}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 3.8 \cdot 10^{+17}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 4.1999999999999998e-253Initial program 88.8%
sub-neg88.8%
associate-+l+88.8%
*-commutative88.8%
+-commutative88.8%
*-commutative88.8%
sub-neg88.8%
+-commutative88.8%
associate--l+88.8%
distribute-lft-out--89.5%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.1%
if 4.1999999999999998e-253 < d4 < 3.8e17Initial program 96.2%
sub-neg96.2%
associate-+l+96.2%
*-commutative96.2%
+-commutative96.2%
*-commutative96.2%
sub-neg96.2%
+-commutative96.2%
associate--l+96.2%
distribute-lft-out--96.2%
distribute-rgt-out--96.2%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 34.0%
mul-1-neg34.0%
distribute-rgt-neg-out34.0%
Simplified34.0%
if 3.8e17 < d4 Initial program 90.0%
sub-neg90.0%
associate-+l+90.0%
*-commutative90.0%
+-commutative90.0%
*-commutative90.0%
sub-neg90.0%
+-commutative90.0%
associate--l+90.0%
distribute-lft-out--91.6%
distribute-rgt-out--91.6%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d4 around inf 60.8%
Final simplification40.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6.4e+30) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.4e+30) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
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+30) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d2 + d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.4e+30) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6.4e+30: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6.4e+30) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6.4e+30) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6.4e+30], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6.4 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d4 < 6.39999999999999945e30Initial program 91.0%
sub-neg91.0%
associate-+l+91.0%
*-commutative91.0%
+-commutative91.0%
*-commutative91.0%
sub-neg91.0%
+-commutative91.0%
associate--l+91.0%
distribute-lft-out--91.5%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.5%
+-commutative84.5%
associate--r+84.5%
Simplified84.5%
if 6.39999999999999945e30 < d4 Initial program 89.1%
sub-neg89.1%
associate-+l+89.1%
*-commutative89.1%
+-commutative89.1%
*-commutative89.1%
sub-neg89.1%
+-commutative89.1%
associate--l+89.1%
distribute-lft-out--90.9%
distribute-rgt-out--90.9%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d3 around 0 83.8%
Final simplification84.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6e+47) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e+47) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
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 <= 6d+47) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d4 - d3) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e+47) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6e+47: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6e+47) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6e+47) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6e+47], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6 \cdot 10^{+47}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d4 < 6.0000000000000003e47Initial program 91.1%
sub-neg91.1%
associate-+l+91.1%
*-commutative91.1%
+-commutative91.1%
*-commutative91.1%
sub-neg91.1%
+-commutative91.1%
associate--l+91.1%
distribute-lft-out--91.6%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.6%
+-commutative84.6%
associate--r+84.6%
Simplified84.6%
if 6.0000000000000003e47 < d4 Initial program 88.9%
sub-neg88.9%
associate-+l+88.9%
*-commutative88.9%
+-commutative88.9%
*-commutative88.9%
sub-neg88.9%
+-commutative88.9%
associate--l+88.9%
distribute-lft-out--90.7%
distribute-rgt-out--90.7%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d2 around 0 94.6%
+-commutative94.6%
associate--r+94.6%
Simplified94.6%
Final simplification86.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6e+30) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e+30) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
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 <= 6d+30) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e+30) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6e+30: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6e+30) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6e+30) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6e+30], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6 \cdot 10^{+30}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 5.99999999999999956e30Initial program 91.0%
sub-neg91.0%
associate-+l+91.0%
*-commutative91.0%
+-commutative91.0%
*-commutative91.0%
sub-neg91.0%
+-commutative91.0%
associate--l+91.0%
distribute-lft-out--91.5%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.4%
+-commutative84.4%
associate--r+84.4%
Simplified84.4%
Taylor expanded in d3 around 0 61.9%
if 5.99999999999999956e30 < d4 Initial program 89.3%
sub-neg89.3%
associate-+l+89.3%
*-commutative89.3%
+-commutative89.3%
*-commutative89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
distribute-lft-out--91.0%
fma-def94.6%
distribute-rgt-out--94.6%
Simplified94.6%
Taylor expanded in d3 around 0 73.4%
Taylor expanded in d1 around 0 73.6%
Final simplification64.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6e-6) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e-6) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
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 <= 6d-6) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e-6) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6e-6: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6e-6) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6e-6) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6e-6], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6 \cdot 10^{-6}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 6.0000000000000002e-6Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--91.2%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 36.4%
if 6.0000000000000002e-6 < d4 Initial program 90.5%
sub-neg90.5%
associate-+l+90.5%
*-commutative90.5%
+-commutative90.5%
*-commutative90.5%
sub-neg90.5%
+-commutative90.5%
associate--l+90.5%
distribute-lft-out--92.0%
distribute-rgt-out--92.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 59.6%
Final simplification42.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
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
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 90.6%
sub-neg90.6%
associate-+l+90.6%
*-commutative90.6%
+-commutative90.6%
*-commutative90.6%
sub-neg90.6%
+-commutative90.6%
associate--l+90.6%
distribute-lft-out--91.4%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.2%
Final simplification31.2%
(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 2024014
(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)))