
(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 (* (+ (* x x) (* y y)) (* (- x y) (+ x y))))
double code(double x, double y) {
return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) + (y * y)) * ((x - y) * (x + y))
end function
public static double code(double x, double y) {
return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
def code(x, y): return ((x * x) + (y * y)) * ((x - y) * (x + y))
function code(x, y) return Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x - y) * Float64(x + y))) end
function tmp = code(x, y) tmp = ((x * x) + (y * y)) * ((x - y) * (x + y)); end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x + y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)
\end{array}
Initial program 87.1%
sqr-pow87.0%
sqr-pow86.9%
difference-of-squares93.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
Applied egg-rr93.9%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y -2.35e+156)
(* (* y y) (* y (- y)))
(if (or (<= y -2.9e-50) (not (<= y 3.1e-46)))
(* (* y y) (- (* x x) (* y y)))
(* (* x x) (+ (* x x) (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= -2.35e+156) {
tmp = (y * y) * (y * -y);
} else if ((y <= -2.9e-50) || !(y <= 3.1e-46)) {
tmp = (y * y) * ((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 <= (-2.35d+156)) then
tmp = (y * y) * (y * -y)
else if ((y <= (-2.9d-50)) .or. (.not. (y <= 3.1d-46))) then
tmp = (y * y) * ((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 <= -2.35e+156) {
tmp = (y * y) * (y * -y);
} else if ((y <= -2.9e-50) || !(y <= 3.1e-46)) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.35e+156: tmp = (y * y) * (y * -y) elif (y <= -2.9e-50) or not (y <= 3.1e-46): tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.35e+156) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); elseif ((y <= -2.9e-50) || !(y <= 3.1e-46)) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * 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 <= -2.35e+156) tmp = (y * y) * (y * -y); elseif ((y <= -2.9e-50) || ~((y <= 3.1e-46))) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.35e+156], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -2.9e-50], N[Not[LessEqual[y, 3.1e-46]], $MachinePrecision]], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $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 -2.35 \cdot 10^{+156}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq -2.9 \cdot 10^{-50} \lor \neg \left(y \leq 3.1 \cdot 10^{-46}\right):\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\end{array}
\end{array}
if y < -2.35e156Initial program 67.6%
sqr-pow67.6%
sqr-pow67.6%
difference-of-squares73.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
Applied egg-rr73.5%
Taylor expanded in x around 0 73.5%
unpow273.5%
Simplified73.5%
Taylor expanded in x around 0 85.3%
unpow285.3%
mul-1-neg85.3%
distribute-rgt-neg-out85.3%
Simplified85.3%
if -2.35e156 < y < -2.90000000000000008e-50 or 3.1000000000000001e-46 < y Initial program 80.4%
sqr-pow80.3%
sqr-pow80.1%
difference-of-squares94.4%
metadata-eval94.4%
pow294.4%
metadata-eval94.4%
pow294.4%
metadata-eval94.4%
pow294.4%
metadata-eval94.4%
pow294.4%
Applied egg-rr94.4%
Taylor expanded in x around 0 85.0%
unpow285.0%
Simplified85.0%
if -2.90000000000000008e-50 < y < 3.1000000000000001e-46Initial program 100.0%
sqr-pow99.8%
sqr-pow99.8%
difference-of-squares99.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.1%
unpow298.1%
Simplified98.1%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (<= x 1.35e+154) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 1.35e+154) {
tmp = (y * y) * ((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 (x <= 1.35d+154) then
tmp = (y * y) * ((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 (x <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.35e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.35e+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.35e+154], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 90.9%
sqr-pow90.7%
sqr-pow90.6%
difference-of-squares97.4%
metadata-eval97.4%
pow297.4%
metadata-eval97.4%
pow297.4%
metadata-eval97.4%
pow297.4%
metadata-eval97.4%
pow297.4%
Applied egg-rr97.4%
Taylor expanded in x around 0 67.2%
unpow267.2%
Simplified67.2%
if 1.35000000000000003e154 < x Initial program 64.9%
sqr-pow64.9%
sqr-pow64.9%
difference-of-squares73.0%
metadata-eval73.0%
pow273.0%
metadata-eval73.0%
pow273.0%
metadata-eval73.0%
pow273.0%
metadata-eval73.0%
pow273.0%
Applied egg-rr73.0%
Taylor expanded in x around 0 51.4%
unpow251.4%
Simplified51.4%
Taylor expanded in y around 0 67.6%
unpow267.6%
unpow267.6%
Simplified67.6%
Final simplification67.3%
(FPCore (x y) :precision binary64 (if (or (<= x -9.4e+169) (not (<= x 3.9e+155))) (* (* x x) (* y y)) (* (* y y) (* y (- y)))))
double code(double x, double y) {
double tmp;
if ((x <= -9.4e+169) || !(x <= 3.9e+155)) {
tmp = (x * x) * (y * y);
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-9.4d+169)) .or. (.not. (x <= 3.9d+155))) then
tmp = (x * x) * (y * y)
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -9.4e+169) || !(x <= 3.9e+155)) {
tmp = (x * x) * (y * y);
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -9.4e+169) or not (x <= 3.9e+155): tmp = (x * x) * (y * y) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -9.4e+169) || !(x <= 3.9e+155)) tmp = Float64(Float64(x * x) * Float64(y * y)); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -9.4e+169) || ~((x <= 3.9e+155))) tmp = (x * x) * (y * y); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -9.4e+169], N[Not[LessEqual[x, 3.9e+155]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.4 \cdot 10^{+169} \lor \neg \left(x \leq 3.9 \cdot 10^{+155}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if x < -9.3999999999999995e169 or 3.8999999999999998e155 < x Initial program 69.4%
sqr-pow69.4%
sqr-pow69.4%
difference-of-squares79.0%
metadata-eval79.0%
pow279.0%
metadata-eval79.0%
pow279.0%
metadata-eval79.0%
pow279.0%
metadata-eval79.0%
pow279.0%
Applied egg-rr79.0%
Taylor expanded in x around 0 56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in y around 0 69.4%
unpow269.4%
unpow269.4%
Simplified69.4%
if -9.3999999999999995e169 < x < 3.8999999999999998e155Initial program 92.8%
sqr-pow92.6%
sqr-pow92.5%
difference-of-squares98.7%
metadata-eval98.7%
pow298.7%
metadata-eval98.7%
pow298.7%
metadata-eval98.7%
pow298.7%
metadata-eval98.7%
pow298.7%
Applied egg-rr98.7%
Taylor expanded in x around 0 67.6%
unpow267.6%
Simplified67.6%
Taylor expanded in x around 0 67.7%
unpow267.7%
mul-1-neg67.7%
distribute-rgt-neg-out67.7%
Simplified67.7%
Final simplification68.1%
(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 87.1%
sqr-pow87.0%
sqr-pow86.9%
difference-of-squares93.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
Applied egg-rr93.9%
Taylor expanded in x around 0 64.9%
unpow264.9%
Simplified64.9%
Taylor expanded in y around 0 31.5%
unpow231.5%
unpow231.5%
Simplified31.5%
Final simplification31.5%
herbie shell --seed 2023171
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))