
(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) 2e+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) <= 2e+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) <= 2e+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) <= 2e+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], 2e+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 2 \cdot 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)) < 1.99999999999999997e307Initial program 100.0%
if 1.99999999999999997e307 < (pow.f64 y #s(literal 4 binary64)) Initial program 59.8%
Taylor expanded in x around 0 81.7%
neg-mul-181.7%
Simplified81.7%
metadata-eval81.7%
pow-pow81.7%
pow281.7%
add-cube-cbrt81.7%
associate-*r*81.7%
unpow-prod-down81.7%
add-cube-cbrt81.7%
pow381.7%
pow281.7%
pow-prod-up81.7%
metadata-eval81.7%
Applied egg-rr81.7%
unpow281.7%
associate-*r*81.7%
unpow281.7%
pow-sqr81.7%
metadata-eval81.7%
pow-plus81.7%
pow-plus81.7%
metadata-eval81.7%
metadata-eval81.7%
Simplified81.7%
(FPCore (x y) :precision binary64 (if (<= (pow x 4.0) 1.12e+45) (- (pow y 4.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 1.12e+45) {
tmp = -pow(y, 4.0);
} else {
tmp = pow(x, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x ** 4.0d0) <= 1.12d+45) then
tmp = -(y ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.pow(x, 4.0) <= 1.12e+45) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(x, 4.0) <= 1.12e+45: tmp = -math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x ^ 4.0) <= 1.12e+45) tmp = Float64(-(y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x ^ 4.0) <= 1.12e+45) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 1.12e+45], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 1.12 \cdot 10^{+45}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 1.12e45Initial program 100.0%
Taylor expanded in x around 0 95.3%
neg-mul-195.3%
Simplified95.3%
if 1.12e45 < (pow.f64 x #s(literal 4 binary64)) Initial program 71.3%
Taylor expanded in x around inf 78.3%
(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 87.1%
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 87.1%
Taylor expanded in x around 0 62.5%
neg-mul-162.5%
Simplified62.5%
add-sqr-sqrt18.4%
sqrt-unprod27.3%
sqr-neg27.3%
sqrt-unprod25.0%
add-log-exp29.1%
add-sqr-sqrt29.1%
add-sqr-sqrt29.1%
sqrt-unprod29.1%
*-un-lft-identity29.1%
exp-prod29.1%
add-sqr-sqrt29.1%
sqrt-unprod29.1%
sqr-neg29.1%
sqrt-unprod18.4%
add-sqr-sqrt18.8%
exp-prod18.8%
*-un-lft-identity18.8%
exp-neg18.8%
rgt-mult-inverse19.7%
Applied egg-rr19.7%
herbie shell --seed 2024163
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))