
(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 88.6%
associate--l+88.6%
distribute-lft-out--90.2%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d4 -5.8e-297)
t_0
(if (<= d4 4.5e-251)
(* d1 (- d2 d3))
(if (<= d4 8e-144)
t_0
(if (or (<= d4 5.6e-50) (and (not (<= d4 1.8e-35)) (<= d4 1.02e+111)))
(* d1 (- (+ d1 d3)))
(* d1 (+ d2 d4))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= -5.8e-297) {
tmp = t_0;
} else if (d4 <= 4.5e-251) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 8e-144) {
tmp = t_0;
} else if ((d4 <= 5.6e-50) || (!(d4 <= 1.8e-35) && (d4 <= 1.02e+111))) {
tmp = d1 * -(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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d4 <= (-5.8d-297)) then
tmp = t_0
else if (d4 <= 4.5d-251) then
tmp = d1 * (d2 - d3)
else if (d4 <= 8d-144) then
tmp = t_0
else if ((d4 <= 5.6d-50) .or. (.not. (d4 <= 1.8d-35)) .and. (d4 <= 1.02d+111)) then
tmp = d1 * -(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 t_0 = d1 * (d2 - d1);
double tmp;
if (d4 <= -5.8e-297) {
tmp = t_0;
} else if (d4 <= 4.5e-251) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 8e-144) {
tmp = t_0;
} else if ((d4 <= 5.6e-50) || (!(d4 <= 1.8e-35) && (d4 <= 1.02e+111))) {
tmp = d1 * -(d1 + d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d4 <= -5.8e-297: tmp = t_0 elif d4 <= 4.5e-251: tmp = d1 * (d2 - d3) elif d4 <= 8e-144: tmp = t_0 elif (d4 <= 5.6e-50) or (not (d4 <= 1.8e-35) and (d4 <= 1.02e+111)): tmp = d1 * -(d1 + d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d4 <= -5.8e-297) tmp = t_0; elseif (d4 <= 4.5e-251) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 8e-144) tmp = t_0; elseif ((d4 <= 5.6e-50) || (!(d4 <= 1.8e-35) && (d4 <= 1.02e+111))) tmp = Float64(d1 * Float64(-Float64(d1 + d3))); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); tmp = 0.0; if (d4 <= -5.8e-297) tmp = t_0; elseif (d4 <= 4.5e-251) tmp = d1 * (d2 - d3); elseif (d4 <= 8e-144) tmp = t_0; elseif ((d4 <= 5.6e-50) || (~((d4 <= 1.8e-35)) && (d4 <= 1.02e+111))) tmp = d1 * -(d1 + d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -5.8e-297], t$95$0, If[LessEqual[d4, 4.5e-251], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 8e-144], t$95$0, If[Or[LessEqual[d4, 5.6e-50], And[N[Not[LessEqual[d4, 1.8e-35]], $MachinePrecision], LessEqual[d4, 1.02e+111]]], N[(d1 * (-N[(d1 + d3), $MachinePrecision])), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d4 \leq -5.8 \cdot 10^{-297}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 4.5 \cdot 10^{-251}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 8 \cdot 10^{-144}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 5.6 \cdot 10^{-50} \lor \neg \left(d4 \leq 1.8 \cdot 10^{-35}\right) \land d4 \leq 1.02 \cdot 10^{+111}:\\
\;\;\;\;d1 \cdot \left(-\left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < -5.79999999999999979e-297 or 4.49999999999999978e-251 < d4 < 7.9999999999999996e-144Initial program 90.4%
associate--l+90.4%
distribute-lft-out--91.8%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 80.5%
Taylor expanded in d4 around 0 63.0%
if -5.79999999999999979e-297 < d4 < 4.49999999999999978e-251Initial program 94.4%
associate--l+94.4%
distribute-lft-out--94.4%
distribute-rgt-out--94.4%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 99.9%
Taylor expanded in d1 around 0 69.1%
if 7.9999999999999996e-144 < d4 < 5.5999999999999996e-50 or 1.80000000000000009e-35 < d4 < 1.02e111Initial program 89.2%
associate--l+89.2%
distribute-lft-out--91.9%
distribute-rgt-out--94.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.3%
Taylor expanded in d2 around 0 68.8%
neg-mul-168.8%
+-commutative68.8%
distribute-neg-in68.8%
sub-neg68.8%
Simplified68.8%
if 5.5999999999999996e-50 < d4 < 1.80000000000000009e-35 or 1.02e111 < d4 Initial program 81.5%
associate--l+81.5%
distribute-lft-out--83.3%
distribute-rgt-out--96.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 96.4%
Taylor expanded in d1 around 0 87.3%
Final simplification69.4%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d4 8.3e-293)
(* d1 d2)
(if (<= d4 8.8e-247)
t_0
(if (<= d4 5.5e-144)
(* d1 d2)
(if (<= d4 4.7e-95)
t_0
(if (<= d4 1.45e-34)
(* d1 d2)
(if (<= d4 9.8e+117) t_0 (* d1 d4)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d4 <= 8.3e-293) {
tmp = d1 * d2;
} else if (d4 <= 8.8e-247) {
tmp = t_0;
} else if (d4 <= 5.5e-144) {
tmp = d1 * d2;
} else if (d4 <= 4.7e-95) {
tmp = t_0;
} else if (d4 <= 1.45e-34) {
tmp = d1 * d2;
} else if (d4 <= 9.8e+117) {
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) :: tmp
t_0 = d1 * -d3
if (d4 <= 8.3d-293) then
tmp = d1 * d2
else if (d4 <= 8.8d-247) then
tmp = t_0
else if (d4 <= 5.5d-144) then
tmp = d1 * d2
else if (d4 <= 4.7d-95) then
tmp = t_0
else if (d4 <= 1.45d-34) then
tmp = d1 * d2
else if (d4 <= 9.8d+117) 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 tmp;
if (d4 <= 8.3e-293) {
tmp = d1 * d2;
} else if (d4 <= 8.8e-247) {
tmp = t_0;
} else if (d4 <= 5.5e-144) {
tmp = d1 * d2;
} else if (d4 <= 4.7e-95) {
tmp = t_0;
} else if (d4 <= 1.45e-34) {
tmp = d1 * d2;
} else if (d4 <= 9.8e+117) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d4 <= 8.3e-293: tmp = d1 * d2 elif d4 <= 8.8e-247: tmp = t_0 elif d4 <= 5.5e-144: tmp = d1 * d2 elif d4 <= 4.7e-95: tmp = t_0 elif d4 <= 1.45e-34: tmp = d1 * d2 elif d4 <= 9.8e+117: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d4 <= 8.3e-293) tmp = Float64(d1 * d2); elseif (d4 <= 8.8e-247) tmp = t_0; elseif (d4 <= 5.5e-144) tmp = Float64(d1 * d2); elseif (d4 <= 4.7e-95) tmp = t_0; elseif (d4 <= 1.45e-34) tmp = Float64(d1 * d2); elseif (d4 <= 9.8e+117) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; tmp = 0.0; if (d4 <= 8.3e-293) tmp = d1 * d2; elseif (d4 <= 8.8e-247) tmp = t_0; elseif (d4 <= 5.5e-144) tmp = d1 * d2; elseif (d4 <= 4.7e-95) tmp = t_0; elseif (d4 <= 1.45e-34) tmp = d1 * d2; elseif (d4 <= 9.8e+117) 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]}, If[LessEqual[d4, 8.3e-293], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 8.8e-247], t$95$0, If[LessEqual[d4, 5.5e-144], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.7e-95], t$95$0, If[LessEqual[d4, 1.45e-34], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 9.8e+117], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d4 \leq 8.3 \cdot 10^{-293}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 8.8 \cdot 10^{-247}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 5.5 \cdot 10^{-144}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.7 \cdot 10^{-95}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.45 \cdot 10^{-34}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 9.8 \cdot 10^{+117}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 8.29999999999999998e-293 or 8.79999999999999966e-247 < d4 < 5.49999999999999973e-144 or 4.6999999999999998e-95 < d4 < 1.4500000000000001e-34Initial program 91.2%
associate--l+91.2%
distribute-lft-out--92.4%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 41.3%
if 8.29999999999999998e-293 < d4 < 8.79999999999999966e-247 or 5.49999999999999973e-144 < d4 < 4.6999999999999998e-95 or 1.4500000000000001e-34 < d4 < 9.8000000000000002e117Initial program 89.8%
associate--l+89.8%
distribute-lft-out--91.8%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 46.5%
associate-*r*46.5%
neg-mul-146.5%
Simplified46.5%
if 9.8000000000000002e117 < d4 Initial program 79.2%
associate--l+79.2%
distribute-lft-out--81.3%
distribute-rgt-out--95.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 68.1%
Final simplification47.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- d2 d3))))
(if (<= d4 -2.4e-294)
t_0
(if (<= d4 5.5e-251)
t_1
(if (<= d4 1.5e-139)
t_0
(if (<= d4 1.45e+15)
t_1
(if (<= d4 1.95e+132) (* d1 (- d4 d1)) (* d1 (+ d2 d4)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= -2.4e-294) {
tmp = t_0;
} else if (d4 <= 5.5e-251) {
tmp = t_1;
} else if (d4 <= 1.5e-139) {
tmp = t_0;
} else if (d4 <= 1.45e+15) {
tmp = t_1;
} else if (d4 <= 1.95e+132) {
tmp = d1 * (d4 - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d1 * (d2 - d1)
t_1 = d1 * (d2 - d3)
if (d4 <= (-2.4d-294)) then
tmp = t_0
else if (d4 <= 5.5d-251) then
tmp = t_1
else if (d4 <= 1.5d-139) then
tmp = t_0
else if (d4 <= 1.45d+15) then
tmp = t_1
else if (d4 <= 1.95d+132) then
tmp = d1 * (d4 - 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 t_0 = d1 * (d2 - d1);
double t_1 = d1 * (d2 - d3);
double tmp;
if (d4 <= -2.4e-294) {
tmp = t_0;
} else if (d4 <= 5.5e-251) {
tmp = t_1;
} else if (d4 <= 1.5e-139) {
tmp = t_0;
} else if (d4 <= 1.45e+15) {
tmp = t_1;
} else if (d4 <= 1.95e+132) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (d2 - d3) tmp = 0 if d4 <= -2.4e-294: tmp = t_0 elif d4 <= 5.5e-251: tmp = t_1 elif d4 <= 1.5e-139: tmp = t_0 elif d4 <= 1.45e+15: tmp = t_1 elif d4 <= 1.95e+132: tmp = d1 * (d4 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= -2.4e-294) tmp = t_0; elseif (d4 <= 5.5e-251) tmp = t_1; elseif (d4 <= 1.5e-139) tmp = t_0; elseif (d4 <= 1.45e+15) tmp = t_1; elseif (d4 <= 1.95e+132) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); t_1 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= -2.4e-294) tmp = t_0; elseif (d4 <= 5.5e-251) tmp = t_1; elseif (d4 <= 1.5e-139) tmp = t_0; elseif (d4 <= 1.45e+15) tmp = t_1; elseif (d4 <= 1.95e+132) tmp = d1 * (d4 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -2.4e-294], t$95$0, If[LessEqual[d4, 5.5e-251], t$95$1, If[LessEqual[d4, 1.5e-139], t$95$0, If[LessEqual[d4, 1.45e+15], t$95$1, If[LessEqual[d4, 1.95e+132], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq -2.4 \cdot 10^{-294}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 5.5 \cdot 10^{-251}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 1.5 \cdot 10^{-139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.45 \cdot 10^{+15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d4 \leq 1.95 \cdot 10^{+132}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < -2.39999999999999997e-294 or 5.5e-251 < d4 < 1.5e-139Initial program 90.4%
associate--l+90.4%
distribute-lft-out--91.8%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 80.5%
Taylor expanded in d4 around 0 63.0%
if -2.39999999999999997e-294 < d4 < 5.5e-251 or 1.5e-139 < d4 < 1.45e15Initial program 91.1%
associate--l+91.1%
distribute-lft-out--93.3%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
Taylor expanded in d1 around 0 68.4%
if 1.45e15 < d4 < 1.95000000000000001e132Initial program 89.5%
associate--l+89.5%
distribute-lft-out--89.5%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in100.0%
Applied egg-rr100.0%
Taylor expanded in d3 around 0 85.1%
Taylor expanded in d2 around 0 54.8%
if 1.95000000000000001e132 < d4 Initial program 80.0%
associate--l+80.0%
distribute-lft-out--82.2%
distribute-rgt-out--95.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 95.7%
Taylor expanded in d1 around 0 89.1%
Final simplification67.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -4.3e+61) (not (<= d3 2.4e+110))) (* d1 (- d2 d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.3e+61) || !(d3 <= 2.4e+110)) {
tmp = d1 * (d2 - 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 <= (-4.3d+61)) .or. (.not. (d3 <= 2.4d+110))) then
tmp = d1 * (d2 - 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 <= -4.3e+61) || !(d3 <= 2.4e+110)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -4.3e+61) or not (d3 <= 2.4e+110): tmp = d1 * (d2 - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -4.3e+61) || !(d3 <= 2.4e+110)) tmp = Float64(d1 * Float64(d2 - 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 <= -4.3e+61) || ~((d3 <= 2.4e+110))) tmp = d1 * (d2 - d3); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -4.3e+61], N[Not[LessEqual[d3, 2.4e+110]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -4.3 \cdot 10^{+61} \lor \neg \left(d3 \leq 2.4 \cdot 10^{+110}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -4.3000000000000001e61 or 2.40000000000000012e110 < d3 Initial program 81.9%
associate--l+81.9%
distribute-lft-out--86.7%
distribute-rgt-out--89.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.3%
Taylor expanded in d1 around 0 72.3%
if -4.3000000000000001e61 < d3 < 2.40000000000000012e110Initial program 91.9%
associate--l+91.9%
distribute-lft-out--91.9%
distribute-rgt-out--95.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.2%
Final simplification87.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -1.38e+169) (not (<= d1 2.6e+219))) (- (* d1 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -1.38e+169) || !(d1 <= 2.6e+219)) {
tmp = -(d1 * 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 ((d1 <= (-1.38d+169)) .or. (.not. (d1 <= 2.6d+219))) then
tmp = -(d1 * 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 ((d1 <= -1.38e+169) || !(d1 <= 2.6e+219)) {
tmp = -(d1 * d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -1.38e+169) or not (d1 <= 2.6e+219): tmp = -(d1 * d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -1.38e+169) || !(d1 <= 2.6e+219)) tmp = Float64(-Float64(d1 * d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -1.38e+169) || ~((d1 <= 2.6e+219))) tmp = -(d1 * d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -1.38e+169], N[Not[LessEqual[d1, 2.6e+219]], $MachinePrecision]], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.38 \cdot 10^{+169} \lor \neg \left(d1 \leq 2.6 \cdot 10^{+219}\right):\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d1 < -1.38e169 or 2.5999999999999999e219 < d1 Initial program 58.5%
associate--l+58.5%
distribute-lft-out--61.0%
distribute-rgt-out--68.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 100.0%
unpow2100.0%
mul-1-neg100.0%
distribute-rgt-neg-out100.0%
Simplified100.0%
if -1.38e169 < d1 < 2.5999999999999999e219Initial program 94.4%
associate--l+94.4%
distribute-lft-out--95.8%
distribute-rgt-out--98.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.9%
Taylor expanded in d1 around 0 65.3%
Final simplification70.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.5e+67) (* d1 (- d2 (+ d1 d3))) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.5e+67) {
tmp = d1 * (d2 - (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 (d4 <= 4.5d+67) then
tmp = d1 * (d2 - (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 (d4 <= 4.5e+67) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.5e+67: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.5e+67) tmp = Float64(d1 * Float64(d2 - 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 (d4 <= 4.5e+67) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.5e+67], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.5 \cdot 10^{+67}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d4 < 4.4999999999999998e67Initial program 90.6%
associate--l+90.6%
distribute-lft-out--92.1%
distribute-rgt-out--92.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.7%
if 4.4999999999999998e67 < d4 Initial program 81.1%
associate--l+81.1%
distribute-lft-out--83.0%
distribute-rgt-out--96.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 94.6%
Final simplification86.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 8.5e-158) (* d1 d2) (if (<= d4 5e+105) (- (* d1 d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 8.5e-158) {
tmp = d1 * d2;
} else if (d4 <= 5e+105) {
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 <= 8.5d-158) then
tmp = d1 * d2
else if (d4 <= 5d+105) 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 <= 8.5e-158) {
tmp = d1 * d2;
} else if (d4 <= 5e+105) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 8.5e-158: tmp = d1 * d2 elif d4 <= 5e+105: tmp = -(d1 * d1) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 8.5e-158) tmp = Float64(d1 * d2); elseif (d4 <= 5e+105) tmp = Float64(-Float64(d1 * d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 8.5e-158) tmp = d1 * d2; elseif (d4 <= 5e+105) tmp = -(d1 * d1); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 8.5e-158], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 5e+105], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 8.5 \cdot 10^{-158}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 5 \cdot 10^{+105}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 8.49999999999999944e-158Initial program 90.6%
associate--l+90.6%
distribute-lft-out--91.8%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 37.7%
if 8.49999999999999944e-158 < d4 < 5.00000000000000046e105Initial program 90.9%
associate--l+90.9%
distribute-lft-out--93.1%
distribute-rgt-out--95.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 36.7%
unpow236.7%
mul-1-neg36.7%
distribute-rgt-neg-out36.7%
Simplified36.7%
if 5.00000000000000046e105 < d4 Initial program 80.8%
associate--l+80.8%
distribute-lft-out--82.7%
distribute-rgt-out--96.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 64.6%
Final simplification43.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3e+41) (* d1 (+ d2 d4)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3e+41) {
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 <= (-3d+41)) 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 <= -3e+41) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3e+41: tmp = d1 * (d2 + d4) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3e+41) 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 <= -3e+41) tmp = d1 * (d2 + d4); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3e+41], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3 \cdot 10^{+41}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -2.9999999999999998e41Initial program 84.8%
associate--l+84.8%
distribute-lft-out--87.9%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 86.8%
Taylor expanded in d1 around 0 83.1%
if -2.9999999999999998e41 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--91.0%
distribute-rgt-out--93.7%
distribute-lft-out100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-in93.7%
Applied egg-rr93.7%
Taylor expanded in d3 around 0 74.8%
Taylor expanded in d2 around 0 58.6%
Final simplification64.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.45e+41) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.45e+41) {
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 <= (-1.45d+41)) 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 <= -1.45e+41) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.45e+41: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.45e+41) 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 <= -1.45e+41) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.45e+41], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.45 \cdot 10^{+41}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.44999999999999994e41Initial program 84.8%
associate--l+84.8%
distribute-lft-out--87.9%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 67.6%
if -1.44999999999999994e41 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--91.0%
distribute-rgt-out--93.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 33.2%
Final simplification42.0%
(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 88.6%
associate--l+88.6%
distribute-lft-out--90.2%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 30.5%
Final simplification30.5%
(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 2023224
(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)))