
(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 14 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 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(d2 - d3) + Float64(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[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.6%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -4e+22) (* d1 (- d4 (+ d1 d3))) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -4e+22) {
tmp = d1 * (d4 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d3 <= (-4d+22)) then
tmp = d1 * (d4 - (d1 + d3))
else
tmp = d1 * ((d2 + d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -4e+22) {
tmp = d1 * (d4 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -4e+22: tmp = d1 * (d4 - (d1 + d3)) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -4e+22) tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= -4e+22) tmp = d1 * (d4 - (d1 + d3)); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -4e+22], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -4 \cdot 10^{+22}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -4e22Initial program 87.7%
associate--l+87.7%
distribute-lft-out--89.4%
distribute-rgt-out--91.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.3%
if -4e22 < d3 Initial program 90.4%
associate--l+90.4%
distribute-lft-out--90.9%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 81.5%
Final simplification81.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.75e+52) (* d1 (- d2 d3)) (* d1 (- (- d1) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.75e+52) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (-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.75d+52)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (-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.75e+52) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (-d1 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.75e+52: tmp = d1 * (d2 - d3) else: tmp = d1 * (-d1 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.75e+52) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(Float64(-d1) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.75e+52) tmp = d1 * (d2 - d3); else tmp = d1 * (-d1 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.75e+52], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.75 \cdot 10^{+52}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\end{array}
\end{array}
if d2 < -1.75e52Initial program 87.0%
associate--l+87.0%
distribute-lft-out--88.9%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.4%
Taylor expanded in d4 around 0 83.5%
if -1.75e52 < d2 Initial program 90.6%
associate--l+90.6%
distribute-lft-out--91.1%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.2%
Taylor expanded in d4 around 0 63.4%
associate-*r*63.4%
neg-mul-163.4%
Simplified63.4%
Final simplification67.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 -3e+137) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -3e+137) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d3 <= (-3d+137)) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -3e+137) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -3e+137: tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -3e+137) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= -3e+137) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -3e+137], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3 \cdot 10^{+137}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -3.0000000000000001e137Initial program 87.1%
associate--l+87.1%
distribute-lft-out--90.3%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 78.3%
associate-*r*78.3%
neg-mul-178.3%
Simplified78.3%
if -3.0000000000000001e137 < d3 Initial program 90.2%
associate--l+90.2%
distribute-lft-out--90.6%
distribute-rgt-out--92.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.7%
Taylor expanded in d3 around 0 58.2%
Final simplification60.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 8.5e+63) (* d1 (+ d2 d4)) (* d1 (- d2 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= 8.5e+63) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (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 (d1 <= 8.5d+63) then
tmp = d1 * (d2 + d4)
else
tmp = d1 * (d2 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= 8.5e+63) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d2 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= 8.5e+63: tmp = d1 * (d2 + d4) else: tmp = d1 * (d2 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= 8.5e+63) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = Float64(d1 * Float64(d2 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= 8.5e+63) tmp = d1 * (d2 + d4); else tmp = d1 * (d2 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, 8.5e+63], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq 8.5 \cdot 10^{+63}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\end{array}
\end{array}
if d1 < 8.5000000000000004e63Initial program 91.9%
associate--l+91.9%
distribute-lft-out--92.4%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 86.3%
Taylor expanded in d3 around 0 56.4%
if 8.5000000000000004e63 < d1 Initial program 82.5%
associate--l+82.5%
distribute-lft-out--84.2%
distribute-rgt-out--86.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.8%
Taylor expanded in d4 around 0 83.3%
Final simplification62.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d3 1.65e+101) (* d1 (+ d2 d4)) (* d1 (- d2 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= 1.65e+101) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (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 (d3 <= 1.65d+101) then
tmp = d1 * (d2 + d4)
else
tmp = d1 * (d2 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= 1.65e+101) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d2 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= 1.65e+101: tmp = d1 * (d2 + d4) else: tmp = d1 * (d2 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= 1.65e+101) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = Float64(d1 * Float64(d2 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= 1.65e+101) tmp = d1 * (d2 + d4); else tmp = d1 * (d2 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, 1.65e+101], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq 1.65 \cdot 10^{+101}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\end{array}
\end{array}
if d3 < 1.65000000000000006e101Initial program 91.4%
associate--l+91.4%
distribute-lft-out--91.9%
distribute-rgt-out--94.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.9%
Taylor expanded in d3 around 0 61.9%
if 1.65000000000000006e101 < d3 Initial program 84.7%
associate--l+84.7%
distribute-lft-out--86.4%
distribute-rgt-out--88.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 96.6%
Taylor expanded in d4 around 0 91.8%
Final simplification68.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.6e+36) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.6e+36) {
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 <= (-5.6d+36)) 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 <= -5.6e+36) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.6e+36: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.6e+36) 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 <= -5.6e+36) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.6e+36], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.6 \cdot 10^{+36}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -5.6000000000000001e36Initial program 88.3%
associate--l+88.3%
distribute-lft-out--90.0%
distribute-rgt-out--90.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.5%
Taylor expanded in d4 around 0 83.6%
if -5.6000000000000001e36 < d2 Initial program 90.3%
associate--l+90.3%
distribute-lft-out--90.8%
distribute-rgt-out--93.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 70.8%
Taylor expanded in d2 around 0 54.5%
Final simplification61.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.8e+52) (* d1 (- d2 d3)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e+52) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.8d+52)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e+52) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.8e+52: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.8e+52) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.8e+52) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e+52], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.8 \cdot 10^{+52}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.8e52Initial program 87.0%
associate--l+87.0%
distribute-lft-out--88.9%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.4%
Taylor expanded in d4 around 0 83.5%
if -1.8e52 < d2 Initial program 90.6%
associate--l+90.6%
distribute-lft-out--91.1%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.2%
Taylor expanded in d1 around 0 61.7%
Final simplification66.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.65e+52) (* d1 d2) (* d1 (- d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.65e+52) {
tmp = d1 * d2;
} 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 (d2 <= (-1.65d+52)) then
tmp = d1 * d2
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 (d2 <= -1.65e+52) {
tmp = d1 * d2;
} else {
tmp = d1 * -d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.65e+52: tmp = d1 * d2 else: tmp = d1 * -d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.65e+52) tmp = Float64(d1 * d2); else tmp = Float64(d1 * Float64(-d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.65e+52) tmp = d1 * d2; else tmp = d1 * -d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.65e+52], N[(d1 * d2), $MachinePrecision], N[(d1 * (-d1)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.65 \cdot 10^{+52}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\end{array}
\end{array}
if d2 < -1.65e52Initial program 87.2%
associate--l+87.2%
distribute-lft-out--89.1%
distribute-rgt-out--89.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 76.8%
if -1.65e52 < d2 Initial program 90.5%
associate--l+90.5%
distribute-lft-out--91.0%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 33.5%
neg-mul-133.5%
Simplified33.5%
Final simplification42.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.7e+66) (* d1 d2) (* d1 (- d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e+66) {
tmp = d1 * d2;
} else {
tmp = 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+66)) then
tmp = d1 * d2
else
tmp = 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+66) {
tmp = d1 * d2;
} else {
tmp = d1 * -d3;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.7e+66: tmp = d1 * d2 else: tmp = d1 * -d3 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.7e+66) tmp = Float64(d1 * d2); else tmp = Float64(d1 * Float64(-d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.7e+66) tmp = d1 * d2; else tmp = d1 * -d3; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.7e+66], N[(d1 * d2), $MachinePrecision], N[(d1 * (-d3)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.7 \cdot 10^{+66}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\end{array}
\end{array}
if d2 < -1.70000000000000015e66Initial program 86.0%
associate--l+86.0%
distribute-lft-out--88.0%
distribute-rgt-out--88.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 80.3%
if -1.70000000000000015e66 < d2 Initial program 90.8%
associate--l+90.8%
distribute-lft-out--91.2%
distribute-rgt-out--94.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 39.4%
associate-*r*39.4%
neg-mul-139.4%
Simplified39.4%
Final simplification47.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.8e-13) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.8e-13) {
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 <= (-2.8d-13)) 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 <= -2.8e-13) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.8e-13: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.8e-13) 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 <= -2.8e-13) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.8e-13], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.8 \cdot 10^{-13}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.8000000000000002e-13Initial program 90.0%
associate--l+90.0%
distribute-lft-out--91.4%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 64.0%
if -2.8000000000000002e-13 < d2 Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.3%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 29.2%
Final simplification38.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- d4 (+ d1 d3))))
double code(double d1, double d2, double d3, double d4) {
return d1 * (d4 - (d1 + 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 * (d4 - (d1 + d3))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (d4 - (d1 + d3));
}
def code(d1, d2, d3, d4): return d1 * (d4 - (d1 + d3))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(d4 - Float64(d1 + d3))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (d4 - (d1 + d3)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(d4 - \left(d1 + d3\right)\right)
\end{array}
Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.6%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 75.1%
Final simplification75.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ d2 d4) d3)))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 + 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 + d4) - d3)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 + d4) - d3);
}
def code(d1, d2, d3, d4): return d1 * ((d2 + d4) - d3)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 + d4) - d3)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 + d4) - d3); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 + d4\right) - d3\right)
\end{array}
Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.6%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 82.2%
Final simplification82.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 89.8%
associate--l+89.8%
distribute-lft-out--90.6%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.8%
Final simplification32.8%
(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 2024066
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))