
(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 (- (+ 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 86.7%
+-commutative86.7%
*-commutative86.7%
distribute-lft-out--88.3%
distribute-lft-out89.8%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -7e+101) (not (<= d3 5.8e+110))) (* d1 (- (+ d4 d2) d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -7e+101) || !(d3 <= 5.8e+110)) {
tmp = d1 * ((d4 + d2) - 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 <= (-7d+101)) .or. (.not. (d3 <= 5.8d+110))) then
tmp = d1 * ((d4 + d2) - 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 <= -7e+101) || !(d3 <= 5.8e+110)) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -7e+101) or not (d3 <= 5.8e+110): tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * ((d4 + d2) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -7e+101) || !(d3 <= 5.8e+110)) tmp = Float64(d1 * Float64(Float64(d4 + d2) - 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 <= -7e+101) || ~((d3 <= 5.8e+110))) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * ((d4 + d2) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -7e+101], N[Not[LessEqual[d3, 5.8e+110]], $MachinePrecision]], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -7 \cdot 10^{+101} \lor \neg \left(d3 \leq 5.8 \cdot 10^{+110}\right):\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -7.00000000000000046e101 or 5.7999999999999999e110 < d3 Initial program 80.5%
+-commutative80.5%
*-commutative80.5%
distribute-lft-out--85.7%
distribute-lft-out88.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.8%
if -7.00000000000000046e101 < d3 < 5.7999999999999999e110Initial program 89.4%
+-commutative89.4%
*-commutative89.4%
distribute-lft-out--89.4%
distribute-lft-out90.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.7%
Final simplification95.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.05e+147) (not (<= d3 8.5e+111))) (* d1 (- d4 d3)) (* d1 (- (+ d4 d2) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.05e+147) || !(d3 <= 8.5e+111)) {
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+147)) .or. (.not. (d3 <= 8.5d+111))) 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+147) || !(d3 <= 8.5e+111)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * ((d4 + d2) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.05e+147) or not (d3 <= 8.5e+111): 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+147) || !(d3 <= 8.5e+111)) 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+147) || ~((d3 <= 8.5e+111))) 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+147], N[Not[LessEqual[d3, 8.5e+111]], $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^{+147} \lor \neg \left(d3 \leq 8.5 \cdot 10^{+111}\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.05000000000000003e147 or 8.49999999999999983e111 < d3 Initial program 80.6%
+-commutative80.6%
*-commutative80.6%
distribute-lft-out--86.5%
distribute-lft-out89.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.5%
Taylor expanded in d2 around 0 89.2%
if -1.05000000000000003e147 < d3 < 8.49999999999999983e111Initial program 88.9%
+-commutative88.9%
*-commutative88.9%
distribute-lft-out--88.9%
distribute-lft-out89.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.0%
Final simplification92.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -4.8e+141) (not (<= d1 1.05e+121))) (* d1 (- d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -4.8e+141) || !(d1 <= 1.05e+121)) {
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 <= (-4.8d+141)) .or. (.not. (d1 <= 1.05d+121))) 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 <= -4.8e+141) || !(d1 <= 1.05e+121)) {
tmp = d1 * -d1;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -4.8e+141) or not (d1 <= 1.05e+121): tmp = d1 * -d1 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -4.8e+141) || !(d1 <= 1.05e+121)) 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 <= -4.8e+141) || ~((d1 <= 1.05e+121))) tmp = d1 * -d1; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -4.8e+141], N[Not[LessEqual[d1, 1.05e+121]], $MachinePrecision]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.8 \cdot 10^{+141} \lor \neg \left(d1 \leq 1.05 \cdot 10^{+121}\right):\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d1 < -4.79999999999999995e141 or 1.0500000000000001e121 < d1 Initial program 60.8%
+-commutative60.8%
*-commutative60.8%
distribute-lft-out--63.3%
distribute-lft-out67.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 84.1%
neg-mul-184.1%
Simplified84.1%
if -4.79999999999999995e141 < d1 < 1.0500000000000001e121Initial program 98.3%
+-commutative98.3%
*-commutative98.3%
distribute-lft-out--99.4%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 71.4%
Taylor expanded in d1 around 0 63.2%
Final simplification69.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.2e-275) (* d1 d2) (if (<= d4 1.45e+89) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.2e-275) {
tmp = d1 * d2;
} else if (d4 <= 1.45e+89) {
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 <= 3.2d-275) then
tmp = d1 * d2
else if (d4 <= 1.45d+89) 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 <= 3.2e-275) {
tmp = d1 * d2;
} else if (d4 <= 1.45e+89) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.2e-275: tmp = d1 * d2 elif d4 <= 1.45e+89: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.2e-275) tmp = Float64(d1 * d2); elseif (d4 <= 1.45e+89) 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 <= 3.2e-275) tmp = d1 * d2; elseif (d4 <= 1.45e+89) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.2e-275], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.45e+89], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.2 \cdot 10^{-275}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.45 \cdot 10^{+89}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 3.2e-275Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--89.1%
distribute-lft-out90.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 39.4%
if 3.2e-275 < d4 < 1.45000000000000013e89Initial program 87.5%
+-commutative87.5%
*-commutative87.5%
distribute-lft-out--88.8%
distribute-lft-out88.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 41.7%
neg-mul-141.7%
Simplified41.7%
if 1.45000000000000013e89 < d4 Initial program 82.9%
+-commutative82.9%
*-commutative82.9%
distribute-lft-out--85.1%
distribute-lft-out89.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 73.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.5e+66) (* d1 (- (+ d4 d2) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.5e+66) {
tmp = d1 * ((d4 + d2) - 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 (d2 <= (-1.5d+66)) then
tmp = d1 * ((d4 + d2) - 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 (d2 <= -1.5e+66) {
tmp = d1 * ((d4 + d2) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.5e+66: tmp = d1 * ((d4 + d2) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.5e+66) tmp = Float64(d1 * Float64(Float64(d4 + d2) - 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 (d2 <= -1.5e+66) tmp = d1 * ((d4 + d2) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.5e+66], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.5 \cdot 10^{+66}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d2 < -1.50000000000000001e66Initial program 76.3%
+-commutative76.3%
*-commutative76.3%
distribute-lft-out--78.2%
distribute-lft-out80.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.4%
if -1.50000000000000001e66 < d2 Initial program 89.5%
+-commutative89.5%
*-commutative89.5%
distribute-lft-out--91.0%
distribute-lft-out92.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.9%
Final simplification85.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.05e+86) (* d1 (- d2 d1)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.05e+86) {
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 <= 1.05d+86) 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 <= 1.05e+86) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.05e+86: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.05e+86) 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 <= 1.05e+86) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.05e+86], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.05 \cdot 10^{+86}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.0499999999999999e86Initial program 87.5%
+-commutative87.5%
*-commutative87.5%
distribute-lft-out--88.9%
distribute-lft-out89.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.7%
Taylor expanded in d4 around 0 66.8%
if 1.0499999999999999e86 < d4 Initial program 83.3%
+-commutative83.3%
*-commutative83.3%
distribute-lft-out--85.4%
distribute-lft-out89.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 95.8%
Taylor expanded in d2 around 0 88.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.8e+89) (* d1 (- d2 d1)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.8e+89) {
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 <= 1.8d+89) 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 <= 1.8e+89) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.8e+89: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.8e+89) 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 <= 1.8e+89) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.8e+89], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.8 \cdot 10^{+89}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d4 < 1.8e89Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--89.0%
distribute-lft-out89.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.3%
Taylor expanded in d4 around 0 66.5%
if 1.8e89 < d4 Initial program 82.9%
+-commutative82.9%
*-commutative82.9%
distribute-lft-out--85.1%
distribute-lft-out89.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around 0 80.8%
Taylor expanded in d1 around 0 78.6%
Final simplification68.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.6e+34) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+34) {
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.6d+34) 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.6e+34) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.6e+34: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.6e+34) 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.6e+34) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.6e+34], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.6 \cdot 10^{+34}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.5999999999999999e34Initial program 88.5%
+-commutative88.5%
*-commutative88.5%
distribute-lft-out--89.6%
distribute-lft-out90.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 38.9%
if 1.5999999999999999e34 < d4 Initial program 81.2%
+-commutative81.2%
*-commutative81.2%
distribute-lft-out--84.4%
distribute-lft-out87.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 60.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -3.4e+230) (* d1 d3) (* d1 d2)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -3.4e+230) {
tmp = d1 * d3;
} else {
tmp = d1 * 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 <= (-3.4d+230)) then
tmp = d1 * d3
else
tmp = d1 * d2
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -3.4e+230) {
tmp = d1 * d3;
} else {
tmp = d1 * d2;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -3.4e+230: tmp = d1 * d3 else: tmp = d1 * d2 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -3.4e+230) tmp = Float64(d1 * d3); else tmp = Float64(d1 * d2); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -3.4e+230) tmp = d1 * d3; else tmp = d1 * d2; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -3.4e+230], N[(d1 * d3), $MachinePrecision], N[(d1 * d2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -3.4 \cdot 10^{+230}:\\
\;\;\;\;d1 \cdot d3\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d2\\
\end{array}
\end{array}
if d1 < -3.39999999999999986e230Initial program 36.4%
+-commutative36.4%
*-commutative36.4%
distribute-lft-out--36.4%
distribute-lft-out36.4%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around 0 63.6%
Taylor expanded in d3 around inf 9.8%
associate-*r*9.8%
mul-1-neg9.8%
Simplified9.8%
add-sqr-sqrt9.8%
sqrt-unprod22.7%
sqr-neg22.7%
sqrt-unprod0.0%
add-sqr-sqrt29.6%
pow129.6%
Applied egg-rr29.6%
unpow129.6%
Simplified29.6%
if -3.39999999999999986e230 < d1 Initial program 91.4%
+-commutative91.4%
*-commutative91.4%
distribute-lft-out--93.2%
distribute-lft-out94.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.8%
(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%
+-commutative86.7%
*-commutative86.7%
distribute-lft-out--88.3%
distribute-lft-out89.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 34.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 2024185
(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)))