
(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 (<= (pow y 4.0) 1e+307) (- (pow x 4.0) (pow y 4.0)) (- (pow (cbrt y) 12.0))))
double code(double x, double y) {
double tmp;
if (pow(y, 4.0) <= 1e+307) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = -pow(cbrt(y), 12.0);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.pow(y, 4.0) <= 1e+307) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else {
tmp = -Math.pow(Math.cbrt(y), 12.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y ^ 4.0) <= 1e+307) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); else tmp = Float64(-(cbrt(y) ^ 12.0)); end return tmp end
code[x_, y_] := If[LessEqual[N[Power[y, 4.0], $MachinePrecision], 1e+307], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], (-N[Power[N[Power[y, 1/3], $MachinePrecision], 12.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 10^{+307}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{\left(\sqrt[3]{y}\right)}^{12}\\
\end{array}
\end{array}
if (pow.f64 y #s(literal 4 binary64)) < 9.99999999999999986e306Initial program 100.0%
if 9.99999999999999986e306 < (pow.f64 y #s(literal 4 binary64)) Initial program 55.7%
Taylor expanded in x around 0 84.1%
neg-mul-184.1%
Simplified84.1%
metadata-eval84.1%
pow-pow84.1%
pow284.1%
add-cube-cbrt84.1%
associate-*r*84.1%
unpow-prod-down84.1%
add-cube-cbrt84.1%
pow384.1%
pow284.1%
pow-prod-up84.1%
metadata-eval84.1%
Applied egg-rr84.1%
unpow284.1%
associate-*r*84.1%
unpow284.1%
pow-sqr84.1%
metadata-eval84.1%
pow-plus84.1%
pow-plus84.1%
metadata-eval84.1%
metadata-eval84.1%
Simplified84.1%
(FPCore (x y) :precision binary64 (if (<= (pow y 4.0) 5e-246) (pow x 4.0) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if (pow(y, 4.0) <= 5e-246) {
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 ((y ** 4.0d0) <= 5d-246) 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 (Math.pow(y, 4.0) <= 5e-246) {
tmp = Math.pow(x, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(y, 4.0) <= 5e-246: tmp = math.pow(x, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((y ^ 4.0) <= 5e-246) tmp = x ^ 4.0; else tmp = Float64(-(y ^ 4.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y ^ 4.0) <= 5e-246) tmp = x ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[y, 4.0], $MachinePrecision], 5e-246], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 5 \cdot 10^{-246}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y #s(literal 4 binary64)) < 4.9999999999999997e-246Initial program 100.0%
Taylor expanded in x around inf 98.4%
if 4.9999999999999997e-246 < (pow.f64 y #s(literal 4 binary64)) Initial program 73.1%
Taylor expanded in x around 0 76.1%
neg-mul-176.1%
Simplified76.1%
(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 84.8%
Taylor expanded in x around inf 56.6%
(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 84.8%
Taylor expanded in x around 0 59.1%
neg-mul-159.1%
Simplified59.1%
add-sqr-sqrt14.8%
sqrt-unprod22.5%
sqr-neg22.5%
sqrt-unprod21.4%
add-log-exp25.1%
add-sqr-sqrt25.1%
add-sqr-sqrt25.1%
sqrt-unprod25.1%
*-un-lft-identity25.1%
exp-prod25.1%
add-sqr-sqrt25.1%
sqrt-unprod25.1%
sqr-neg25.1%
sqrt-unprod14.8%
add-sqr-sqrt15.7%
exp-prod15.7%
*-un-lft-identity15.7%
exp-neg15.7%
rgt-mult-inverse16.5%
Applied egg-rr16.5%
herbie shell --seed 2024157
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))