
(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 5 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 (let* ((t_0 (+ (* x x) (* y y)))) (if (<= x 5.8e+145) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 5.8e+145) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * x) + (y * y)
if (x <= 5.8d+145) then
tmp = t_0 * ((x * x) - (y * y))
else
tmp = (x * x) * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 5.8e+145) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
def code(x, y): t_0 = (x * x) + (y * y) tmp = 0 if x <= 5.8e+145: tmp = t_0 * ((x * x) - (y * y)) else: tmp = (x * x) * t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * y)) tmp = 0.0 if (x <= 5.8e+145) tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * x) + (y * y); tmp = 0.0; if (x <= 5.8e+145) tmp = t_0 * ((x * x) - (y * y)); else tmp = (x * x) * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.8e+145], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 5.8 \cdot 10^{+145}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\
\end{array}
\end{array}
if x < 5.8000000000000001e145Initial program 90.3%
sqr-pow90.1%
sqr-pow90.0%
difference-of-squares98.3%
metadata-eval98.3%
pow298.3%
metadata-eval98.3%
pow298.3%
metadata-eval98.3%
pow298.3%
metadata-eval98.3%
pow298.3%
Applied egg-rr98.3%
if 5.8000000000000001e145 < x Initial program 65.0%
sqr-pow65.0%
sqr-pow65.0%
difference-of-squares75.0%
metadata-eval75.0%
pow275.0%
metadata-eval75.0%
pow275.0%
metadata-eval75.0%
pow275.0%
metadata-eval75.0%
pow275.0%
Applied egg-rr75.0%
Taylor expanded in x around inf 87.5%
unpow287.5%
Simplified87.5%
Final simplification96.6%
(FPCore (x y) :precision binary64 (if (or (<= y -1.95e+109) (not (<= y 1.05e-57))) (* (* y y) (- (* y (- y)) (* x x))) (* (* x x) (+ (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.95e+109) || !(y <= 1.05e-57)) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.95d+109)) .or. (.not. (y <= 1.05d-57))) then
tmp = (y * y) * ((y * -y) - (x * x))
else
tmp = (x * x) * ((x * x) + (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.95e+109) || !(y <= 1.05e-57)) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.95e+109) or not (y <= 1.05e-57): tmp = (y * y) * ((y * -y) - (x * x)) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.95e+109) || !(y <= 1.05e-57)) tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); else tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.95e+109) || ~((y <= 1.05e-57))) tmp = (y * y) * ((y * -y) - (x * x)); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.95e+109], N[Not[LessEqual[y, 1.05e-57]], $MachinePrecision]], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+109} \lor \neg \left(y \leq 1.05 \cdot 10^{-57}\right):\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\end{array}
\end{array}
if y < -1.95000000000000008e109 or 1.05e-57 < y Initial program 75.0%
sqr-pow75.0%
sqr-pow74.9%
difference-of-squares88.7%
metadata-eval88.7%
pow288.7%
metadata-eval88.7%
pow288.7%
metadata-eval88.7%
pow288.7%
metadata-eval88.7%
pow288.7%
Applied egg-rr88.7%
Taylor expanded in x around 0 84.4%
unpow284.4%
mul-1-neg84.4%
distribute-rgt-neg-out84.4%
Simplified84.4%
if -1.95000000000000008e109 < y < 1.05e-57Initial program 95.7%
sqr-pow95.5%
sqr-pow95.4%
difference-of-squares99.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 88.6%
unpow288.6%
Simplified88.6%
Final simplification86.7%
(FPCore (x y) :precision binary64 (if (or (<= y -3.1e+110) (not (<= y 1.22e+126))) (* (* x x) (* y (- y))) (* (* x x) (+ (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if ((y <= -3.1e+110) || !(y <= 1.22e+126)) {
tmp = (x * x) * (y * -y);
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3.1d+110)) .or. (.not. (y <= 1.22d+126))) then
tmp = (x * x) * (y * -y)
else
tmp = (x * x) * ((x * x) + (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3.1e+110) || !(y <= 1.22e+126)) {
tmp = (x * x) * (y * -y);
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.1e+110) or not (y <= 1.22e+126): tmp = (x * x) * (y * -y) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.1e+110) || !(y <= 1.22e+126)) tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3.1e+110) || ~((y <= 1.22e+126))) tmp = (x * x) * (y * -y); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.1e+110], N[Not[LessEqual[y, 1.22e+126]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+110} \lor \neg \left(y \leq 1.22 \cdot 10^{+126}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\end{array}
\end{array}
if y < -3.10000000000000017e110 or 1.21999999999999995e126 < y Initial program 68.8%
sqr-pow68.8%
sqr-pow68.8%
difference-of-squares83.8%
metadata-eval83.8%
pow283.8%
metadata-eval83.8%
pow283.8%
metadata-eval83.8%
pow283.8%
metadata-eval83.8%
pow283.8%
Applied egg-rr83.8%
Taylor expanded in x around 0 90.0%
unpow290.0%
mul-1-neg90.0%
distribute-rgt-neg-out90.0%
Simplified90.0%
Taylor expanded in x around inf 61.7%
mul-1-neg61.7%
unpow261.7%
unpow261.7%
*-commutative61.7%
Simplified61.7%
if -3.10000000000000017e110 < y < 1.21999999999999995e126Initial program 94.3%
sqr-pow94.1%
sqr-pow94.0%
difference-of-squares99.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 76.5%
unpow276.5%
Simplified76.5%
Final simplification71.9%
(FPCore (x y) :precision binary64 (if (or (<= y -4.8e+109) (not (<= y 1.25e+126))) (* (* x x) (* y (- y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if ((y <= -4.8e+109) || !(y <= 1.25e+126)) {
tmp = (x * x) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
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+109)) .or. (.not. (y <= 1.25d+126))) then
tmp = (x * x) * (y * -y)
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -4.8e+109) || !(y <= 1.25e+126)) {
tmp = (x * x) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4.8e+109) or not (y <= 1.25e+126): tmp = (x * x) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -4.8e+109) || !(y <= 1.25e+126)) tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -4.8e+109) || ~((y <= 1.25e+126))) tmp = (x * x) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4.8e+109], N[Not[LessEqual[y, 1.25e+126]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+109} \lor \neg \left(y \leq 1.25 \cdot 10^{+126}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < -4.79999999999999975e109 or 1.24999999999999994e126 < y Initial program 68.8%
sqr-pow68.8%
sqr-pow68.8%
difference-of-squares83.8%
metadata-eval83.8%
pow283.8%
metadata-eval83.8%
pow283.8%
metadata-eval83.8%
pow283.8%
metadata-eval83.8%
pow283.8%
Applied egg-rr83.8%
Taylor expanded in x around 0 90.0%
unpow290.0%
mul-1-neg90.0%
distribute-rgt-neg-out90.0%
Simplified90.0%
Taylor expanded in x around inf 61.7%
mul-1-neg61.7%
unpow261.7%
unpow261.7%
*-commutative61.7%
Simplified61.7%
if -4.79999999999999975e109 < y < 1.24999999999999994e126Initial program 94.3%
sqr-pow94.1%
sqr-pow94.0%
difference-of-squares99.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 76.5%
unpow276.5%
Simplified76.5%
Taylor expanded in x around 0 34.5%
unpow234.5%
unpow234.5%
*-commutative34.5%
Simplified34.5%
Final simplification43.0%
(FPCore (x y) :precision binary64 (* (* x x) (* y y)))
double code(double x, double y) {
return (x * x) * (y * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (y * y)
end function
public static double code(double x, double y) {
return (x * x) * (y * y);
}
def code(x, y): return (x * x) * (y * y)
function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
function tmp = code(x, y) tmp = (x * x) * (y * y); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 86.3%
sqr-pow86.2%
sqr-pow86.1%
difference-of-squares94.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
Applied egg-rr94.7%
Taylor expanded in x around inf 55.8%
unpow255.8%
Simplified55.8%
Taylor expanded in x around 0 26.9%
unpow226.9%
unpow226.9%
*-commutative26.9%
Simplified26.9%
Final simplification26.9%
herbie shell --seed 2023178
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))