
(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 3 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 8.2e+126) (- (pow x 4.0) (pow y_m 4.0)) (if (<= y_m 2e+142) (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 <= 8.2e+126) {
tmp = pow(x, 4.0) - pow(y_m, 4.0);
} else if (y_m <= 2e+142) {
tmp = pow(x, 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 <= 8.2d+126) then
tmp = (x ** 4.0d0) - (y_m ** 4.0d0)
else if (y_m <= 2d+142) then
tmp = x ** 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 <= 8.2e+126) {
tmp = Math.pow(x, 4.0) - Math.pow(y_m, 4.0);
} else if (y_m <= 2e+142) {
tmp = Math.pow(x, 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 <= 8.2e+126: tmp = math.pow(x, 4.0) - math.pow(y_m, 4.0) elif y_m <= 2e+142: tmp = math.pow(x, 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 <= 8.2e+126) tmp = Float64((x ^ 4.0) - (y_m ^ 4.0)); elseif (y_m <= 2e+142) tmp = x ^ 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 <= 8.2e+126) tmp = (x ^ 4.0) - (y_m ^ 4.0); elseif (y_m <= 2e+142) tmp = x ^ 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, 8.2e+126], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y$95$m, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 2e+142], N[Power[x, 4.0], $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 8.2 \cdot 10^{+126}:\\
\;\;\;\;{x}^{4} - {y_m}^{4}\\
\mathbf{elif}\;y_m \leq 2 \cdot 10^{+142}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y_m}^{4}\\
\end{array}
\end{array}
if y < 8.2000000000000001e126Initial program 90.7%
if 8.2000000000000001e126 < y < 2.0000000000000001e142Initial program 0.0%
Taylor expanded in x around inf 100.0%
if 2.0000000000000001e142 < y Initial program 68.4%
Taylor expanded in x around 0 97.4%
neg-mul-197.4%
Simplified97.4%
Final simplification91.8%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= (pow y_m 4.0) 1.26e+88) (pow x 4.0) (- (pow y_m 4.0))))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (pow(y_m, 4.0) <= 1.26e+88) {
tmp = pow(x, 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 ** 4.0d0) <= 1.26d+88) then
tmp = x ** 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 (Math.pow(y_m, 4.0) <= 1.26e+88) {
tmp = Math.pow(x, 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 math.pow(y_m, 4.0) <= 1.26e+88: tmp = math.pow(x, 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 ^ 4.0) <= 1.26e+88) tmp = x ^ 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 ^ 4.0) <= 1.26e+88) tmp = x ^ 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[N[Power[y$95$m, 4.0], $MachinePrecision], 1.26e+88], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y$95$m, 4.0], $MachinePrecision])]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;{y_m}^{4} \leq 1.26 \cdot 10^{+88}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y_m}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 1.26e88Initial program 100.0%
Taylor expanded in x around inf 89.3%
if 1.26e88 < (pow.f64 y 4) Initial program 71.8%
Taylor expanded in x around 0 83.9%
neg-mul-183.9%
Simplified83.9%
Final simplification86.7%
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 86.3%
Taylor expanded in x around inf 54.3%
Final simplification54.3%
herbie shell --seed 2024020
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))