
(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}
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1e+136) (* (pow (hypot x y) 2.0) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1e+136) {
tmp = pow(hypot(x, y), 2.0) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1e+136) {
tmp = Math.pow(Math.hypot(x, y), 2.0) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1e+136: tmp = math.pow(math.hypot(x, y), 2.0) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1e+136) tmp = Float64((hypot(x, y) ^ 2.0) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1e+136) tmp = (hypot(x, y) ^ 2.0) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1e+136], N[(N[Power[N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+136}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 1.00000000000000006e136Initial program 93.6%
sqr-pow93.5%
sqr-pow93.3%
difference-of-squares97.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
Applied egg-rr97.0%
sub-neg97.0%
distribute-lft-in64.6%
add-sqr-sqrt64.6%
pow264.6%
hypot-def64.6%
add-sqr-sqrt64.5%
pow264.5%
hypot-def64.5%
Applied egg-rr64.5%
distribute-lft-out97.0%
sub-neg97.0%
Simplified97.0%
if 1.00000000000000006e136 < y Initial program 59.5%
sqr-pow59.5%
sqr-pow59.5%
difference-of-squares67.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
Applied egg-rr67.6%
Taylor expanded in x around 0 83.8%
unpow283.8%
neg-mul-183.8%
distribute-rgt-neg-in83.8%
Simplified83.8%
Taylor expanded in x around 0 83.8%
unpow283.8%
Simplified83.8%
Final simplification95.1%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 5.7e+138) (* (- (* x x) (* y y)) (+ (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 5.7e+138) {
tmp = ((x * x) - (y * y)) * ((x * x) + (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.7d+138) then
tmp = ((x * x) - (y * y)) * ((x * x) + (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 5.7e+138) {
tmp = ((x * x) - (y * y)) * ((x * x) + (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 5.7e+138: tmp = ((x * x) - (y * y)) * ((x * x) + (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 5.7e+138) tmp = Float64(Float64(Float64(x * x) - Float64(y * y)) * Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.7e+138) tmp = ((x * x) - (y * y)) * ((x * x) + (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 5.7e+138], N[(N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.7 \cdot 10^{+138}:\\
\;\;\;\;\left(x \cdot x - y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 5.69999999999999986e138Initial program 93.6%
sqr-pow93.5%
sqr-pow93.3%
difference-of-squares97.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
Applied egg-rr97.0%
if 5.69999999999999986e138 < y Initial program 59.5%
sqr-pow59.5%
sqr-pow59.5%
difference-of-squares67.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
Applied egg-rr67.6%
Taylor expanded in x around 0 83.8%
unpow283.8%
neg-mul-183.8%
distribute-rgt-neg-in83.8%
Simplified83.8%
Taylor expanded in x around 0 83.8%
unpow283.8%
Simplified83.8%
Final simplification95.1%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 2.45e-46) (* (* y y) (* y (- y))) (* (* x x) (* x x))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 2.45e-46) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (x * x);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.45d-46) then
tmp = (y * y) * (y * -y)
else
tmp = (x * x) * (x * x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (x <= 2.45e-46) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (x * x);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 2.45e-46: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (x * x) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (x <= 2.45e-46) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(x * x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.45e-46) tmp = (y * y) * (y * -y); else tmp = (x * x) * (x * x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[x, 2.45e-46], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.45 \cdot 10^{-46}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if x < 2.45e-46Initial program 91.3%
sqr-pow91.2%
sqr-pow91.0%
difference-of-squares94.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
Applied egg-rr94.8%
Taylor expanded in x around 0 68.8%
unpow268.8%
neg-mul-168.8%
distribute-rgt-neg-in68.8%
Simplified68.8%
Taylor expanded in x around 0 69.2%
unpow269.2%
Simplified69.2%
if 2.45e-46 < x Initial program 81.9%
sqr-pow81.7%
sqr-pow81.7%
difference-of-squares87.3%
metadata-eval87.3%
pow287.3%
metadata-eval87.3%
pow287.3%
metadata-eval87.3%
pow287.3%
metadata-eval87.3%
pow287.3%
Applied egg-rr87.3%
Taylor expanded in x around inf 76.2%
unpow276.2%
Simplified76.2%
Taylor expanded in x around inf 76.3%
unpow276.3%
Simplified76.3%
Final simplification71.2%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* x x)))
y = abs(y);
double code(double x, double y) {
return (x * x) * (x * x);
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (x * x)
end function
y = Math.abs(y);
public static double code(double x, double y) {
return (x * x) * (x * x);
}
y = abs(y) def code(x, y): return (x * x) * (x * x)
y = abs(y) function code(x, y) return Float64(Float64(x * x) * Float64(x * x)) end
y = abs(y) function tmp = code(x, y) tmp = (x * x) * (x * x); end
NOTE: y should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left(x \cdot x\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 88.7%
sqr-pow88.6%
sqr-pow88.4%
difference-of-squares92.7%
metadata-eval92.7%
pow292.7%
metadata-eval92.7%
pow292.7%
metadata-eval92.7%
pow292.7%
metadata-eval92.7%
pow292.7%
Applied egg-rr92.7%
Taylor expanded in x around inf 58.8%
unpow258.8%
Simplified58.8%
Taylor expanded in x around inf 59.1%
unpow259.1%
Simplified59.1%
Final simplification59.1%
herbie shell --seed 2023278
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))