
(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}
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= x_m 2.1e+127) (fma (pow x_m 2.0) (pow x_m 2.0) (- (pow y 4.0))) (pow x_m 4.0)))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 2.1e+127) {
tmp = fma(pow(x_m, 2.0), pow(x_m, 2.0), -pow(y, 4.0));
} else {
tmp = pow(x_m, 4.0);
}
return tmp;
}
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 2.1e+127) tmp = fma((x_m ^ 2.0), (x_m ^ 2.0), Float64(-(y ^ 4.0))); else tmp = x_m ^ 4.0; end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 2.1e+127], N[(N[Power[x$95$m, 2.0], $MachinePrecision] * N[Power[x$95$m, 2.0], $MachinePrecision] + (-N[Power[y, 4.0], $MachinePrecision])), $MachinePrecision], N[Power[x$95$m, 4.0], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.1 \cdot 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left({x\_m}^{2}, {x\_m}^{2}, -{y}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{4}\\
\end{array}
\end{array}
if x < 2.09999999999999992e127Initial program 91.7%
sqr-pow91.6%
fma-neg95.8%
metadata-eval95.8%
metadata-eval95.8%
Applied egg-rr95.8%
if 2.09999999999999992e127 < x Initial program 65.0%
Taylor expanded in x around inf 87.5%
Final simplification94.5%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= x_m 1.15e+77) (- (pow x_m 4.0) (pow y 4.0)) (pow x_m 4.0)))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 1.15e+77) {
tmp = pow(x_m, 4.0) - pow(y, 4.0);
} else {
tmp = pow(x_m, 4.0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (x_m <= 1.15d+77) then
tmp = (x_m ** 4.0d0) - (y ** 4.0d0)
else
tmp = x_m ** 4.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (x_m <= 1.15e+77) {
tmp = Math.pow(x_m, 4.0) - Math.pow(y, 4.0);
} else {
tmp = Math.pow(x_m, 4.0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if x_m <= 1.15e+77: tmp = math.pow(x_m, 4.0) - math.pow(y, 4.0) else: tmp = math.pow(x_m, 4.0) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 1.15e+77) tmp = Float64((x_m ^ 4.0) - (y ^ 4.0)); else tmp = x_m ^ 4.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (x_m <= 1.15e+77) tmp = (x_m ^ 4.0) - (y ^ 4.0); else tmp = x_m ^ 4.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 1.15e+77], N[(N[Power[x$95$m, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[x$95$m, 4.0], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;{x\_m}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{4}\\
\end{array}
\end{array}
if x < 1.14999999999999997e77Initial program 93.6%
if 1.14999999999999997e77 < x Initial program 63.5%
Taylor expanded in x around inf 82.7%
Final simplification91.4%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= (pow y 4.0) 3e-23) (pow x_m 4.0) (- (pow y 4.0))))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (pow(y, 4.0) <= 3e-23) {
tmp = pow(x_m, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if ((y ** 4.0d0) <= 3d-23) then
tmp = x_m ** 4.0d0
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (Math.pow(y, 4.0) <= 3e-23) {
tmp = Math.pow(x_m, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if math.pow(y, 4.0) <= 3e-23: tmp = math.pow(x_m, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if ((y ^ 4.0) <= 3e-23) tmp = x_m ^ 4.0; else tmp = Float64(-(y ^ 4.0)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if ((y ^ 4.0) <= 3e-23) tmp = x_m ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[N[Power[y, 4.0], $MachinePrecision], 3e-23], N[Power[x$95$m, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 3 \cdot 10^{-23}:\\
\;\;\;\;{x\_m}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 3.00000000000000003e-23Initial program 100.0%
Taylor expanded in x around inf 93.7%
if 3.00000000000000003e-23 < (pow.f64 y 4) Initial program 74.8%
Taylor expanded in x around 0 78.0%
neg-mul-178.0%
Simplified78.0%
Final simplification85.9%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (pow x_m 4.0))
x_m = fabs(x);
double code(double x_m, double y) {
return pow(x_m, 4.0);
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = x_m ** 4.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return Math.pow(x_m, 4.0);
}
x_m = math.fabs(x) def code(x_m, y): return math.pow(x_m, 4.0)
x_m = abs(x) function code(x_m, y) return x_m ^ 4.0 end
x_m = abs(x); function tmp = code(x_m, y) tmp = x_m ^ 4.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := N[Power[x$95$m, 4.0], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{x\_m}^{4}
\end{array}
Initial program 87.5%
Taylor expanded in x around inf 58.6%
Final simplification58.6%
herbie shell --seed 2024044
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))