
(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}
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= y_m 2.2e+144) (fma (pow y_m 2.0) (- (pow y_m 2.0)) (pow x 4.0)) (- (pow y_m 4.0))))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (y_m <= 2.2e+144) {
tmp = fma(pow(y_m, 2.0), -pow(y_m, 2.0), pow(x, 4.0));
} else {
tmp = -pow(y_m, 4.0);
}
return tmp;
}
y_m = abs(y) function code(x, y_m) tmp = 0.0 if (y_m <= 2.2e+144) tmp = fma((y_m ^ 2.0), Float64(-(y_m ^ 2.0)), (x ^ 4.0)); else tmp = Float64(-(y_m ^ 4.0)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[LessEqual[y$95$m, 2.2e+144], N[(N[Power[y$95$m, 2.0], $MachinePrecision] * (-N[Power[y$95$m, 2.0], $MachinePrecision]) + N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision], (-N[Power[y$95$m, 4.0], $MachinePrecision])]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 2.2 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left({y_m}^{2}, -{y_m}^{2}, {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;-{y_m}^{4}\\
\end{array}
\end{array}
if y < 2.19999999999999988e144Initial program 86.7%
sub-neg86.7%
+-commutative86.7%
sqr-pow86.6%
distribute-rgt-neg-in86.6%
fma-def90.1%
metadata-eval90.1%
metadata-eval90.1%
Applied egg-rr90.1%
if 2.19999999999999988e144 < y Initial program 58.1%
Taylor expanded in x around 0 90.3%
neg-mul-190.3%
Simplified90.3%
Final simplification90.2%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= y_m 1.6e+75) (- (pow x 4.0) (pow y_m 4.0)) (- (pow y_m 4.0))))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (y_m <= 1.6e+75) {
tmp = pow(x, 4.0) - pow(y_m, 4.0);
} else {
tmp = -pow(y_m, 4.0);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if (y_m <= 1.6d+75) then
tmp = (x ** 4.0d0) - (y_m ** 4.0d0)
else
tmp = -(y_m ** 4.0d0)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double tmp;
if (y_m <= 1.6e+75) {
tmp = Math.pow(x, 4.0) - Math.pow(y_m, 4.0);
} else {
tmp = -Math.pow(y_m, 4.0);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if y_m <= 1.6e+75: tmp = math.pow(x, 4.0) - math.pow(y_m, 4.0) else: tmp = -math.pow(y_m, 4.0) return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if (y_m <= 1.6e+75) tmp = Float64((x ^ 4.0) - (y_m ^ 4.0)); else tmp = Float64(-(y_m ^ 4.0)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if (y_m <= 1.6e+75) tmp = (x ^ 4.0) - (y_m ^ 4.0); else tmp = -(y_m ^ 4.0); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[LessEqual[y$95$m, 1.6e+75], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y$95$m, 4.0], $MachinePrecision]), $MachinePrecision], (-N[Power[y$95$m, 4.0], $MachinePrecision])]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 1.6 \cdot 10^{+75}:\\
\;\;\;\;{x}^{4} - {y_m}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y_m}^{4}\\
\end{array}
\end{array}
if y < 1.59999999999999992e75Initial program 87.6%
if 1.59999999999999992e75 < y Initial program 63.0%
Taylor expanded in x around 0 89.1%
neg-mul-189.1%
Simplified89.1%
Final simplification87.9%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= (pow x 4.0) 1.05e+31) (- (pow y_m 4.0)) (pow x 4.0)))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (pow(x, 4.0) <= 1.05e+31) {
tmp = -pow(y_m, 4.0);
} else {
tmp = pow(x, 4.0);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if ((x ** 4.0d0) <= 1.05d+31) then
tmp = -(y_m ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double tmp;
if (Math.pow(x, 4.0) <= 1.05e+31) {
tmp = -Math.pow(y_m, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if math.pow(x, 4.0) <= 1.05e+31: tmp = -math.pow(y_m, 4.0) else: tmp = math.pow(x, 4.0) return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if ((x ^ 4.0) <= 1.05e+31) tmp = Float64(-(y_m ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if ((x ^ 4.0) <= 1.05e+31) tmp = -(y_m ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 1.05e+31], (-N[Power[y$95$m, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 1.05 \cdot 10^{+31}:\\
\;\;\;\;-{y_m}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x 4) < 1.04999999999999989e31Initial program 100.0%
Taylor expanded in x around 0 92.3%
neg-mul-192.3%
Simplified92.3%
if 1.04999999999999989e31 < (pow.f64 x 4) Initial program 67.7%
Taylor expanded in x around inf 73.0%
Final simplification82.2%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (pow x 4.0))
y_m = fabs(y);
double code(double x, double y_m) {
return pow(x, 4.0);
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = x ** 4.0d0
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return Math.pow(x, 4.0);
}
y_m = math.fabs(y) def code(x, y_m): return math.pow(x, 4.0)
y_m = abs(y) function code(x, y_m) return x ^ 4.0 end
y_m = abs(y); function tmp = code(x, y_m) tmp = x ^ 4.0; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := N[Power[x, 4.0], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
{x}^{4}
\end{array}
Initial program 83.2%
Taylor expanded in x around inf 55.4%
Final simplification55.4%
herbie shell --seed 2023319
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))