
(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 12 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(Float64(d4 - d3) - 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[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] + d2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d4 - d3\right) - d1\right) + d2\right)
\end{array}
Initial program 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--85.9%
distribute-lft-out--95.7%
neg-sub095.7%
distribute-rgt-neg-out95.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- (- d1) d3))))
(if (<= d4 1.3e-272)
t_0
(if (<= d4 8e-192)
t_1
(if (<= d4 5.2e-112) t_0 (if (<= d4 1.16e+30) t_1 (* d1 (- d4 d3))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (-d1 - d3);
double tmp;
if (d4 <= 1.3e-272) {
tmp = t_0;
} else if (d4 <= 8e-192) {
tmp = t_1;
} else if (d4 <= 5.2e-112) {
tmp = t_0;
} else if (d4 <= 1.16e+30) {
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 - d1)
t_1 = d1 * (-d1 - d3)
if (d4 <= 1.3d-272) then
tmp = t_0
else if (d4 <= 8d-192) then
tmp = t_1
else if (d4 <= 5.2d-112) then
tmp = t_0
else if (d4 <= 1.16d+30) 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 - d1);
double t_1 = d1 * (-d1 - d3);
double tmp;
if (d4 <= 1.3e-272) {
tmp = t_0;
} else if (d4 <= 8e-192) {
tmp = t_1;
} else if (d4 <= 5.2e-112) {
tmp = t_0;
} else if (d4 <= 1.16e+30) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (-d1 - d3) tmp = 0 if d4 <= 1.3e-272: tmp = t_0 elif d4 <= 8e-192: tmp = t_1 elif d4 <= 5.2e-112: tmp = t_0 elif d4 <= 1.16e+30: tmp = t_1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(Float64(-d1) - d3)) tmp = 0.0 if (d4 <= 1.3e-272) tmp = t_0; elseif (d4 <= 8e-192) tmp = t_1; elseif (d4 <= 5.2e-112) tmp = t_0; elseif (d4 <= 1.16e+30) 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 - d1); t_1 = d1 * (-d1 - d3); tmp = 0.0; if (d4 <= 1.3e-272) tmp = t_0; elseif (d4 <= 8e-192) tmp = t_1; elseif (d4 <= 5.2e-112) tmp = t_0; elseif (d4 <= 1.16e+30) 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 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, 1.3e-272], t$95$0, If[LessEqual[d4, 8e-192], t$95$1, If[LessEqual[d4, 5.2e-112], t$95$0, If[LessEqual[d4, 1.16e+30], t$95$1, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{if}\;d4 \leq 1.3 \cdot 10^{-272}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 8 \cdot 10^{-192}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 5.2 \cdot 10^{-112}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.16 \cdot 10^{+30}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.29999999999999996e-272 or 8.0000000000000008e-192 < d4 < 5.19999999999999983e-112Initial program 86.0%
associate--l+86.0%
sub-neg86.0%
associate-+l+86.0%
+-commutative86.0%
--rgt-identity86.0%
associate--r-86.0%
associate-+r-86.0%
+-commutative86.0%
*-commutative86.0%
sub-neg86.0%
distribute-lft-out--86.0%
distribute-lft-out--95.5%
neg-sub095.5%
distribute-rgt-neg-out95.5%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 85.1%
Taylor expanded in d4 around 0 66.4%
if 1.29999999999999996e-272 < d4 < 8.0000000000000008e-192 or 5.19999999999999983e-112 < d4 < 1.16e30Initial program 87.8%
associate--l+87.8%
sub-neg87.8%
associate-+l+87.8%
+-commutative87.8%
--rgt-identity87.8%
associate--r-87.8%
associate-+r-87.8%
+-commutative87.8%
*-commutative87.8%
sub-neg87.8%
distribute-lft-out--87.8%
distribute-lft-out--97.6%
neg-sub097.6%
distribute-rgt-neg-out97.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 71.2%
Taylor expanded in d4 around 0 71.2%
mul-1-neg71.2%
*-commutative71.2%
distribute-rgt-neg-in71.2%
Simplified71.2%
if 1.16e30 < d4 Initial program 84.4%
associate--l+84.4%
sub-neg84.4%
associate-+l+84.4%
+-commutative84.4%
--rgt-identity84.4%
associate--r-84.4%
associate-+r-84.4%
+-commutative84.4%
*-commutative84.4%
sub-neg84.4%
distribute-lft-out--84.4%
distribute-lft-out--94.8%
neg-sub094.8%
distribute-rgt-neg-out94.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 95.0%
Taylor expanded in d1 around 0 87.5%
Final simplification71.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -3.8e+210) (not (<= d3 3.7e+147))) (* d1 (- d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.8e+210) || !(d3 <= 3.7e+147)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
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.8d+210)) .or. (.not. (d3 <= 3.7d+147))) then
tmp = d1 * -d3
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.8e+210) || !(d3 <= 3.7e+147)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -3.8e+210) or not (d3 <= 3.7e+147): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -3.8e+210) || !(d3 <= 3.7e+147)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -3.8e+210) || ~((d3 <= 3.7e+147))) tmp = d1 * -d3; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -3.8e+210], N[Not[LessEqual[d3, 3.7e+147]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3.8 \cdot 10^{+210} \lor \neg \left(d3 \leq 3.7 \cdot 10^{+147}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -3.80000000000000028e210 or 3.7e147 < d3 Initial program 75.4%
associate--l+75.4%
sub-neg75.4%
associate-+l+75.4%
+-commutative75.4%
--rgt-identity75.4%
associate--r-75.4%
associate-+r-75.4%
+-commutative75.4%
*-commutative75.4%
sub-neg75.4%
distribute-lft-out--75.4%
distribute-lft-out--94.7%
neg-sub094.7%
distribute-rgt-neg-out94.7%
distribute-lft-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in d3 around inf 84.6%
associate-*r*84.6%
mul-1-neg84.6%
Simplified84.6%
if -3.80000000000000028e210 < d3 < 3.7e147Initial program 88.9%
associate--l+88.9%
sub-neg88.9%
associate-+l+88.9%
+-commutative88.9%
--rgt-identity88.9%
associate--r-88.9%
associate-+r-88.9%
+-commutative88.9%
*-commutative88.9%
sub-neg88.9%
distribute-lft-out--88.9%
distribute-lft-out--96.0%
neg-sub096.0%
distribute-rgt-neg-out96.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.6%
Taylor expanded in d3 around 0 70.4%
Final simplification73.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.6e+133) (* d1 (- d2 d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+133) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + 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 (d2 <= (-2.6d+133)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+133) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.6e+133: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.6e+133) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.6e+133) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.6e+133], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.6 \cdot 10^{+133}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -2.5999999999999998e133Initial program 86.0%
associate--l+86.0%
sub-neg86.0%
associate-+l+86.0%
+-commutative86.0%
--rgt-identity86.0%
associate--r-86.0%
associate-+r-86.0%
+-commutative86.0%
*-commutative86.0%
sub-neg86.0%
distribute-lft-out--86.0%
distribute-lft-out--93.0%
neg-sub093.0%
distribute-rgt-neg-out93.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 97.7%
Taylor expanded in d4 around 0 86.8%
if -2.5999999999999998e133 < d2 Initial program 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--85.9%
distribute-lft-out--96.2%
neg-sub096.2%
distribute-rgt-neg-out96.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 81.9%
Final simplification82.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5e+82) (* d1 (- (+ d4 d2) d1)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+82) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * (d4 - (d1 + 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 (d2 <= (-5d+82)) then
tmp = d1 * ((d4 + d2) - d1)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5e+82) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5e+82: tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5e+82) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5e+82) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5e+82], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5 \cdot 10^{+82}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -5.00000000000000015e82Initial program 86.3%
associate--l+86.3%
sub-neg86.3%
associate-+l+86.3%
+-commutative86.3%
--rgt-identity86.3%
associate--r-86.3%
associate-+r-86.3%
+-commutative86.3%
*-commutative86.3%
sub-neg86.3%
distribute-lft-out--86.3%
distribute-lft-out--94.1%
neg-sub094.1%
distribute-rgt-neg-out94.1%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 84.5%
if -5.00000000000000015e82 < d2 Initial program 85.8%
associate--l+85.8%
sub-neg85.8%
associate-+l+85.8%
+-commutative85.8%
--rgt-identity85.8%
associate--r-85.8%
associate-+r-85.8%
+-commutative85.8%
*-commutative85.8%
sub-neg85.8%
distribute-lft-out--85.8%
distribute-lft-out--96.1%
neg-sub096.1%
distribute-rgt-neg-out96.1%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.6%
Final simplification83.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.7e+60) (* d1 (- (+ d4 d2) d3)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e+60) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (d4 - (d1 + 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 (d2 <= (-1.7d+60)) then
tmp = d1 * ((d4 + d2) - d3)
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e+60) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.7e+60: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.7e+60) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.7e+60) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.7e+60], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.7 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -1.7e60Initial program 87.5%
associate--l+87.5%
sub-neg87.5%
associate-+l+87.5%
+-commutative87.5%
--rgt-identity87.5%
associate--r-87.5%
associate-+r-87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
distribute-lft-out--87.5%
distribute-lft-out--94.6%
neg-sub094.6%
distribute-rgt-neg-out94.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 98.2%
if -1.7e60 < d2 Initial program 85.5%
associate--l+85.5%
sub-neg85.5%
associate-+l+85.5%
+-commutative85.5%
--rgt-identity85.5%
associate--r-85.5%
associate-+r-85.5%
+-commutative85.5%
*-commutative85.5%
sub-neg85.5%
distribute-lft-out--85.5%
distribute-lft-out--96.0%
neg-sub096.0%
distribute-rgt-neg-out96.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.6%
Final simplification86.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -9.6e-230) (* d1 d2) (if (<= d4 5.3e+31) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -9.6e-230) {
tmp = d1 * d2;
} else if (d4 <= 5.3e+31) {
tmp = d1 * -d1;
} 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 <= (-9.6d-230)) then
tmp = d1 * d2
else if (d4 <= 5.3d+31) then
tmp = d1 * -d1
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 <= -9.6e-230) {
tmp = d1 * d2;
} else if (d4 <= 5.3e+31) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -9.6e-230: tmp = d1 * d2 elif d4 <= 5.3e+31: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -9.6e-230) tmp = Float64(d1 * d2); elseif (d4 <= 5.3e+31) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -9.6e-230) tmp = d1 * d2; elseif (d4 <= 5.3e+31) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -9.6e-230], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 5.3e+31], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -9.6 \cdot 10^{-230}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 5.3 \cdot 10^{+31}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -9.6000000000000008e-230Initial program 82.9%
associate--l+82.9%
sub-neg82.9%
associate-+l+82.9%
+-commutative82.9%
--rgt-identity82.9%
associate--r-82.9%
associate-+r-82.9%
+-commutative82.9%
*-commutative82.9%
sub-neg82.9%
distribute-lft-out--82.9%
distribute-lft-out--94.6%
neg-sub094.6%
distribute-rgt-neg-out94.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 39.3%
if -9.6000000000000008e-230 < d4 < 5.3000000000000003e31Initial program 90.8%
associate--l+90.8%
sub-neg90.8%
associate-+l+90.8%
+-commutative90.8%
--rgt-identity90.8%
associate--r-90.8%
associate-+r-90.8%
+-commutative90.8%
*-commutative90.8%
sub-neg90.8%
distribute-lft-out--90.8%
distribute-lft-out--97.7%
neg-sub097.7%
distribute-rgt-neg-out97.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around inf 46.2%
mul-1-neg46.2%
unpow246.2%
distribute-rgt-neg-in46.2%
Simplified46.2%
if 5.3000000000000003e31 < d4 Initial program 84.4%
associate--l+84.4%
sub-neg84.4%
associate-+l+84.4%
+-commutative84.4%
--rgt-identity84.4%
associate--r-84.4%
associate-+r-84.4%
+-commutative84.4%
*-commutative84.4%
sub-neg84.4%
distribute-lft-out--84.4%
distribute-lft-out--94.8%
neg-sub094.8%
distribute-rgt-neg-out94.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 62.3%
Final simplification46.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.8e+28) (* d1 (- d2 d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.8e+28) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
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 <= 3.8d+28) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.8e+28) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.8e+28: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.8e+28) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.8e+28) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.8e+28], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.8 \cdot 10^{+28}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 3.7999999999999999e28Initial program 86.3%
associate--l+86.3%
sub-neg86.3%
associate-+l+86.3%
+-commutative86.3%
--rgt-identity86.3%
associate--r-86.3%
associate-+r-86.3%
+-commutative86.3%
*-commutative86.3%
sub-neg86.3%
distribute-lft-out--86.3%
distribute-lft-out--95.9%
neg-sub095.9%
distribute-rgt-neg-out95.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 81.3%
Taylor expanded in d4 around 0 66.5%
if 3.7999999999999999e28 < d4 Initial program 84.4%
associate--l+84.4%
sub-neg84.4%
associate-+l+84.4%
+-commutative84.4%
--rgt-identity84.4%
associate--r-84.4%
associate-+r-84.4%
+-commutative84.4%
*-commutative84.4%
sub-neg84.4%
distribute-lft-out--84.4%
distribute-lft-out--94.8%
neg-sub094.8%
distribute-rgt-neg-out94.8%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.5%
Taylor expanded in d3 around 0 69.1%
Final simplification67.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -7.2e+60) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.2e+60) {
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 <= (-7.2d+60)) 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 <= -7.2e+60) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -7.2e+60: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -7.2e+60) 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 <= -7.2e+60) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -7.2e+60], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -7.2 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -7.19999999999999935e60Initial program 87.5%
associate--l+87.5%
sub-neg87.5%
associate-+l+87.5%
+-commutative87.5%
--rgt-identity87.5%
associate--r-87.5%
associate-+r-87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
distribute-lft-out--87.5%
distribute-lft-out--94.6%
neg-sub094.6%
distribute-rgt-neg-out94.6%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 98.2%
Taylor expanded in d4 around 0 82.8%
if -7.19999999999999935e60 < d2 Initial program 85.5%
associate--l+85.5%
sub-neg85.5%
associate-+l+85.5%
+-commutative85.5%
--rgt-identity85.5%
associate--r-85.5%
associate-+r-85.5%
+-commutative85.5%
*-commutative85.5%
sub-neg85.5%
distribute-lft-out--85.5%
distribute-lft-out--96.0%
neg-sub096.0%
distribute-rgt-neg-out96.0%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.6%
Taylor expanded in d3 around 0 62.1%
Final simplification66.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 7.5e+17) (* d1 (- d2 d1)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 7.5e+17) {
tmp = d1 * (d2 - d1);
} 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 <= 7.5d+17) then
tmp = d1 * (d2 - d1)
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 <= 7.5e+17) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 7.5e+17: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 7.5e+17) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 7.5e+17) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 7.5e+17], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 7.5 \cdot 10^{+17}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 7.5e17Initial program 86.1%
associate--l+86.1%
sub-neg86.1%
associate-+l+86.1%
+-commutative86.1%
--rgt-identity86.1%
associate--r-86.1%
associate-+r-86.1%
+-commutative86.1%
*-commutative86.1%
sub-neg86.1%
distribute-lft-out--86.1%
distribute-lft-out--95.9%
neg-sub095.9%
distribute-rgt-neg-out95.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d3 around 0 81.9%
Taylor expanded in d4 around 0 66.8%
if 7.5e17 < d4 Initial program 85.4%
associate--l+85.4%
sub-neg85.4%
associate-+l+85.4%
+-commutative85.4%
--rgt-identity85.4%
associate--r-85.4%
associate-+r-85.4%
+-commutative85.4%
*-commutative85.4%
sub-neg85.4%
distribute-lft-out--85.4%
distribute-lft-out--95.2%
neg-sub095.2%
distribute-rgt-neg-out95.2%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 93.7%
Taylor expanded in d1 around 0 85.1%
Final simplification71.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.3e+21) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.3e+21) {
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 <= 4.3d+21) 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 <= 4.3e+21) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.3e+21: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.3e+21) 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 <= 4.3e+21) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.3e+21], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.3 \cdot 10^{+21}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 4.3e21Initial program 86.1%
associate--l+86.1%
sub-neg86.1%
associate-+l+86.1%
+-commutative86.1%
--rgt-identity86.1%
associate--r-86.1%
associate-+r-86.1%
+-commutative86.1%
*-commutative86.1%
sub-neg86.1%
distribute-lft-out--86.1%
distribute-lft-out--95.9%
neg-sub095.9%
distribute-rgt-neg-out95.9%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 42.0%
if 4.3e21 < d4 Initial program 85.2%
associate--l+85.2%
sub-neg85.2%
associate-+l+85.2%
+-commutative85.2%
--rgt-identity85.2%
associate--r-85.2%
associate-+r-85.2%
+-commutative85.2%
*-commutative85.2%
sub-neg85.2%
distribute-lft-out--85.2%
distribute-lft-out--95.1%
neg-sub095.1%
distribute-rgt-neg-out95.1%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 59.4%
Final simplification46.2%
(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 85.9%
associate--l+85.9%
sub-neg85.9%
associate-+l+85.9%
+-commutative85.9%
--rgt-identity85.9%
associate--r-85.9%
associate-+r-85.9%
+-commutative85.9%
*-commutative85.9%
sub-neg85.9%
distribute-lft-out--85.9%
distribute-lft-out--95.7%
neg-sub095.7%
distribute-rgt-neg-out95.7%
distribute-lft-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 37.2%
Final simplification37.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 2023275
(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)))