
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d4 d1) (- d2 d3))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d1) + (d2 - 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) + (d2 - d3))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d1) + (d2 - d3));
}
def code(d1, d2, d3, d4): return d1 * ((d4 - d1) + (d2 - d3))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 - d1) + Float64(d2 - d3))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 - d1) + (d2 - d3)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 - d1), $MachinePrecision] + N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 - d1\right) + \left(d2 - d3\right)\right)
\end{array}
Initial program 85.9%
associate--l+85.9%
+-commutative85.9%
distribute-rgt-out--89.0%
distribute-lft-out--90.6%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -7.2e+60)
(* d1 d2)
(if (or (<= d2 -1.9e-44) (and (not (<= d2 -2e-73)) (<= d2 -4.4e-268)))
(* d1 (- d3))
(* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.2e+60) {
tmp = d1 * d2;
} else if ((d2 <= -1.9e-44) || (!(d2 <= -2e-73) && (d2 <= -4.4e-268))) {
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 (d2 <= (-7.2d+60)) then
tmp = d1 * d2
else if ((d2 <= (-1.9d-44)) .or. (.not. (d2 <= (-2d-73))) .and. (d2 <= (-4.4d-268))) 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 (d2 <= -7.2e+60) {
tmp = d1 * d2;
} else if ((d2 <= -1.9e-44) || (!(d2 <= -2e-73) && (d2 <= -4.4e-268))) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -7.2e+60: tmp = d1 * d2 elif (d2 <= -1.9e-44) or (not (d2 <= -2e-73) and (d2 <= -4.4e-268)): tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -7.2e+60) tmp = Float64(d1 * d2); elseif ((d2 <= -1.9e-44) || (!(d2 <= -2e-73) && (d2 <= -4.4e-268))) 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 (d2 <= -7.2e+60) tmp = d1 * d2; elseif ((d2 <= -1.9e-44) || (~((d2 <= -2e-73)) && (d2 <= -4.4e-268))) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -7.2e+60], N[(d1 * d2), $MachinePrecision], If[Or[LessEqual[d2, -1.9e-44], And[N[Not[LessEqual[d2, -2e-73]], $MachinePrecision], LessEqual[d2, -4.4e-268]]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -7.2 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -1.9 \cdot 10^{-44} \lor \neg \left(d2 \leq -2 \cdot 10^{-73}\right) \land d2 \leq -4.4 \cdot 10^{-268}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -7.19999999999999935e60Initial program 77.8%
associate--l+77.8%
+-commutative77.8%
distribute-rgt-out--77.8%
distribute-lft-out--84.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 65.6%
if -7.19999999999999935e60 < d2 < -1.9e-44 or -1.99999999999999999e-73 < d2 < -4.40000000000000008e-268Initial program 92.1%
associate--l+92.1%
+-commutative92.1%
distribute-rgt-out--96.0%
distribute-lft-out--96.0%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around inf 43.8%
associate-*r*43.8%
neg-mul-143.8%
Simplified43.8%
if -1.9e-44 < d2 < -1.99999999999999999e-73 or -4.40000000000000008e-268 < d2 Initial program 86.2%
associate--l+86.2%
+-commutative86.2%
distribute-rgt-out--90.0%
distribute-lft-out--90.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 31.0%
Final simplification39.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -5.1e+44)
(* d1 (- d2 d3))
(if (or (<= d2 -2.25e-87) (not (<= d2 -7.8e-266)))
(* d1 (- d4 d1))
(* d1 (- d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.1e+44) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -2.25e-87) || !(d2 <= -7.8e-266)) {
tmp = d1 * (d4 - d1);
} 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 <= (-5.1d+44)) then
tmp = d1 * (d2 - d3)
else if ((d2 <= (-2.25d-87)) .or. (.not. (d2 <= (-7.8d-266)))) then
tmp = d1 * (d4 - d1)
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 <= -5.1e+44) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -2.25e-87) || !(d2 <= -7.8e-266)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * -d3;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.1e+44: tmp = d1 * (d2 - d3) elif (d2 <= -2.25e-87) or not (d2 <= -7.8e-266): tmp = d1 * (d4 - d1) else: tmp = d1 * -d3 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.1e+44) tmp = Float64(d1 * Float64(d2 - d3)); elseif ((d2 <= -2.25e-87) || !(d2 <= -7.8e-266)) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(-d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5.1e+44) tmp = d1 * (d2 - d3); elseif ((d2 <= -2.25e-87) || ~((d2 <= -7.8e-266))) tmp = d1 * (d4 - d1); else tmp = d1 * -d3; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.1e+44], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -2.25e-87], N[Not[LessEqual[d2, -7.8e-266]], $MachinePrecision]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * (-d3)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.1 \cdot 10^{+44}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -2.25 \cdot 10^{-87} \lor \neg \left(d2 \leq -7.8 \cdot 10^{-266}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\end{array}
\end{array}
if d2 < -5.1e44Initial program 79.6%
associate--l+79.6%
+-commutative79.6%
distribute-rgt-out--79.6%
distribute-lft-out--85.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.3%
+-commutative84.3%
associate--r+84.3%
Simplified84.3%
Taylor expanded in d1 around 0 71.2%
if -5.1e44 < d2 < -2.24999999999999979e-87 or -7.80000000000000057e-266 < d2 Initial program 86.1%
associate--l+86.1%
+-commutative86.1%
distribute-rgt-out--90.5%
distribute-lft-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 94.4%
Taylor expanded in d3 around 0 70.4%
Taylor expanded in d2 around 0 52.3%
+-commutative52.3%
mul-1-neg52.3%
unpow252.3%
distribute-rgt-neg-out52.3%
distribute-lft-in57.3%
sub-neg57.3%
Simplified57.3%
if -2.24999999999999979e-87 < d2 < -7.80000000000000057e-266Initial program 96.2%
associate--l+96.2%
+-commutative96.2%
distribute-rgt-out--96.2%
distribute-lft-out--96.2%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around inf 50.9%
associate-*r*50.9%
neg-mul-150.9%
Simplified50.9%
Final simplification59.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.5e+44)
(* d1 (- d2 d3))
(if (or (<= d2 -2.25e-85) (not (<= d2 -2e-268)))
(* d1 (- d4 d1))
(* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.5e+44) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -2.25e-85) || !(d2 <= -2e-268)) {
tmp = d1 * (d4 - 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 (d2 <= (-1.5d+44)) then
tmp = d1 * (d2 - d3)
else if ((d2 <= (-2.25d-85)) .or. (.not. (d2 <= (-2d-268)))) then
tmp = d1 * (d4 - 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 (d2 <= -1.5e+44) {
tmp = d1 * (d2 - d3);
} else if ((d2 <= -2.25e-85) || !(d2 <= -2e-268)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.5e+44: tmp = d1 * (d2 - d3) elif (d2 <= -2.25e-85) or not (d2 <= -2e-268): tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.5e+44) tmp = Float64(d1 * Float64(d2 - d3)); elseif ((d2 <= -2.25e-85) || !(d2 <= -2e-268)) tmp = Float64(d1 * Float64(d4 - d1)); 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.5e+44) tmp = d1 * (d2 - d3); elseif ((d2 <= -2.25e-85) || ~((d2 <= -2e-268))) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.5e+44], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, -2.25e-85], N[Not[LessEqual[d2, -2e-268]], $MachinePrecision]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.5 \cdot 10^{+44}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -2.25 \cdot 10^{-85} \lor \neg \left(d2 \leq -2 \cdot 10^{-268}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.49999999999999993e44Initial program 79.6%
associate--l+79.6%
+-commutative79.6%
distribute-rgt-out--79.6%
distribute-lft-out--85.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.3%
+-commutative84.3%
associate--r+84.3%
Simplified84.3%
Taylor expanded in d1 around 0 71.2%
if -1.49999999999999993e44 < d2 < -2.25000000000000002e-85 or -1.99999999999999992e-268 < d2 Initial program 86.1%
associate--l+86.1%
+-commutative86.1%
distribute-rgt-out--90.5%
distribute-lft-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 94.4%
Taylor expanded in d3 around 0 70.4%
Taylor expanded in d2 around 0 52.3%
+-commutative52.3%
mul-1-neg52.3%
unpow252.3%
distribute-rgt-neg-out52.3%
distribute-lft-in57.3%
sub-neg57.3%
Simplified57.3%
if -2.25000000000000002e-85 < d2 < -1.99999999999999992e-268Initial program 96.2%
associate--l+96.2%
+-commutative96.2%
distribute-rgt-out--96.2%
distribute-lft-out--96.2%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 89.2%
Taylor expanded in d2 around 0 89.2%
Final simplification63.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 7.1e-280)
(* d1 (- d2 d1))
(if (<= d4 1.15e-96)
(* (- d1) (+ d1 d3))
(if (<= d4 7e+41) (* d1 (- d2 d3)) (* d1 (- d4 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 7.1e-280) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 1.15e-96) {
tmp = -d1 * (d1 + d3);
} else if (d4 <= 7e+41) {
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 (d4 <= 7.1d-280) then
tmp = d1 * (d2 - d1)
else if (d4 <= 1.15d-96) then
tmp = -d1 * (d1 + d3)
else if (d4 <= 7d+41) 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 (d4 <= 7.1e-280) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 1.15e-96) {
tmp = -d1 * (d1 + d3);
} else if (d4 <= 7e+41) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 7.1e-280: tmp = d1 * (d2 - d1) elif d4 <= 1.15e-96: tmp = -d1 * (d1 + d3) elif d4 <= 7e+41: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 7.1e-280) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 1.15e-96) tmp = Float64(Float64(-d1) * Float64(d1 + d3)); elseif (d4 <= 7e+41) 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 (d4 <= 7.1e-280) tmp = d1 * (d2 - d1); elseif (d4 <= 1.15e-96) tmp = -d1 * (d1 + d3); elseif (d4 <= 7e+41) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 7.1e-280], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.15e-96], N[((-d1) * N[(d1 + d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 7e+41], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 7.1 \cdot 10^{-280}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 1.15 \cdot 10^{-96}:\\
\;\;\;\;\left(-d1\right) \cdot \left(d1 + d3\right)\\
\mathbf{elif}\;d4 \leq 7 \cdot 10^{+41}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 7.09999999999999955e-280Initial program 84.5%
associate--l+84.5%
+-commutative84.5%
distribute-rgt-out--88.5%
distribute-lft-out--91.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 77.9%
+-commutative77.9%
associate--r+77.9%
Simplified77.9%
Taylor expanded in d3 around 0 54.5%
if 7.09999999999999955e-280 < d4 < 1.15e-96Initial program 94.4%
associate--l+94.4%
+-commutative94.4%
distribute-rgt-out--94.4%
distribute-lft-out--94.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d2 around 0 79.7%
mul-1-neg79.7%
+-commutative79.7%
distribute-rgt-neg-out79.7%
distribute-neg-in79.7%
+-commutative79.7%
sub-neg79.7%
Simplified79.7%
if 1.15e-96 < d4 < 6.9999999999999998e41Initial program 83.9%
associate--l+83.9%
+-commutative83.9%
distribute-rgt-out--83.9%
distribute-lft-out--83.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 89.2%
+-commutative89.2%
associate--r+89.2%
Simplified89.2%
Taylor expanded in d1 around 0 77.4%
if 6.9999999999999998e41 < d4 Initial program 85.0%
associate--l+85.0%
+-commutative85.0%
distribute-rgt-out--89.2%
distribute-lft-out--89.2%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 93.9%
Taylor expanded in d2 around 0 77.0%
Final simplification64.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -2.8e+60) (* d1 (- d2 d1)) (if (<= d1 2.45e+120) (* d1 (- (+ d4 d2) d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -2.8e+60) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 2.45e+120) {
tmp = d1 * ((d4 + 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 (d1 <= (-2.8d+60)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 2.45d+120) then
tmp = d1 * ((d4 + 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 (d1 <= -2.8e+60) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 2.45e+120) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -2.8e+60: tmp = d1 * (d2 - d1) elif d1 <= 2.45e+120: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -2.8e+60) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 2.45e+120) tmp = Float64(d1 * Float64(Float64(d4 + 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 (d1 <= -2.8e+60) tmp = d1 * (d2 - d1); elseif (d1 <= 2.45e+120) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -2.8e+60], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 2.45e+120], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -2.8 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 2.45 \cdot 10^{+120}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -2.8e60Initial program 61.2%
associate--l+61.2%
+-commutative61.2%
distribute-rgt-out--73.4%
distribute-lft-out--73.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 90.6%
+-commutative90.6%
associate--r+90.6%
Simplified90.6%
Taylor expanded in d3 around 0 87.9%
if -2.8e60 < d1 < 2.45000000000000005e120Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
distribute-rgt-out--99.9%
distribute-lft-out--99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 93.4%
if 2.45000000000000005e120 < d1 Initial program 61.4%
associate--l+61.4%
+-commutative61.4%
distribute-rgt-out--65.9%
distribute-lft-out--75.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 93.2%
Taylor expanded in d3 around 0 86.6%
Taylor expanded in d2 around 0 80.1%
+-commutative80.1%
mul-1-neg80.1%
unpow280.1%
distribute-rgt-neg-out80.1%
distribute-lft-in84.6%
sub-neg84.6%
Simplified84.6%
Final simplification90.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.2e+91) (not (<= d3 3e+192))) (* d1 (- d3)) (* d1 (- d2 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.2e+91) || !(d3 <= 3e+192)) {
tmp = d1 * -d3;
} 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 ((d3 <= (-1.2d+91)) .or. (.not. (d3 <= 3d+192))) then
tmp = d1 * -d3
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 ((d3 <= -1.2e+91) || !(d3 <= 3e+192)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.2e+91) or not (d3 <= 3e+192): tmp = d1 * -d3 else: tmp = d1 * (d2 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.2e+91) || !(d3 <= 3e+192)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.2e+91) || ~((d3 <= 3e+192))) tmp = d1 * -d3; else tmp = d1 * (d2 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.2e+91], N[Not[LessEqual[d3, 3e+192]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.2 \cdot 10^{+91} \lor \neg \left(d3 \leq 3 \cdot 10^{+192}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\end{array}
\end{array}
if d3 < -1.19999999999999991e91 or 3e192 < d3 Initial program 79.7%
associate--l+79.7%
+-commutative79.7%
distribute-rgt-out--81.2%
distribute-lft-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 80.4%
associate-*r*80.4%
neg-mul-180.4%
Simplified80.4%
if -1.19999999999999991e91 < d3 < 3e192Initial program 88.0%
associate--l+88.0%
+-commutative88.0%
distribute-rgt-out--91.6%
distribute-lft-out--91.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 71.7%
+-commutative71.7%
associate--r+71.7%
Simplified71.7%
Taylor expanded in d3 around 0 61.9%
Final simplification66.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -6.9e-15) (not (<= d3 4.5e+42))) (* d1 (- d2 d3)) (* d1 (- d2 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -6.9e-15) || !(d3 <= 4.5e+42)) {
tmp = d1 * (d2 - d3);
} 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 ((d3 <= (-6.9d-15)) .or. (.not. (d3 <= 4.5d+42))) then
tmp = d1 * (d2 - d3)
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 ((d3 <= -6.9e-15) || !(d3 <= 4.5e+42)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -6.9e-15) or not (d3 <= 4.5e+42): tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -6.9e-15) || !(d3 <= 4.5e+42)) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d2 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -6.9e-15) || ~((d3 <= 4.5e+42))) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -6.9e-15], N[Not[LessEqual[d3, 4.5e+42]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -6.9 \cdot 10^{-15} \lor \neg \left(d3 \leq 4.5 \cdot 10^{+42}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\end{array}
\end{array}
if d3 < -6.9000000000000001e-15 or 4.50000000000000012e42 < d3 Initial program 82.8%
associate--l+82.8%
+-commutative82.8%
distribute-rgt-out--84.3%
distribute-lft-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 86.2%
+-commutative86.2%
associate--r+86.2%
Simplified86.2%
Taylor expanded in d1 around 0 72.1%
if -6.9000000000000001e-15 < d3 < 4.50000000000000012e42Initial program 89.1%
associate--l+89.1%
+-commutative89.1%
distribute-rgt-out--93.7%
distribute-lft-out--93.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 69.9%
+-commutative69.9%
associate--r+69.9%
Simplified69.9%
Taylor expanded in d3 around 0 67.6%
Final simplification69.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 5.1e-45) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d4 d2) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 5.1e-45) {
tmp = d1 * ((d2 - d3) - 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 (d4 <= 5.1d-45) then
tmp = d1 * ((d2 - d3) - 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 (d4 <= 5.1e-45) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 + d2) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 5.1e-45: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 + d2) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 5.1e-45) tmp = Float64(d1 * Float64(Float64(d2 - d3) - 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 (d4 <= 5.1e-45) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 + d2) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 5.1e-45], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 5.1 \cdot 10^{-45}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 5.0999999999999997e-45Initial program 86.7%
associate--l+86.7%
+-commutative86.7%
distribute-rgt-out--89.7%
distribute-lft-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.8%
+-commutative82.8%
associate--r+82.8%
Simplified82.8%
if 5.0999999999999997e-45 < d4 Initial program 83.5%
associate--l+83.5%
+-commutative83.5%
distribute-rgt-out--86.8%
distribute-lft-out--86.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 95.3%
Final simplification85.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.7e-28) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d1) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.7e-28) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.7d-28)) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d4 - d1) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.7e-28) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.7e-28: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d1) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.7e-28) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 - d1) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.7e-28) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d1) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.7e-28], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.7 \cdot 10^{-28}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d2 < -2.6999999999999999e-28Initial program 81.6%
associate--l+81.6%
+-commutative81.6%
distribute-rgt-out--81.6%
distribute-lft-out--86.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.3%
+-commutative82.3%
associate--r+82.3%
Simplified82.3%
if -2.6999999999999999e-28 < d2 Initial program 87.2%
associate--l+87.2%
+-commutative87.2%
distribute-rgt-out--91.3%
distribute-lft-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 82.6%
associate--r+82.6%
Simplified82.6%
Final simplification82.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4.2e+44) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.2e+44) {
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 <= (-4.2d+44)) 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 <= -4.2e+44) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.2e+44: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.2e+44) 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 <= -4.2e+44) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4.2e+44], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4.2 \cdot 10^{+44}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -4.19999999999999974e44Initial program 79.6%
associate--l+79.6%
+-commutative79.6%
distribute-rgt-out--79.6%
distribute-lft-out--85.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 62.5%
if -4.19999999999999974e44 < d2 Initial program 87.4%
associate--l+87.4%
+-commutative87.4%
distribute-rgt-out--91.3%
distribute-lft-out--91.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 31.9%
Final simplification37.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 85.9%
associate--l+85.9%
+-commutative85.9%
distribute-rgt-out--89.0%
distribute-lft-out--90.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 29.8%
Final simplification29.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 2024010
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:herbie-target
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))