
(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}
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.35e+154) (* (+ (* x x) (* y y)) (- (* x x) (* y y))) (* (* y y) (- (* y (- y)) (* x x)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.35e+154) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * ((y * -y) - (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 (y <= 1.35d+154) then
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
else
tmp = (y * y) * ((y * -y) - (x * x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.35e+154) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.35e+154: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) else: tmp = (y * y) * ((y * -y) - (x * x)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.35e+154) tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.35e+154) tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); else tmp = (y * y) * ((y * -y) - (x * x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.35e+154], 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[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\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) - x \cdot x\right)\\
\end{array}
\end{array}
if y < 1.35000000000000003e154Initial program 93.4%
sqr-pow93.2%
sqr-pow93.2%
difference-of-squares97.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
Applied egg-rr97.1%
if 1.35000000000000003e154 < y Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares76.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
Applied egg-rr76.7%
Taylor expanded in x around 0 86.7%
unpow286.7%
mul-1-neg86.7%
Simplified86.7%
Final simplification95.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 4.45e+14) (* (* y y) (- (* y (- y)) (* x x))) (* (* x x) (+ (* x x) (* y y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 4.45e+14) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (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 (x <= 4.45d+14) then
tmp = (y * y) * ((y * -y) - (x * x))
else
tmp = (x * x) * ((x * x) + (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (x <= 4.45e+14) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 4.45e+14: tmp = (y * y) * ((y * -y) - (x * x)) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (x <= 4.45e+14) 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
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4.45e+14) tmp = (y * y) * ((y * -y) - (x * x)); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[x, 4.45e+14], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.45 \cdot 10^{+14}:\\
\;\;\;\;\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 x < 4.45e14Initial program 96.0%
sqr-pow95.9%
sqr-pow95.8%
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%
Taylor expanded in x around 0 72.3%
unpow272.3%
mul-1-neg72.3%
Simplified72.3%
if 4.45e14 < x Initial program 70.4%
sqr-pow70.2%
sqr-pow70.2%
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 77.6%
unpow277.6%
Simplified77.6%
Final simplification73.4%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 7e+158) (* (* x x) (+ (* x x) (* y y))) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 7e+158) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (x * x) * (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 <= 7d+158) then
tmp = (x * x) * ((x * x) + (y * y))
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 7e+158) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 7e+158: tmp = (x * x) * ((x * x) + (y * y)) else: tmp = (x * x) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 7e+158) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7e+158) tmp = (x * x) * ((x * x) + (y * y)); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 7e+158], N[(N[(x * x), $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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+158}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 7.0000000000000003e158Initial program 93.0%
sqr-pow92.9%
sqr-pow92.8%
difference-of-squares96.7%
metadata-eval96.7%
pow296.7%
metadata-eval96.7%
pow296.7%
metadata-eval96.7%
pow296.7%
metadata-eval96.7%
pow296.7%
Applied egg-rr96.7%
Taylor expanded in x around inf 59.2%
unpow259.2%
Simplified59.2%
if 7.0000000000000003e158 < y Initial program 71.4%
sqr-pow71.4%
sqr-pow71.4%
difference-of-squares78.6%
metadata-eval78.6%
pow278.6%
metadata-eval78.6%
pow278.6%
metadata-eval78.6%
pow278.6%
metadata-eval78.6%
pow278.6%
Applied egg-rr78.6%
Taylor expanded in x around 0 89.3%
unpow289.3%
mul-1-neg89.3%
Simplified89.3%
Taylor expanded in x around inf 53.6%
mul-1-neg53.6%
unpow253.6%
unpow253.6%
*-commutative53.6%
Simplified53.6%
Final simplification58.6%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1e+156) (* (* x x) (* y y)) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1e+156) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (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 <= 1d+156) then
tmp = (x * x) * (y * y)
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1e+156) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1e+156: tmp = (x * x) * (y * y) else: tmp = (x * x) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1e+156) tmp = Float64(Float64(x * x) * Float64(y * y)); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1e+156) tmp = (x * x) * (y * y); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1e+156], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+156}:\\
\;\;\;\;\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 y < 9.9999999999999998e155Initial program 93.4%
sqr-pow93.2%
sqr-pow93.2%
difference-of-squares97.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
Applied egg-rr97.1%
Taylor expanded in x around inf 59.3%
unpow259.3%
Simplified59.3%
Taylor expanded in x around 0 33.9%
unpow233.9%
unpow233.9%
*-commutative33.9%
Simplified33.9%
if 9.9999999999999998e155 < y Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares76.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
Applied egg-rr76.7%
Taylor expanded in x around 0 86.7%
unpow286.7%
mul-1-neg86.7%
Simplified86.7%
Taylor expanded in x around inf 53.3%
mul-1-neg53.3%
unpow253.3%
unpow253.3%
*-commutative53.3%
Simplified53.3%
Final simplification36.1%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* y y)))
y = abs(y);
double code(double x, double y) {
return (x * x) * (y * y);
}
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) * (y * y)
end function
y = Math.abs(y);
public static double code(double x, double y) {
return (x * x) * (y * y);
}
y = abs(y) def code(x, y): return (x * x) * (y * y)
y = abs(y) function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
y = abs(y) function tmp = code(x, y) tmp = (x * x) * (y * y); end
NOTE: y should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 90.6%
sqr-pow90.5%
sqr-pow90.4%
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 53.9%
unpow253.9%
Simplified53.9%
Taylor expanded in x around 0 31.5%
unpow231.5%
unpow231.5%
*-commutative31.5%
Simplified31.5%
Final simplification31.5%
herbie shell --seed 2023293
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))