
(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 -8e+179) (* (* x x) t_0) (* t_0 (- (* x x) (* y y))))))
double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= -8e+179) {
tmp = (x * x) * t_0;
} else {
tmp = t_0 * ((x * x) - (y * y));
}
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 <= (-8d+179)) then
tmp = (x * x) * t_0
else
tmp = t_0 * ((x * x) - (y * y))
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 <= -8e+179) {
tmp = (x * x) * t_0;
} else {
tmp = t_0 * ((x * x) - (y * y));
}
return tmp;
}
def code(x, y): t_0 = (x * x) + (y * y) tmp = 0 if x <= -8e+179: tmp = (x * x) * t_0 else: tmp = t_0 * ((x * x) - (y * y)) return tmp
function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * y)) tmp = 0.0 if (x <= -8e+179) tmp = Float64(Float64(x * x) * t_0); else tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * x) + (y * y); tmp = 0.0; if (x <= -8e+179) tmp = (x * x) * t_0; else tmp = t_0 * ((x * x) - (y * y)); 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, -8e+179], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq -8 \cdot 10^{+179}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\
\end{array}
\end{array}
if x < -7.99999999999999984e179Initial program 62.5%
sqr-pow62.5%
sqr-pow62.5%
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 95.8%
unpow295.8%
Simplified95.8%
if -7.99999999999999984e179 < x Initial program 90.1%
sqr-pow90.0%
sqr-pow89.9%
difference-of-squares96.3%
metadata-eval96.3%
pow296.3%
metadata-eval96.3%
pow296.3%
metadata-eval96.3%
pow296.3%
metadata-eval96.3%
pow296.3%
Applied egg-rr96.3%
Final simplification96.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.25e+43) (not (<= y 1.2e+16))) (* (* y y) (- (* y (- y)) (* x x))) (* (* x x) (+ (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.25e+43) || !(y <= 1.2e+16)) {
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.25d+43)) .or. (.not. (y <= 1.2d+16))) 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.25e+43) || !(y <= 1.2e+16)) {
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.25e+43) or not (y <= 1.2e+16): 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.25e+43) || !(y <= 1.2e+16)) 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.25e+43) || ~((y <= 1.2e+16))) 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.25e+43], N[Not[LessEqual[y, 1.2e+16]], $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.25 \cdot 10^{+43} \lor \neg \left(y \leq 1.2 \cdot 10^{+16}\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.2500000000000001e43 or 1.2e16 < y Initial program 70.6%
sqr-pow70.6%
sqr-pow70.5%
difference-of-squares87.1%
metadata-eval87.1%
pow287.1%
metadata-eval87.1%
pow287.1%
metadata-eval87.1%
pow287.1%
metadata-eval87.1%
pow287.1%
Applied egg-rr87.1%
Taylor expanded in x around 0 81.6%
unpow281.6%
mul-1-neg81.6%
distribute-rgt-neg-out81.6%
Simplified81.6%
if -1.2500000000000001e43 < y < 1.2e16Initial 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 90.1%
unpow290.1%
Simplified90.1%
Final simplification86.5%
(FPCore (x y) :precision binary64 (if (or (<= y -5.3e+137) (not (<= y 1.8e+151))) (* (* x x) (* y (- y))) (* (* x x) (+ (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if ((y <= -5.3e+137) || !(y <= 1.8e+151)) {
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 <= (-5.3d+137)) .or. (.not. (y <= 1.8d+151))) 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 <= -5.3e+137) || !(y <= 1.8e+151)) {
tmp = (x * x) * (y * -y);
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.3e+137) or not (y <= 1.8e+151): tmp = (x * x) * (y * -y) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.3e+137) || !(y <= 1.8e+151)) 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 <= -5.3e+137) || ~((y <= 1.8e+151))) 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, -5.3e+137], N[Not[LessEqual[y, 1.8e+151]], $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 -5.3 \cdot 10^{+137} \lor \neg \left(y \leq 1.8 \cdot 10^{+151}\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 < -5.29999999999999968e137 or 1.8e151 < y Initial program 67.2%
sqr-pow67.2%
sqr-pow67.2%
difference-of-squares78.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
Applied egg-rr78.1%
Taylor expanded in x around 0 87.5%
unpow287.5%
mul-1-neg87.5%
distribute-rgt-neg-out87.5%
Simplified87.5%
Taylor expanded in x around inf 48.7%
mul-1-neg48.7%
unpow248.7%
unpow248.7%
*-commutative48.7%
Simplified48.7%
if -5.29999999999999968e137 < y < 1.8e151Initial program 94.3%
sqr-pow94.1%
sqr-pow94.0%
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 75.4%
unpow275.4%
Simplified75.4%
Final simplification68.7%
(FPCore (x y) :precision binary64 (if (or (<= x -5.2e+150) (not (<= x 4.6e+115))) (* (* x x) (* y y)) (* (* x x) (* y (- y)))))
double code(double x, double y) {
double tmp;
if ((x <= -5.2e+150) || !(x <= 4.6e+115)) {
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 ((x <= (-5.2d+150)) .or. (.not. (x <= 4.6d+115))) 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 ((x <= -5.2e+150) || !(x <= 4.6e+115)) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -5.2e+150) or not (x <= 4.6e+115): tmp = (x * x) * (y * y) else: tmp = (x * x) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -5.2e+150) || !(x <= 4.6e+115)) tmp = Float64(Float64(x * x) * Float64(y * y)); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -5.2e+150) || ~((x <= 4.6e+115))) tmp = (x * x) * (y * y); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -5.2e+150], N[Not[LessEqual[x, 4.6e+115]], $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}\;x \leq -5.2 \cdot 10^{+150} \lor \neg \left(x \leq 4.6 \cdot 10^{+115}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if x < -5.20000000000000012e150 or 4.60000000000000007e115 < x Initial program 68.0%
sqr-pow68.0%
sqr-pow68.0%
difference-of-squares81.3%
metadata-eval81.3%
pow281.3%
metadata-eval81.3%
pow281.3%
metadata-eval81.3%
pow281.3%
metadata-eval81.3%
pow281.3%
Applied egg-rr81.3%
Taylor expanded in x around inf 92.0%
unpow292.0%
Simplified92.0%
Taylor expanded in x around 0 57.6%
unpow257.6%
unpow257.6%
*-commutative57.6%
Simplified57.6%
if -5.20000000000000012e150 < x < 4.60000000000000007e115Initial program 95.6%
sqr-pow95.4%
sqr-pow95.3%
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 0 80.6%
unpow280.6%
mul-1-neg80.6%
distribute-rgt-neg-out80.6%
Simplified80.6%
Taylor expanded in x around inf 43.1%
mul-1-neg43.1%
unpow243.1%
unpow243.1%
*-commutative43.1%
Simplified43.1%
Final simplification47.4%
(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.5%
sqr-pow87.4%
sqr-pow87.3%
difference-of-squares94.3%
metadata-eval94.3%
pow294.3%
metadata-eval94.3%
pow294.3%
metadata-eval94.3%
pow294.3%
metadata-eval94.3%
pow294.3%
Applied egg-rr94.3%
Taylor expanded in x around inf 59.7%
unpow259.7%
Simplified59.7%
Taylor expanded in x around 0 36.2%
unpow236.2%
unpow236.2%
*-commutative36.2%
Simplified36.2%
Final simplification36.2%
herbie shell --seed 2023182
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))