
(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 (* (fma x x (pow y 2.0)) (* (+ x y) (- x y))))
double code(double x, double y) {
return fma(x, x, pow(y, 2.0)) * ((x + y) * (x - y));
}
function code(x, y) return Float64(fma(x, x, (y ^ 2.0)) * Float64(Float64(x + y) * Float64(x - y))) end
code[x_, y_] := N[(N[(x * x + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, x, {y}^{2}\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)
\end{array}
Initial program 85.2%
sqr-pow85.1%
sqr-pow85.0%
difference-of-squares94.8%
metadata-eval94.8%
pow294.8%
fma-def94.8%
metadata-eval94.8%
metadata-eval94.8%
metadata-eval94.8%
Applied egg-rr94.8%
unpow294.8%
unpow294.8%
difference-of-squares99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 4.8e+79) (- (pow x 4.0) (pow y 4.0)) (if (<= y 2.15e+88) (pow x 4.0) (- (pow y 4.0)))))
double code(double x, double y) {
double tmp;
if (y <= 4.8e+79) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else if (y <= 2.15e+88) {
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.8d+79) then
tmp = (x ** 4.0d0) - (y ** 4.0d0)
else if (y <= 2.15d+88) 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 (y <= 4.8e+79) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else if (y <= 2.15e+88) {
tmp = Math.pow(x, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.8e+79: tmp = math.pow(x, 4.0) - math.pow(y, 4.0) elif y <= 2.15e+88: 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.8e+79) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); elseif (y <= 2.15e+88) 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.8e+79) tmp = (x ^ 4.0) - (y ^ 4.0); elseif (y <= 2.15e+88) tmp = x ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.8e+79], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.15e+88], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{+79}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{+88}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if y < 4.79999999999999971e79Initial program 89.4%
if 4.79999999999999971e79 < y < 2.14999999999999987e88Initial program 50.0%
Taylor expanded in x around inf 50.8%
if 2.14999999999999987e88 < y Initial program 68.1%
Taylor expanded in x around 0 85.1%
neg-mul-185.1%
Simplified85.1%
Final simplification88.3%
(FPCore (x y) :precision binary64 (if (<= (pow y 4.0) 2.8e-69) (pow x 4.0) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if (pow(y, 4.0) <= 2.8e-69) {
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) <= 2.8d-69) 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) <= 2.8e-69) {
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) <= 2.8e-69: 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) <= 2.8e-69) 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) <= 2.8e-69) 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], 2.8e-69], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 2.8 \cdot 10^{-69}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 2.79999999999999979e-69Initial program 100.0%
Taylor expanded in x around inf 93.0%
if 2.79999999999999979e-69 < (pow.f64 y 4) Initial program 72.0%
Taylor expanded in x around 0 75.8%
neg-mul-175.8%
Simplified75.8%
Final simplification83.8%
(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 85.2%
Taylor expanded in x around inf 56.8%
Final simplification56.8%
herbie shell --seed 2024016
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))