
(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 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.4%
associate--l+89.4%
distribute-lft-out--89.8%
distribute-rgt-out--95.3%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (- (* d1 d3))) (t_1 (* d1 (- d1))) (t_2 (* d1 (+ d2 d4))))
(if (<= d1 -2.2e+125)
t_1
(if (<= d1 -5.8e-63)
t_2
(if (<= d1 -1.5e-79)
t_0
(if (<= d1 4.7e-130)
t_2
(if (<= d1 4.2e-47) t_0 (if (<= d1 3.5e+178) t_2 t_1))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * -d1;
double t_2 = d1 * (d2 + d4);
double tmp;
if (d1 <= -2.2e+125) {
tmp = t_1;
} else if (d1 <= -5.8e-63) {
tmp = t_2;
} else if (d1 <= -1.5e-79) {
tmp = t_0;
} else if (d1 <= 4.7e-130) {
tmp = t_2;
} else if (d1 <= 4.2e-47) {
tmp = t_0;
} else if (d1 <= 3.5e+178) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = -(d1 * d3)
t_1 = d1 * -d1
t_2 = d1 * (d2 + d4)
if (d1 <= (-2.2d+125)) then
tmp = t_1
else if (d1 <= (-5.8d-63)) then
tmp = t_2
else if (d1 <= (-1.5d-79)) then
tmp = t_0
else if (d1 <= 4.7d-130) then
tmp = t_2
else if (d1 <= 4.2d-47) then
tmp = t_0
else if (d1 <= 3.5d+178) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * -d1;
double t_2 = d1 * (d2 + d4);
double tmp;
if (d1 <= -2.2e+125) {
tmp = t_1;
} else if (d1 <= -5.8e-63) {
tmp = t_2;
} else if (d1 <= -1.5e-79) {
tmp = t_0;
} else if (d1 <= 4.7e-130) {
tmp = t_2;
} else if (d1 <= 4.2e-47) {
tmp = t_0;
} else if (d1 <= 3.5e+178) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = -(d1 * d3) t_1 = d1 * -d1 t_2 = d1 * (d2 + d4) tmp = 0 if d1 <= -2.2e+125: tmp = t_1 elif d1 <= -5.8e-63: tmp = t_2 elif d1 <= -1.5e-79: tmp = t_0 elif d1 <= 4.7e-130: tmp = t_2 elif d1 <= 4.2e-47: tmp = t_0 elif d1 <= 3.5e+178: tmp = t_2 else: tmp = t_1 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) t_1 = Float64(d1 * Float64(-d1)) t_2 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d1 <= -2.2e+125) tmp = t_1; elseif (d1 <= -5.8e-63) tmp = t_2; elseif (d1 <= -1.5e-79) tmp = t_0; elseif (d1 <= 4.7e-130) tmp = t_2; elseif (d1 <= 4.2e-47) tmp = t_0; elseif (d1 <= 3.5e+178) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = -(d1 * d3); t_1 = d1 * -d1; t_2 = d1 * (d2 + d4); tmp = 0.0; if (d1 <= -2.2e+125) tmp = t_1; elseif (d1 <= -5.8e-63) tmp = t_2; elseif (d1 <= -1.5e-79) tmp = t_0; elseif (d1 <= 4.7e-130) tmp = t_2; elseif (d1 <= 4.2e-47) tmp = t_0; elseif (d1 <= 3.5e+178) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = (-N[(d1 * d3), $MachinePrecision])}, Block[{t$95$1 = N[(d1 * (-d1)), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -2.2e+125], t$95$1, If[LessEqual[d1, -5.8e-63], t$95$2, If[LessEqual[d1, -1.5e-79], t$95$0, If[LessEqual[d1, 4.7e-130], t$95$2, If[LessEqual[d1, 4.2e-47], t$95$0, If[LessEqual[d1, 3.5e+178], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
t_1 := d1 \cdot \left(-d1\right)\\
t_2 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d1 \leq -2.2 \cdot 10^{+125}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d1 \leq -5.8 \cdot 10^{-63}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d1 \leq -1.5 \cdot 10^{-79}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 4.7 \cdot 10^{-130}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d1 \leq 4.2 \cdot 10^{-47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 3.5 \cdot 10^{+178}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d1 < -2.19999999999999991e125 or 3.5e178 < d1 Initial program 63.6%
associate--l+63.6%
distribute-lft-out--65.1%
distribute-rgt-out--83.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 85.0%
unpow285.0%
mul-1-neg85.0%
distribute-rgt-neg-out85.0%
Simplified85.0%
if -2.19999999999999991e125 < d1 < -5.7999999999999995e-63 or -1.5e-79 < d1 < 4.69999999999999968e-130 or 4.2000000000000001e-47 < d1 < 3.5e178Initial program 98.2%
associate--l+98.2%
distribute-lft-out--98.2%
distribute-rgt-out--99.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 77.6%
Taylor expanded in d1 around 0 67.1%
if -5.7999999999999995e-63 < d1 < -1.5e-79 or 4.69999999999999968e-130 < d1 < 4.2000000000000001e-47Initial program 99.9%
associate--l+99.9%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 72.8%
mul-1-neg72.8%
distribute-rgt-neg-out72.8%
Simplified72.8%
Final simplification72.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (- (* d1 d3))) (t_1 (* d1 (- d1))))
(if (<= d2 -1.45e+88)
(* d1 d2)
(if (<= d2 -5.6e-104)
t_1
(if (<= d2 -8.2e-272)
t_0
(if (<= d2 6e-251) t_1 (if (<= d2 2.75e-188) t_0 (* d1 d4))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * -d1;
double tmp;
if (d2 <= -1.45e+88) {
tmp = d1 * d2;
} else if (d2 <= -5.6e-104) {
tmp = t_1;
} else if (d2 <= -8.2e-272) {
tmp = t_0;
} else if (d2 <= 6e-251) {
tmp = t_1;
} else if (d2 <= 2.75e-188) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -(d1 * d3)
t_1 = d1 * -d1
if (d2 <= (-1.45d+88)) then
tmp = d1 * d2
else if (d2 <= (-5.6d-104)) then
tmp = t_1
else if (d2 <= (-8.2d-272)) then
tmp = t_0
else if (d2 <= 6d-251) then
tmp = t_1
else if (d2 <= 2.75d-188) then
tmp = t_0
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = -(d1 * d3);
double t_1 = d1 * -d1;
double tmp;
if (d2 <= -1.45e+88) {
tmp = d1 * d2;
} else if (d2 <= -5.6e-104) {
tmp = t_1;
} else if (d2 <= -8.2e-272) {
tmp = t_0;
} else if (d2 <= 6e-251) {
tmp = t_1;
} else if (d2 <= 2.75e-188) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = -(d1 * d3) t_1 = d1 * -d1 tmp = 0 if d2 <= -1.45e+88: tmp = d1 * d2 elif d2 <= -5.6e-104: tmp = t_1 elif d2 <= -8.2e-272: tmp = t_0 elif d2 <= 6e-251: tmp = t_1 elif d2 <= 2.75e-188: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(-Float64(d1 * d3)) t_1 = Float64(d1 * Float64(-d1)) tmp = 0.0 if (d2 <= -1.45e+88) tmp = Float64(d1 * d2); elseif (d2 <= -5.6e-104) tmp = t_1; elseif (d2 <= -8.2e-272) tmp = t_0; elseif (d2 <= 6e-251) tmp = t_1; elseif (d2 <= 2.75e-188) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = -(d1 * d3); t_1 = d1 * -d1; tmp = 0.0; if (d2 <= -1.45e+88) tmp = d1 * d2; elseif (d2 <= -5.6e-104) tmp = t_1; elseif (d2 <= -8.2e-272) tmp = t_0; elseif (d2 <= 6e-251) tmp = t_1; elseif (d2 <= 2.75e-188) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = (-N[(d1 * d3), $MachinePrecision])}, Block[{t$95$1 = N[(d1 * (-d1)), $MachinePrecision]}, If[LessEqual[d2, -1.45e+88], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -5.6e-104], t$95$1, If[LessEqual[d2, -8.2e-272], t$95$0, If[LessEqual[d2, 6e-251], t$95$1, If[LessEqual[d2, 2.75e-188], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -d1 \cdot d3\\
t_1 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d2 \leq -1.45 \cdot 10^{+88}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -5.6 \cdot 10^{-104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d2 \leq -8.2 \cdot 10^{-272}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq 6 \cdot 10^{-251}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d2 \leq 2.75 \cdot 10^{-188}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.45e88Initial program 84.6%
associate--l+84.6%
distribute-lft-out--84.6%
distribute-rgt-out--88.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 65.6%
if -1.45e88 < d2 < -5.6e-104 or -8.1999999999999995e-272 < d2 < 5.9999999999999997e-251Initial program 86.7%
associate--l+86.7%
distribute-lft-out--86.7%
distribute-rgt-out--95.5%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around inf 47.1%
unpow247.1%
mul-1-neg47.1%
distribute-rgt-neg-out47.1%
Simplified47.1%
if -5.6e-104 < d2 < -8.1999999999999995e-272 or 5.9999999999999997e-251 < d2 < 2.7500000000000001e-188Initial program 90.1%
associate--l+90.1%
distribute-lft-out--90.1%
distribute-rgt-out--99.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 43.7%
mul-1-neg43.7%
distribute-rgt-neg-out43.7%
Simplified43.7%
if 2.7500000000000001e-188 < d2 Initial program 92.5%
associate--l+92.5%
distribute-lft-out--93.5%
distribute-rgt-out--96.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 21.9%
Final simplification39.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 2.6e-203)
(* d1 (- d2 d1))
(if (or (<= d4 2.4e-38) (and (not (<= d4 420000000.0)) (<= d4 1.5e+71)))
(* (+ d1 d3) (- d1))
(* d1 (+ d2 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.6e-203) {
tmp = d1 * (d2 - d1);
} else if ((d4 <= 2.4e-38) || (!(d4 <= 420000000.0) && (d4 <= 1.5e+71))) {
tmp = (d1 + 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 (d4 <= 2.6d-203) then
tmp = d1 * (d2 - d1)
else if ((d4 <= 2.4d-38) .or. (.not. (d4 <= 420000000.0d0)) .and. (d4 <= 1.5d+71)) then
tmp = (d1 + 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 (d4 <= 2.6e-203) {
tmp = d1 * (d2 - d1);
} else if ((d4 <= 2.4e-38) || (!(d4 <= 420000000.0) && (d4 <= 1.5e+71))) {
tmp = (d1 + d3) * -d1;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.6e-203: tmp = d1 * (d2 - d1) elif (d4 <= 2.4e-38) or (not (d4 <= 420000000.0) and (d4 <= 1.5e+71)): tmp = (d1 + d3) * -d1 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.6e-203) tmp = Float64(d1 * Float64(d2 - d1)); elseif ((d4 <= 2.4e-38) || (!(d4 <= 420000000.0) && (d4 <= 1.5e+71))) tmp = Float64(Float64(d1 + 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 (d4 <= 2.6e-203) tmp = d1 * (d2 - d1); elseif ((d4 <= 2.4e-38) || (~((d4 <= 420000000.0)) && (d4 <= 1.5e+71))) tmp = (d1 + d3) * -d1; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.6e-203], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d4, 2.4e-38], And[N[Not[LessEqual[d4, 420000000.0]], $MachinePrecision], LessEqual[d4, 1.5e+71]]], N[(N[(d1 + d3), $MachinePrecision] * (-d1)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.6 \cdot 10^{-203}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 2.4 \cdot 10^{-38} \lor \neg \left(d4 \leq 420000000\right) \land d4 \leq 1.5 \cdot 10^{+71}:\\
\;\;\;\;\left(d1 + d3\right) \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 2.59999999999999975e-203Initial program 89.5%
associate--l+89.5%
distribute-lft-out--90.1%
distribute-rgt-out--95.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.2%
Taylor expanded in d4 around 0 60.4%
if 2.59999999999999975e-203 < d4 < 2.40000000000000022e-38 or 4.2e8 < d4 < 1.50000000000000006e71Initial program 94.2%
associate--l+94.2%
distribute-lft-out--94.2%
distribute-rgt-out--96.1%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around 0 65.6%
Taylor expanded in d4 around 0 64.7%
mul-1-neg64.7%
distribute-rgt-neg-in64.7%
Simplified64.7%
if 2.40000000000000022e-38 < d4 < 4.2e8 or 1.50000000000000006e71 < d4 Initial program 84.3%
associate--l+84.3%
distribute-lft-out--84.3%
distribute-rgt-out--94.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 90.1%
Taylor expanded in d1 around 0 80.4%
Final simplification65.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.42e+88)
(* d1 d2)
(if (or (<= d2 -1.3e-116) (and (not (<= d2 -8e-256)) (<= d2 7.5e-251)))
(* d1 (- d1))
(* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.42e+88) {
tmp = d1 * d2;
} else if ((d2 <= -1.3e-116) || (!(d2 <= -8e-256) && (d2 <= 7.5e-251))) {
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 <= (-1.42d+88)) then
tmp = d1 * d2
else if ((d2 <= (-1.3d-116)) .or. (.not. (d2 <= (-8d-256))) .and. (d2 <= 7.5d-251)) 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 <= -1.42e+88) {
tmp = d1 * d2;
} else if ((d2 <= -1.3e-116) || (!(d2 <= -8e-256) && (d2 <= 7.5e-251))) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.42e+88: tmp = d1 * d2 elif (d2 <= -1.3e-116) or (not (d2 <= -8e-256) and (d2 <= 7.5e-251)): tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.42e+88) tmp = Float64(d1 * d2); elseif ((d2 <= -1.3e-116) || (!(d2 <= -8e-256) && (d2 <= 7.5e-251))) 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 <= -1.42e+88) tmp = d1 * d2; elseif ((d2 <= -1.3e-116) || (~((d2 <= -8e-256)) && (d2 <= 7.5e-251))) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.42e+88], N[(d1 * d2), $MachinePrecision], If[Or[LessEqual[d2, -1.3e-116], And[N[Not[LessEqual[d2, -8e-256]], $MachinePrecision], LessEqual[d2, 7.5e-251]]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.42 \cdot 10^{+88}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -1.3 \cdot 10^{-116} \lor \neg \left(d2 \leq -8 \cdot 10^{-256}\right) \land d2 \leq 7.5 \cdot 10^{-251}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.41999999999999996e88Initial program 84.6%
associate--l+84.6%
distribute-lft-out--84.6%
distribute-rgt-out--88.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 65.6%
if -1.41999999999999996e88 < d2 < -1.3e-116 or -7.99999999999999982e-256 < d2 < 7.5000000000000004e-251Initial program 87.8%
associate--l+87.8%
distribute-lft-out--87.8%
distribute-rgt-out--95.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around inf 45.6%
unpow245.6%
mul-1-neg45.6%
distribute-rgt-neg-out45.6%
Simplified45.6%
if -1.3e-116 < d2 < -7.99999999999999982e-256 or 7.5000000000000004e-251 < d2 Initial program 91.6%
associate--l+91.6%
distribute-lft-out--92.2%
distribute-rgt-out--97.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 26.3%
Final simplification38.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -7.5e+153) (* d1 (+ d2 d4)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.5e+153) {
tmp = d1 * (d2 + d4);
} 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 <= (-7.5d+153)) then
tmp = d1 * (d2 + d4)
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 <= -7.5e+153) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -7.5e+153: tmp = d1 * (d2 + d4) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -7.5e+153) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -7.5e+153) tmp = d1 * (d2 + d4); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -7.5e+153], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -7.5 \cdot 10^{+153}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -7.50000000000000065e153Initial program 88.9%
associate--l+88.9%
distribute-lft-out--88.9%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.4%
Taylor expanded in d1 around 0 91.8%
if -7.50000000000000065e153 < d2 Initial program 89.5%
associate--l+89.5%
distribute-lft-out--90.0%
distribute-rgt-out--96.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 79.4%
Final simplification81.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.7e+148) (* d1 (- (+ d2 d4) d1)) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.7e+148) {
tmp = d1 * ((d2 + d4) - 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+148)) then
tmp = d1 * ((d2 + d4) - 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+148) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.7e+148: tmp = d1 * ((d2 + d4) - d1) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.7e+148) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.7e+148) tmp = d1 * ((d2 + d4) - d1); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.7e+148], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.7 \cdot 10^{+148}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -2.70000000000000019e148Initial program 88.9%
associate--l+88.9%
distribute-lft-out--88.9%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 97.4%
if -2.70000000000000019e148 < d2 Initial program 89.5%
associate--l+89.5%
distribute-lft-out--90.0%
distribute-rgt-out--96.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 79.4%
Final simplification82.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -9.2e+97) (* d1 (+ d2 d4)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -9.2e+97) {
tmp = d1 * (d2 + d4);
} 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 <= (-9.2d+97)) then
tmp = d1 * (d2 + d4)
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 <= -9.2e+97) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -9.2e+97: tmp = d1 * (d2 + d4) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -9.2e+97) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -9.2e+97) tmp = d1 * (d2 + d4); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -9.2e+97], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -9.2 \cdot 10^{+97}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -9.20000000000000022e97Initial program 85.1%
associate--l+85.1%
distribute-lft-out--85.1%
distribute-rgt-out--89.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 87.9%
Taylor expanded in d1 around 0 81.5%
if -9.20000000000000022e97 < d2 Initial program 90.4%
associate--l+90.4%
distribute-lft-out--90.9%
distribute-rgt-out--96.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 79.4%
Taylor expanded in d3 around 0 56.5%
Final simplification61.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.2e+53) (* d1 (- d2 d1)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.2e+53) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3.2d+53)) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.2e+53) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.2e+53: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.2e+53) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.2e+53) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.2e+53], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.2 \cdot 10^{+53}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -3.2e53Initial program 86.2%
associate--l+86.2%
distribute-lft-out--86.2%
distribute-rgt-out--89.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 85.1%
Taylor expanded in d4 around 0 67.3%
if -3.2e53 < d2 Initial program 90.4%
associate--l+90.4%
distribute-lft-out--90.9%
distribute-rgt-out--96.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 79.6%
Taylor expanded in d3 around 0 56.9%
Final simplification59.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.5e+55) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+55) {
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.5d+55)) 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.5e+55) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.5e+55: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.5e+55) 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.5e+55) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.5e+55], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.5 \cdot 10^{+55}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -2.50000000000000023e55Initial program 86.2%
associate--l+86.2%
distribute-lft-out--86.2%
distribute-rgt-out--89.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 59.2%
if -2.50000000000000023e55 < d2 Initial program 90.4%
associate--l+90.4%
distribute-lft-out--90.9%
distribute-rgt-out--96.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 29.4%
Final simplification36.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d4))
double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
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
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
def code(d1, d2, d3, d4): return d1 * d4
function code(d1, d2, d3, d4) return Float64(d1 * d4) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d4; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d4), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d4
\end{array}
Initial program 89.4%
associate--l+89.4%
distribute-lft-out--89.8%
distribute-rgt-out--95.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 28.0%
Final simplification28.0%
(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 2023227
(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)))