
(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.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%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y 5e-72)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 1.35e+154)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))
double code(double x, double y) {
double tmp;
if (y <= 5e-72) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.35e+154) {
tmp = (y * y) * ((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 (y <= 5d-72) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 1.35d+154) then
tmp = (y * y) * ((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 (y <= 5e-72) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5e-72: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 1.35e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 5e-72) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 1.35e+154) tmp = Float64(Float64(y * y) * 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 (y <= 5e-72) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 1.35e+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5e-72], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+154], N[(N[(y * y), $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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-72}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(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 < 4.9999999999999996e-72Initial program 90.1%
sqr-pow89.9%
sqr-pow89.9%
difference-of-squares96.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
Applied egg-rr96.5%
Taylor expanded in x around inf 70.9%
unpow270.9%
Simplified70.9%
if 4.9999999999999996e-72 < y < 1.35000000000000003e154Initial program 87.8%
sqr-pow87.7%
sqr-pow87.5%
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 90.5%
unpow290.5%
Simplified90.5%
if 1.35000000000000003e154 < y Initial program 73.5%
sqr-pow73.5%
sqr-pow73.5%
difference-of-squares76.5%
metadata-eval76.5%
pow276.5%
metadata-eval76.5%
pow276.5%
metadata-eval76.5%
pow276.5%
metadata-eval76.5%
pow276.5%
Applied egg-rr76.5%
Taylor expanded in x around 0 76.5%
unpow276.5%
Simplified76.5%
Taylor expanded in x around 0 94.1%
unpow294.1%
mul-1-neg94.1%
distribute-rgt-neg-out94.1%
Simplified94.1%
Final simplification77.2%
(FPCore (x y) :precision binary64 (if (<= y 1.35e+154) (* (* y y) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
double code(double x, double y) {
double tmp;
if (y <= 1.35e+154) {
tmp = (y * y) * ((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 (y <= 1.35d+154) then
tmp = (y * y) * ((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 (y <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.35e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.35e+154) tmp = Float64(Float64(y * y) * 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 (y <= 1.35e+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.35e+154], N[(N[(y * y), $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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(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 < 1.35000000000000003e154Initial program 89.6%
sqr-pow89.5%
sqr-pow89.4%
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 0 69.3%
unpow269.3%
Simplified69.3%
if 1.35000000000000003e154 < y Initial program 73.5%
sqr-pow73.5%
sqr-pow73.5%
difference-of-squares76.5%
metadata-eval76.5%
pow276.5%
metadata-eval76.5%
pow276.5%
metadata-eval76.5%
pow276.5%
metadata-eval76.5%
pow276.5%
Applied egg-rr76.5%
Taylor expanded in x around 0 76.5%
unpow276.5%
Simplified76.5%
Taylor expanded in x around 0 94.1%
unpow294.1%
mul-1-neg94.1%
distribute-rgt-neg-out94.1%
Simplified94.1%
Final simplification72.6%
(FPCore (x y) :precision binary64 (if (<= x 3.2e+109) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 3.2e+109) {
tmp = (y * y) * (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 <= 3.2d+109) then
tmp = (y * y) * (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 <= 3.2e+109) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 3.2e+109: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 3.2e+109) tmp = Float64(Float64(y * y) * 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 (x <= 3.2e+109) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 3.2e+109], N[(N[(y * y), $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 3.2 \cdot 10^{+109}:\\
\;\;\;\;\left(y \cdot y\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 x < 3.2000000000000001e109Initial program 91.9%
sqr-pow91.8%
sqr-pow91.7%
difference-of-squares96.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
Applied egg-rr96.6%
Taylor expanded in x around 0 73.4%
unpow273.4%
Simplified73.4%
Taylor expanded in x around 0 65.6%
unpow265.6%
mul-1-neg65.6%
distribute-rgt-neg-out65.6%
Simplified65.6%
if 3.2000000000000001e109 < x Initial program 57.6%
sqr-pow57.6%
sqr-pow57.6%
difference-of-squares78.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
Applied egg-rr78.8%
Taylor expanded in x around 0 48.8%
unpow248.8%
Simplified48.8%
Taylor expanded in y around 0 51.8%
unpow251.8%
unpow251.8%
Simplified51.8%
Final simplification63.8%
(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 0 70.2%
unpow270.2%
Simplified70.2%
Taylor expanded in y around 0 34.1%
unpow234.1%
unpow234.1%
Simplified34.1%
Final simplification34.1%
herbie shell --seed 2023221
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))