
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} - {y}^{4}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} - {y}^{4}
\end{array}
(FPCore (x y) :precision binary64 (if (or (<= x -3.2e+148) (not (<= x 1.75e+90))) (pow x 4.0) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if ((x <= -3.2e+148) || !(x <= 1.75e+90)) {
tmp = pow(x, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-3.2d+148)) .or. (.not. (x <= 1.75d+90))) then
tmp = x ** 4.0d0
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3.2e+148) || !(x <= 1.75e+90)) {
tmp = Math.pow(x, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3.2e+148) or not (x <= 1.75e+90): tmp = math.pow(x, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3.2e+148) || !(x <= 1.75e+90)) tmp = x ^ 4.0; else tmp = Float64(-(y ^ 4.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3.2e+148) || ~((x <= 1.75e+90))) tmp = x ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3.2e+148], N[Not[LessEqual[x, 1.75e+90]], $MachinePrecision]], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+148} \lor \neg \left(x \leq 1.75 \cdot 10^{+90}\right):\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if x < -3.1999999999999999e148 or 1.7499999999999999e90 < x Initial program 50.6%
Taylor expanded in x around inf 88.3%
if -3.1999999999999999e148 < x < 1.7499999999999999e90Initial program 92.7%
Taylor expanded in x around 0 81.3%
neg-mul-181.3%
Simplified81.3%
Final simplification83.4%
(FPCore (x y) :precision binary64 (if (<= (pow x 4.0) INFINITY) (- (pow x 4.0) (pow y 4.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= ((double) INFINITY)) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = pow(x, 4.0);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.pow(x, 4.0) <= Double.POSITIVE_INFINITY) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(x, 4.0) <= math.inf: tmp = math.pow(x, 4.0) - math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x ^ 4.0) <= Inf) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x ^ 4.0) <= Inf) tmp = (x ^ 4.0) - (y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], Infinity], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq \infty:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < +inf.0Initial program 80.1%
if +inf.0 < (pow.f64 x #s(literal 4 binary64)) Initial program 80.1%
Taylor expanded in x around inf 53.8%
(FPCore (x y) :precision binary64 (pow x 4.0))
double code(double x, double y) {
return pow(x, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x ** 4.0d0
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0);
}
def code(x, y): return math.pow(x, 4.0)
function code(x, y) return x ^ 4.0 end
function tmp = code(x, y) tmp = x ^ 4.0; end
code[x_, y_] := N[Power[x, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{4}
\end{array}
Initial program 80.1%
Taylor expanded in x around inf 53.8%
(FPCore (x y) :precision binary64 0.0)
double code(double x, double y) {
return 0.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.0d0
end function
public static double code(double x, double y) {
return 0.0;
}
def code(x, y): return 0.0
function code(x, y) return 0.0 end
function tmp = code(x, y) tmp = 0.0; end
code[x_, y_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 80.1%
Taylor expanded in x around 0 60.6%
neg-mul-160.6%
Simplified60.6%
add-sqr-sqrt13.6%
sqrt-unprod26.7%
sqr-neg26.7%
sqrt-unprod25.5%
add-log-exp28.1%
add-sqr-sqrt28.1%
add-sqr-sqrt28.1%
sqrt-unprod28.1%
*-un-lft-identity28.1%
exp-prod28.1%
add-sqr-sqrt28.1%
sqrt-unprod28.1%
sqr-neg28.1%
sqrt-unprod13.6%
add-sqr-sqrt14.0%
exp-prod14.0%
*-un-lft-identity14.0%
exp-neg14.0%
rgt-mult-inverse14.9%
Applied egg-rr14.9%
herbie shell --seed 2024131
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))