
(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 10 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 (- d2 d3)) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - 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 * ((d4 + (d2 - d3)) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - d1);
}
def code(d1, d2, d3, d4): return d1 * ((d4 + (d2 - d3)) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 + Float64(d2 - d3)) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 + (d2 - d3)) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 + \left(d2 - d3\right)\right) - d1\right)
\end{array}
Initial program 88.7%
+-commutative88.7%
*-commutative88.7%
distribute-lft-out--89.0%
distribute-lft-out90.2%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d4 d3))) (t_1 (* d1 (+ d4 d2))))
(if (<= d3 -6.8e+105)
t_0
(if (<= d3 -2.8e-205)
t_1
(if (<= d3 6e-152) (* d1 (- d4 d1)) (if (<= d3 2.05e+101) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d3);
double t_1 = d1 * (d4 + d2);
double tmp;
if (d3 <= -6.8e+105) {
tmp = t_0;
} else if (d3 <= -2.8e-205) {
tmp = t_1;
} else if (d3 <= 6e-152) {
tmp = d1 * (d4 - d1);
} else if (d3 <= 2.05e+101) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = d1 * (d4 - d3)
t_1 = d1 * (d4 + d2)
if (d3 <= (-6.8d+105)) then
tmp = t_0
else if (d3 <= (-2.8d-205)) then
tmp = t_1
else if (d3 <= 6d-152) then
tmp = d1 * (d4 - d1)
else if (d3 <= 2.05d+101) then
tmp = t_1
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 t_1 = d1 * (d4 + d2);
double tmp;
if (d3 <= -6.8e+105) {
tmp = t_0;
} else if (d3 <= -2.8e-205) {
tmp = t_1;
} else if (d3 <= 6e-152) {
tmp = d1 * (d4 - d1);
} else if (d3 <= 2.05e+101) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d4 - d3) t_1 = d1 * (d4 + d2) tmp = 0 if d3 <= -6.8e+105: tmp = t_0 elif d3 <= -2.8e-205: tmp = t_1 elif d3 <= 6e-152: tmp = d1 * (d4 - d1) elif d3 <= 2.05e+101: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d4 - d3)) t_1 = Float64(d1 * Float64(d4 + d2)) tmp = 0.0 if (d3 <= -6.8e+105) tmp = t_0; elseif (d3 <= -2.8e-205) tmp = t_1; elseif (d3 <= 6e-152) tmp = Float64(d1 * Float64(d4 - d1)); elseif (d3 <= 2.05e+101) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d4 - d3); t_1 = d1 * (d4 + d2); tmp = 0.0; if (d3 <= -6.8e+105) tmp = t_0; elseif (d3 <= -2.8e-205) tmp = t_1; elseif (d3 <= 6e-152) tmp = d1 * (d4 - d1); elseif (d3 <= 2.05e+101) tmp = t_1; 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]}, Block[{t$95$1 = N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -6.8e+105], t$95$0, If[LessEqual[d3, -2.8e-205], t$95$1, If[LessEqual[d3, 6e-152], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 2.05e+101], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d3\right)\\
t_1 := d1 \cdot \left(d4 + d2\right)\\
\mathbf{if}\;d3 \leq -6.8 \cdot 10^{+105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq -2.8 \cdot 10^{-205}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq 6 \cdot 10^{-152}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{elif}\;d3 \leq 2.05 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -6.7999999999999999e105 or 2.05e101 < d3 Initial program 81.1%
+-commutative81.1%
*-commutative81.1%
distribute-lft-out--82.4%
distribute-lft-out86.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.0%
Taylor expanded in d2 around 0 82.0%
if -6.7999999999999999e105 < d3 < -2.79999999999999991e-205 or 6e-152 < d3 < 2.05e101Initial program 91.6%
+-commutative91.6%
*-commutative91.6%
distribute-lft-out--91.6%
distribute-lft-out91.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.2%
Taylor expanded in d1 around 0 73.5%
if -2.79999999999999991e-205 < d3 < 6e-152Initial program 92.0%
+-commutative92.0%
*-commutative92.0%
distribute-lft-out--92.0%
distribute-lft-out92.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 100.0%
Taylor expanded in d2 around 0 81.6%
Final simplification77.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -4.2e-179)
(* d1 d2)
(if (<= d4 3.7e-186)
(* d1 (- d1))
(if (<= d4 3.8e+40) (* d1 (- d3)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -4.2e-179) {
tmp = d1 * d2;
} else if (d4 <= 3.7e-186) {
tmp = d1 * -d1;
} else if (d4 <= 3.8e+40) {
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-179)) then
tmp = d1 * d2
else if (d4 <= 3.7d-186) then
tmp = d1 * -d1
else if (d4 <= 3.8d+40) 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-179) {
tmp = d1 * d2;
} else if (d4 <= 3.7e-186) {
tmp = d1 * -d1;
} else if (d4 <= 3.8e+40) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -4.2e-179: tmp = d1 * d2 elif d4 <= 3.7e-186: tmp = d1 * -d1 elif d4 <= 3.8e+40: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -4.2e-179) tmp = Float64(d1 * d2); elseif (d4 <= 3.7e-186) tmp = Float64(d1 * Float64(-d1)); elseif (d4 <= 3.8e+40) 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-179) tmp = d1 * d2; elseif (d4 <= 3.7e-186) tmp = d1 * -d1; elseif (d4 <= 3.8e+40) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -4.2e-179], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 3.7e-186], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d4, 3.8e+40], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -4.2 \cdot 10^{-179}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 3.7 \cdot 10^{-186}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 3.8 \cdot 10^{+40}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -4.1999999999999997e-179Initial program 90.6%
+-commutative90.6%
*-commutative90.6%
distribute-lft-out--90.6%
distribute-lft-out91.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 19.1%
if -4.1999999999999997e-179 < d4 < 3.7000000000000002e-186Initial program 84.2%
+-commutative84.2%
*-commutative84.2%
distribute-lft-out--85.9%
distribute-lft-out85.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 47.4%
neg-mul-147.4%
Simplified47.4%
if 3.7000000000000002e-186 < d4 < 3.80000000000000004e40Initial program 94.9%
+-commutative94.9%
*-commutative94.9%
distribute-lft-out--94.9%
distribute-lft-out94.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 45.7%
mul-1-neg45.7%
distribute-rgt-neg-out45.7%
Simplified45.7%
if 3.80000000000000004e40 < d4 Initial program 85.9%
+-commutative85.9%
*-commutative85.9%
distribute-lft-out--85.9%
distribute-lft-out89.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 64.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -2.95e+122) (not (<= d1 2.8e+34))) (* d1 (- (+ d4 d2) d1)) (* d1 (- (+ d4 d2) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.95e+122) || !(d1 <= 2.8e+34)) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * ((d4 + d2) - 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 ((d1 <= (-2.95d+122)) .or. (.not. (d1 <= 2.8d+34))) then
tmp = d1 * ((d4 + d2) - d1)
else
tmp = d1 * ((d4 + d2) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -2.95e+122) || !(d1 <= 2.8e+34)) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * ((d4 + d2) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -2.95e+122) or not (d1 <= 2.8e+34): tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * ((d4 + d2) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -2.95e+122) || !(d1 <= 2.8e+34)) tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 + d2) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -2.95e+122) || ~((d1 <= 2.8e+34))) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * ((d4 + d2) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -2.95e+122], N[Not[LessEqual[d1, 2.8e+34]], $MachinePrecision]], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.95 \cdot 10^{+122} \lor \neg \left(d1 \leq 2.8 \cdot 10^{+34}\right):\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -2.95000000000000016e122 or 2.80000000000000008e34 < d1 Initial program 71.3%
+-commutative71.3%
*-commutative71.3%
distribute-lft-out--72.3%
distribute-lft-out75.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.3%
if -2.95000000000000016e122 < d1 < 2.80000000000000008e34Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--99.9%
Simplified99.9%
Taylor expanded in d1 around 0 96.8%
Final simplification94.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.05e+136) (not (<= d3 1.2e+124))) (* d1 (- d4 d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.05e+136) || !(d3 <= 1.2e+124)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * ((d4 + d2) - 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 ((d3 <= (-1.05d+136)) .or. (.not. (d3 <= 1.2d+124))) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * ((d4 + d2) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.05e+136) || !(d3 <= 1.2e+124)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.05e+136) or not (d3 <= 1.2e+124): tmp = d1 * (d4 - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.05e+136) || !(d3 <= 1.2e+124)) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(Float64(d4 + d2) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.05e+136) || ~((d3 <= 1.2e+124))) tmp = d1 * (d4 - d3); else tmp = d1 * ((d4 + d2) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.05e+136], N[Not[LessEqual[d3, 1.2e+124]], $MachinePrecision]], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.05 \cdot 10^{+136} \lor \neg \left(d3 \leq 1.2 \cdot 10^{+124}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -1.05e136 or 1.20000000000000003e124 < d3 Initial program 86.4%
+-commutative86.4%
*-commutative86.4%
distribute-lft-out--88.1%
distribute-lft-out93.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 100.0%
Taylor expanded in d2 around 0 89.1%
if -1.05e136 < d3 < 1.20000000000000003e124Initial program 89.3%
+-commutative89.3%
*-commutative89.3%
distribute-lft-out--89.3%
distribute-lft-out89.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 90.8%
Final simplification90.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -7.6e+123) (not (<= d1 8.5e+99))) (* d1 (- d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -7.6e+123) || !(d1 <= 8.5e+99)) {
tmp = d1 * -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 ((d1 <= (-7.6d+123)) .or. (.not. (d1 <= 8.5d+99))) then
tmp = d1 * -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 ((d1 <= -7.6e+123) || !(d1 <= 8.5e+99)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -7.6e+123) or not (d1 <= 8.5e+99): tmp = d1 * -d1 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -7.6e+123) || !(d1 <= 8.5e+99)) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -7.6e+123) || ~((d1 <= 8.5e+99))) tmp = d1 * -d1; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -7.6e+123], N[Not[LessEqual[d1, 8.5e+99]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -7.6 \cdot 10^{+123} \lor \neg \left(d1 \leq 8.5 \cdot 10^{+99}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d1 < -7.59999999999999989e123 or 8.49999999999999984e99 < d1 Initial program 67.8%
+-commutative67.8%
*-commutative67.8%
distribute-lft-out--68.9%
distribute-lft-out72.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 74.5%
neg-mul-174.5%
Simplified74.5%
if -7.59999999999999989e123 < d1 < 8.49999999999999984e99Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft-out--100.0%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 70.5%
Taylor expanded in d1 around 0 67.0%
Final simplification69.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.6e+28) (* d1 d2) (if (<= d2 -4.8e-258) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+28) {
tmp = d1 * d2;
} else if (d2 <= -4.8e-258) {
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 (d2 <= (-2.6d+28)) then
tmp = d1 * d2
else if (d2 <= (-4.8d-258)) 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 (d2 <= -2.6e+28) {
tmp = d1 * d2;
} else if (d2 <= -4.8e-258) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.6e+28: tmp = d1 * d2 elif d2 <= -4.8e-258: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.6e+28) tmp = Float64(d1 * d2); elseif (d2 <= -4.8e-258) 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 (d2 <= -2.6e+28) tmp = d1 * d2; elseif (d2 <= -4.8e-258) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.6e+28], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -4.8e-258], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.6 \cdot 10^{+28}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -4.8 \cdot 10^{-258}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.6000000000000002e28Initial program 78.7%
+-commutative78.7%
*-commutative78.7%
distribute-lft-out--80.8%
distribute-lft-out80.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 42.1%
if -2.6000000000000002e28 < d2 < -4.8000000000000003e-258Initial program 87.0%
+-commutative87.0%
*-commutative87.0%
distribute-lft-out--87.0%
distribute-lft-out89.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 45.6%
neg-mul-145.6%
Simplified45.6%
if -4.8000000000000003e-258 < d2 Initial program 93.2%
+-commutative93.2%
*-commutative93.2%
distribute-lft-out--93.2%
distribute-lft-out93.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 39.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.4e+16) (* d1 (+ d4 d2)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.4e+16) {
tmp = d1 * (d4 + d2);
} 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 <= (-3.4d+16)) then
tmp = d1 * (d4 + d2)
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 <= -3.4e+16) {
tmp = d1 * (d4 + d2);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.4e+16: tmp = d1 * (d4 + d2) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.4e+16) tmp = Float64(d1 * Float64(d4 + d2)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.4e+16) tmp = d1 * (d4 + d2); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.4e+16], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.4 \cdot 10^{+16}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -3.4e16Initial program 79.9%
+-commutative79.9%
*-commutative79.9%
distribute-lft-out--82.0%
distribute-lft-out82.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 85.0%
Taylor expanded in d1 around 0 69.6%
if -3.4e16 < d2 Initial program 90.8%
+-commutative90.8%
*-commutative90.8%
distribute-lft-out--90.8%
distribute-lft-out92.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.1%
Taylor expanded in d2 around 0 63.2%
Final simplification64.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.7e+25) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.7e+25) {
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 <= 1.7d+25) 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 <= 1.7e+25) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.7e+25: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.7e+25) 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 <= 1.7e+25) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.7e+25], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.7 \cdot 10^{+25}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.69999999999999992e25Initial program 89.5%
+-commutative89.5%
*-commutative89.5%
distribute-lft-out--90.0%
distribute-lft-out90.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 26.4%
if 1.69999999999999992e25 < d4 Initial program 86.3%
+-commutative86.3%
*-commutative86.3%
distribute-lft-out--86.3%
distribute-lft-out89.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 62.3%
(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 88.7%
+-commutative88.7%
*-commutative88.7%
distribute-lft-out--89.0%
distribute-lft-out90.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 24.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 2024186
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))