
(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 86.7%
sqr-pow86.6%
sqr-pow86.5%
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%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y 6.5e-67)
(* (* 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 <= 6.5e-67) {
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 <= 6.5d-67) 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 <= 6.5e-67) {
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 <= 6.5e-67: 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 <= 6.5e-67) 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 <= 6.5e-67) 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, 6.5e-67], 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 6.5 \cdot 10^{-67}:\\
\;\;\;\;\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 < 6.4999999999999997e-67Initial program 90.7%
sqr-pow90.6%
sqr-pow90.5%
difference-of-squares96.0%
metadata-eval96.0%
pow296.0%
metadata-eval96.0%
pow296.0%
metadata-eval96.0%
pow296.0%
metadata-eval96.0%
pow296.0%
Applied egg-rr96.0%
Taylor expanded in x around inf 72.0%
unpow272.0%
Simplified72.0%
if 6.4999999999999997e-67 < y < 1.35000000000000003e154Initial program 84.8%
sqr-pow84.7%
sqr-pow84.6%
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 0 83.8%
unpow283.8%
Simplified83.8%
if 1.35000000000000003e154 < y Initial program 63.0%
sqr-pow63.0%
sqr-pow63.0%
difference-of-squares74.1%
metadata-eval74.1%
pow274.1%
metadata-eval74.1%
pow274.1%
metadata-eval74.1%
pow274.1%
metadata-eval74.1%
pow274.1%
Applied egg-rr74.1%
Taylor expanded in x around 0 74.1%
unpow274.1%
Simplified74.1%
Taylor expanded in x around 0 88.9%
unpow288.9%
mul-1-neg88.9%
distribute-rgt-neg-out88.9%
Simplified88.9%
Final simplification75.9%
(FPCore (x y) :precision binary64 (if (<= x 2.05e+153) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 2.05e+153) {
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 <= 2.05d+153) 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 <= 2.05e+153) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.05e+153: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.05e+153) 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 <= 2.05e+153) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.05e+153], 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 2.05 \cdot 10^{+153}:\\
\;\;\;\;\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 < 2.05000000000000008e153Initial program 89.7%
sqr-pow89.6%
sqr-pow89.5%
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 0 68.2%
unpow268.2%
Simplified68.2%
if 2.05000000000000008e153 < x Initial program 66.7%
sqr-pow66.7%
sqr-pow66.7%
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 51.5%
unpow251.5%
Simplified51.5%
Taylor expanded in y around 0 60.6%
unpow260.6%
unpow260.6%
Simplified60.6%
Final simplification67.2%
(FPCore (x y) :precision binary64 (if (<= x 5.6e+175) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 5.6e+175) {
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 <= 5.6d+175) 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 <= 5.6e+175) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.6e+175: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 5.6e+175) 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 <= 5.6e+175) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.6e+175], 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 5.6 \cdot 10^{+175}:\\
\;\;\;\;\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 < 5.6000000000000002e175Initial program 88.5%
sqr-pow88.5%
sqr-pow88.3%
difference-of-squares95.4%
metadata-eval95.4%
pow295.4%
metadata-eval95.4%
pow295.4%
metadata-eval95.4%
pow295.4%
metadata-eval95.4%
pow295.4%
Applied egg-rr95.4%
Taylor expanded in x around 0 67.5%
unpow267.5%
Simplified67.5%
Taylor expanded in x around 0 59.6%
unpow259.6%
mul-1-neg59.6%
distribute-rgt-neg-out59.6%
Simplified59.6%
if 5.6000000000000002e175 < x Initial program 72.4%
sqr-pow72.4%
sqr-pow72.4%
difference-of-squares86.2%
metadata-eval86.2%
pow286.2%
metadata-eval86.2%
pow286.2%
metadata-eval86.2%
pow286.2%
metadata-eval86.2%
pow286.2%
Applied egg-rr86.2%
Taylor expanded in x around 0 55.2%
unpow255.2%
Simplified55.2%
Taylor expanded in y around 0 65.5%
unpow265.5%
unpow265.5%
Simplified65.5%
Final simplification60.3%
(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 86.7%
sqr-pow86.6%
sqr-pow86.5%
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 66.1%
unpow266.1%
Simplified66.1%
Taylor expanded in y around 0 34.9%
unpow234.9%
unpow234.9%
Simplified34.9%
Final simplification34.9%
herbie shell --seed 2023252
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))