
(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 11 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 (+ (- d2 d1) (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d1) + (d4 - d3));
}
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) + (d4 - d3))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d1) + (d4 - d3));
}
def code(d1, d2, d3, d4): return d1 * ((d2 - d1) + (d4 - d3))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d1) + Float64(d4 - d3))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 - d1) + (d4 - d3)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d1), $MachinePrecision] + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d1\right) + \left(d4 - d3\right)\right)
\end{array}
Initial program 86.7%
sub-neg86.7%
associate-+l+86.7%
*-commutative86.7%
+-commutative86.7%
*-commutative86.7%
sub-neg86.7%
+-commutative86.7%
associate--l+86.7%
distribute-lft-out--87.1%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.15e+67)
(* d1 d2)
(if (<= d2 -3000000.0)
(* d1 (- d1))
(if (<= d2 1.4e-208) (* d3 (- d1)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.15e+67) {
tmp = d1 * d2;
} else if (d2 <= -3000000.0) {
tmp = d1 * -d1;
} else if (d2 <= 1.4e-208) {
tmp = d3 * -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 <= (-1.15d+67)) then
tmp = d1 * d2
else if (d2 <= (-3000000.0d0)) then
tmp = d1 * -d1
else if (d2 <= 1.4d-208) then
tmp = d3 * -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 <= -1.15e+67) {
tmp = d1 * d2;
} else if (d2 <= -3000000.0) {
tmp = d1 * -d1;
} else if (d2 <= 1.4e-208) {
tmp = d3 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.15e+67: tmp = d1 * d2 elif d2 <= -3000000.0: tmp = d1 * -d1 elif d2 <= 1.4e-208: tmp = d3 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.15e+67) tmp = Float64(d1 * d2); elseif (d2 <= -3000000.0) tmp = Float64(d1 * Float64(-d1)); elseif (d2 <= 1.4e-208) tmp = Float64(d3 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.15e+67) tmp = d1 * d2; elseif (d2 <= -3000000.0) tmp = d1 * -d1; elseif (d2 <= 1.4e-208) tmp = d3 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.15e+67], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -3000000.0], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d2, 1.4e-208], N[(d3 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.15 \cdot 10^{+67}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -3000000:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d2 \leq 1.4 \cdot 10^{-208}:\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.1499999999999999e67Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
*-commutative79.6%
+-commutative79.6%
*-commutative79.6%
sub-neg79.6%
+-commutative79.6%
associate--l+79.6%
distribute-lft-out--79.6%
distribute-rgt-out--90.7%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around inf 63.9%
if -1.1499999999999999e67 < d2 < -3e6Initial program 94.7%
sub-neg94.7%
associate-+l+94.7%
*-commutative94.7%
+-commutative94.7%
*-commutative94.7%
sub-neg94.7%
+-commutative94.7%
associate--l+94.7%
distribute-lft-out--94.7%
distribute-rgt-out--94.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 43.7%
neg-mul-143.7%
Simplified43.7%
if -3e6 < d2 < 1.40000000000000001e-208Initial program 88.6%
sub-neg88.6%
associate-+l+88.6%
*-commutative88.6%
+-commutative88.6%
*-commutative88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
distribute-lft-out--89.9%
distribute-rgt-out--89.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around inf 52.3%
mul-1-neg52.3%
distribute-rgt-neg-out52.3%
Simplified52.3%
if 1.40000000000000001e-208 < d2 Initial program 87.5%
sub-neg87.5%
associate-+l+87.5%
*-commutative87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
+-commutative87.5%
associate--l+87.5%
distribute-lft-out--87.5%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 25.6%
Final simplification43.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -2.9e+125) (* d1 (- d4 d1)) (if (<= d1 1.05e+189) (* d1 (- (+ d2 d4) d3)) (* d1 (- d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.9e+125) {
tmp = d1 * (d4 - d1);
} else if (d1 <= 1.05e+189) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * -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 (d1 <= (-2.9d+125)) then
tmp = d1 * (d4 - d1)
else if (d1 <= 1.05d+189) then
tmp = d1 * ((d2 + d4) - d3)
else
tmp = d1 * -d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.9e+125) {
tmp = d1 * (d4 - d1);
} else if (d1 <= 1.05e+189) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * -d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -2.9e+125: tmp = d1 * (d4 - d1) elif d1 <= 1.05e+189: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * -d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -2.9e+125) tmp = Float64(d1 * Float64(d4 - d1)); elseif (d1 <= 1.05e+189) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); else tmp = Float64(d1 * Float64(-d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -2.9e+125) tmp = d1 * (d4 - d1); elseif (d1 <= 1.05e+189) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * -d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -2.9e+125], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.05e+189], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * (-d1)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.9 \cdot 10^{+125}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{elif}\;d1 \leq 1.05 \cdot 10^{+189}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\end{array}
\end{array}
if d1 < -2.89999999999999993e125Initial program 53.8%
Taylor expanded in d2 around 0 61.7%
distribute-lft-out--61.7%
Simplified61.7%
Taylor expanded in d3 around 0 77.1%
unpow277.1%
distribute-lft-out--89.9%
Simplified89.9%
if -2.89999999999999993e125 < d1 < 1.04999999999999996e189Initial program 96.4%
sub-neg96.4%
associate-+l+96.4%
*-commutative96.4%
+-commutative96.4%
*-commutative96.4%
sub-neg96.4%
+-commutative96.4%
associate--l+96.4%
distribute-lft-out--96.9%
distribute-rgt-out--97.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.1%
if 1.04999999999999996e189 < d1 Initial program 60.9%
sub-neg60.9%
associate-+l+60.9%
*-commutative60.9%
+-commutative60.9%
*-commutative60.9%
sub-neg60.9%
+-commutative60.9%
associate--l+60.9%
distribute-lft-out--60.9%
distribute-rgt-out--78.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.2e+72) (not (<= d3 3.1e+90))) (* d3 (- d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.2e+72) || !(d3 <= 3.1e+90)) {
tmp = d3 * -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 ((d3 <= (-1.2d+72)) .or. (.not. (d3 <= 3.1d+90))) then
tmp = d3 * -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 ((d3 <= -1.2e+72) || !(d3 <= 3.1e+90)) {
tmp = d3 * -d1;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.2e+72) or not (d3 <= 3.1e+90): tmp = d3 * -d1 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.2e+72) || !(d3 <= 3.1e+90)) tmp = Float64(d3 * Float64(-d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.2e+72) || ~((d3 <= 3.1e+90))) tmp = d3 * -d1; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.2e+72], N[Not[LessEqual[d3, 3.1e+90]], $MachinePrecision]], N[(d3 * (-d1)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.2 \cdot 10^{+72} \lor \neg \left(d3 \leq 3.1 \cdot 10^{+90}\right):\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -1.20000000000000005e72 or 3.09999999999999988e90 < d3 Initial program 80.1%
sub-neg80.1%
associate-+l+80.1%
*-commutative80.1%
+-commutative80.1%
*-commutative80.1%
sub-neg80.1%
+-commutative80.1%
associate--l+80.1%
distribute-lft-out--81.1%
distribute-rgt-out--84.9%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d3 around inf 71.9%
mul-1-neg71.9%
distribute-rgt-neg-out71.9%
Simplified71.9%
if -1.20000000000000005e72 < d3 < 3.09999999999999988e90Initial 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--96.0%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 75.0%
Taylor expanded in d3 around 0 68.8%
Final simplification70.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4e+61) (* d1 (- d2 d3)) (if (<= d2 5.2e-208) (* d1 (- d4 d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4e+61) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 5.2e-208) {
tmp = d1 * (d4 - 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 <= (-4d+61)) then
tmp = d1 * (d2 - d3)
else if (d2 <= 5.2d-208) then
tmp = d1 * (d4 - 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 <= -4e+61) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 5.2e-208) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4e+61: tmp = d1 * (d2 - d3) elif d2 <= 5.2e-208: tmp = d1 * (d4 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4e+61) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= 5.2e-208) tmp = Float64(d1 * Float64(d4 - 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 <= -4e+61) tmp = d1 * (d2 - d3); elseif (d2 <= 5.2e-208) tmp = d1 * (d4 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4e+61], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 5.2e-208], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq 5.2 \cdot 10^{-208}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -3.9999999999999998e61Initial program 79.9%
sub-neg79.9%
associate-+l+79.9%
*-commutative79.9%
+-commutative79.9%
*-commutative79.9%
sub-neg79.9%
+-commutative79.9%
associate--l+79.9%
distribute-lft-out--79.9%
distribute-rgt-out--90.9%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 98.1%
Taylor expanded in d4 around 0 79.5%
if -3.9999999999999998e61 < d2 < 5.20000000000000034e-208Initial program 89.7%
sub-neg89.7%
associate-+l+89.7%
*-commutative89.7%
+-commutative89.7%
*-commutative89.7%
sub-neg89.7%
+-commutative89.7%
associate--l+89.7%
distribute-lft-out--90.7%
distribute-rgt-out--90.7%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 74.3%
Taylor expanded in d4 around 0 73.3%
Taylor expanded in d2 around 0 71.1%
mul-1-neg71.1%
distribute-rgt-neg-out71.1%
+-commutative71.1%
distribute-lft-out72.1%
sub-neg72.1%
Simplified72.1%
if 5.20000000000000034e-208 < d2 Initial program 87.5%
Taylor expanded in d2 around 0 66.2%
distribute-lft-out--66.2%
Simplified66.2%
Taylor expanded in d3 around 0 46.2%
unpow246.2%
distribute-lft-out--48.1%
Simplified48.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.5e+68) (* d1 d2) (if (<= d2 -2.05e-249) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+68) {
tmp = d1 * d2;
} else if (d2 <= -2.05e-249) {
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.5d+68)) then
tmp = d1 * d2
else if (d2 <= (-2.05d-249)) 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.5e+68) {
tmp = d1 * d2;
} else if (d2 <= -2.05e-249) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.5e+68: tmp = d1 * d2 elif d2 <= -2.05e-249: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.5e+68) tmp = Float64(d1 * d2); elseif (d2 <= -2.05e-249) 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.5e+68) tmp = d1 * d2; elseif (d2 <= -2.05e-249) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.5e+68], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -2.05e-249], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.5 \cdot 10^{+68}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -2.05 \cdot 10^{-249}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.5000000000000002e68Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
*-commutative79.6%
+-commutative79.6%
*-commutative79.6%
sub-neg79.6%
+-commutative79.6%
associate--l+79.6%
distribute-lft-out--79.6%
distribute-rgt-out--90.7%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around inf 63.9%
if -2.5000000000000002e68 < d2 < -2.05000000000000002e-249Initial program 87.9%
sub-neg87.9%
associate-+l+87.9%
*-commutative87.9%
+-commutative87.9%
*-commutative87.9%
sub-neg87.9%
+-commutative87.9%
associate--l+87.9%
distribute-lft-out--89.4%
distribute-rgt-out--89.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around inf 47.2%
neg-mul-147.2%
Simplified47.2%
if -2.05000000000000002e-249 < d2 Initial program 89.0%
sub-neg89.0%
associate-+l+89.0%
*-commutative89.0%
+-commutative89.0%
*-commutative89.0%
sub-neg89.0%
+-commutative89.0%
associate--l+89.0%
distribute-lft-out--89.0%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 27.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.95e+62) (* d1 (- (+ d2 d4) d3)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.95e+62) {
tmp = d1 * ((d2 + d4) - d3);
} 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 (d2 <= (-1.95d+62)) then
tmp = d1 * ((d2 + d4) - d3)
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 (d2 <= -1.95e+62) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.95e+62: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.95e+62) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); 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 (d2 <= -1.95e+62) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.95e+62], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.95 \cdot 10^{+62}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d2 < -1.95e62Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
*-commutative79.6%
+-commutative79.6%
*-commutative79.6%
sub-neg79.6%
+-commutative79.6%
associate--l+79.6%
distribute-lft-out--79.6%
distribute-rgt-out--90.7%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d1 around 0 98.1%
if -1.95e62 < d2 Initial program 88.6%
sub-neg88.6%
associate-+l+88.6%
*-commutative88.6%
+-commutative88.6%
*-commutative88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
distribute-lft-out--89.1%
distribute-rgt-out--91.6%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around 0 85.6%
+-commutative85.6%
associate--r+85.6%
Simplified85.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6.8e+53) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.8e+53) {
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 (d4 <= 6.8d+53) 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 (d4 <= 6.8e+53) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6.8e+53: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6.8e+53) 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 (d4 <= 6.8e+53) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6.8e+53], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6.8 \cdot 10^{+53}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 6.79999999999999995e53Initial program 87.5%
sub-neg87.5%
associate-+l+87.5%
*-commutative87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
+-commutative87.5%
associate--l+87.5%
distribute-lft-out--87.5%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 79.1%
Taylor expanded in d4 around 0 65.5%
if 6.79999999999999995e53 < d4 Initial program 83.0%
Taylor expanded in d2 around 0 72.8%
distribute-lft-out--75.0%
Simplified75.0%
Taylor expanded in d3 around 0 66.7%
unpow266.7%
distribute-lft-out--75.2%
Simplified75.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6.6e+48) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.6e+48) {
tmp = d1 * (d2 - 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 (d4 <= 6.6d+48) then
tmp = d1 * (d2 - 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 (d4 <= 6.6e+48) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6.6e+48: tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6.6e+48) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6.6e+48) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6.6e+48], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6.6 \cdot 10^{+48}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 6.60000000000000045e48Initial program 88.0%
sub-neg88.0%
associate-+l+88.0%
*-commutative88.0%
+-commutative88.0%
*-commutative88.0%
sub-neg88.0%
+-commutative88.0%
associate--l+88.0%
distribute-lft-out--88.0%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 79.0%
Taylor expanded in d4 around 0 65.3%
if 6.60000000000000045e48 < d4 Initial program 81.3%
sub-neg81.3%
associate-+l+81.3%
*-commutative81.3%
+-commutative81.3%
*-commutative81.3%
sub-neg81.3%
+-commutative81.3%
associate--l+81.3%
distribute-lft-out--83.3%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d1 around 0 96.2%
Taylor expanded in d3 around 0 84.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -6e+61) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6e+61) {
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 (d2 <= (-6d+61)) 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 (d2 <= -6e+61) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6e+61: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6e+61) 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 (d2 <= -6e+61) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6e+61], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -6e61Initial program 79.9%
sub-neg79.9%
associate-+l+79.9%
*-commutative79.9%
+-commutative79.9%
*-commutative79.9%
sub-neg79.9%
+-commutative79.9%
associate--l+79.9%
distribute-lft-out--79.9%
distribute-rgt-out--90.9%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in d2 around inf 62.8%
if -6e61 < d2 Initial program 88.5%
sub-neg88.5%
associate-+l+88.5%
*-commutative88.5%
+-commutative88.5%
*-commutative88.5%
sub-neg88.5%
+-commutative88.5%
associate--l+88.5%
distribute-lft-out--89.0%
distribute-rgt-out--91.5%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d4 around inf 29.6%
(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 86.7%
sub-neg86.7%
associate-+l+86.7%
*-commutative86.7%
+-commutative86.7%
*-commutative86.7%
sub-neg86.7%
+-commutative86.7%
associate--l+86.7%
distribute-lft-out--87.1%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.6%
(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 2024096
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))