
(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 2e+153) (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 <= 2e+153) {
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 <= 2e+153) 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, 2e+153], 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 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left({y_m}^{2}, -{y_m}^{2}, {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;-{y_m}^{4}\\
\end{array}
\end{array}
if y < 2e153Initial program 87.4%
sub-neg87.4%
+-commutative87.4%
sqr-pow87.4%
distribute-rgt-neg-in87.4%
fma-def91.3%
metadata-eval91.3%
metadata-eval91.3%
Applied egg-rr91.3%
if 2e153 < y Initial program 56.0%
Taylor expanded in x around 0 84.0%
neg-mul-184.0%
Simplified84.0%
Final simplification90.5%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= y_m 1.16e+77) (- (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.16e+77) {
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.16d+77) 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.16e+77) {
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.16e+77: 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.16e+77) 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.16e+77) 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.16e+77], 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.16 \cdot 10^{+77}:\\
\;\;\;\;{x}^{4} - {y_m}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y_m}^{4}\\
\end{array}
\end{array}
if y < 1.1600000000000001e77Initial program 88.1%
if 1.1600000000000001e77 < y Initial program 63.2%
Taylor expanded in x around 0 84.2%
neg-mul-184.2%
Simplified84.2%
Final simplification87.5%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= (pow x 4.0) 5.2e-180) (- (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) <= 5.2e-180) {
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) <= 5.2d-180) 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) <= 5.2e-180) {
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) <= 5.2e-180: 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) <= 5.2e-180) 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) <= 5.2e-180) 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], 5.2e-180], (-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 5.2 \cdot 10^{-180}:\\
\;\;\;\;-{y_m}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x 4) < 5.1999999999999998e-180Initial program 100.0%
Taylor expanded in x around 0 97.2%
neg-mul-197.2%
Simplified97.2%
if 5.1999999999999998e-180 < (pow.f64 x 4) Initial program 70.4%
Taylor expanded in x around inf 73.8%
Final simplification84.9%
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 84.4%
Taylor expanded in x around inf 59.3%
Final simplification59.3%
herbie shell --seed 2023325
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))