
(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}
(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 89.5%
sqr-pow89.4%
sqr-pow89.2%
difference-of-squares95.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
Applied egg-rr95.5%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x 1.15e-10) (* (* y y) (- (* y y))) (* (* x x) (+ (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if (x <= 1.15e-10) {
tmp = (y * y) * -(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 (x <= 1.15d-10) then
tmp = (y * y) * -(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 (x <= 1.15e-10) {
tmp = (y * y) * -(y * y);
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.15e-10: tmp = (y * y) * -(y * y) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.15e-10) tmp = Float64(Float64(y * y) * Float64(-Float64(y * 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 (x <= 1.15e-10) tmp = (y * y) * -(y * y); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.15e-10], N[(N[(y * y), $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}\;x \leq 1.15 \cdot 10^{-10}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(-y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\end{array}
\end{array}
if x < 1.15000000000000004e-10Initial program 91.4%
Taylor expanded in x around 0 72.6%
neg-mul-172.6%
Simplified72.6%
sqr-pow72.5%
metadata-eval72.5%
pow272.5%
metadata-eval72.5%
pow272.5%
Applied egg-rr72.5%
if 1.15000000000000004e-10 < x Initial program 84.3%
sqr-pow84.2%
sqr-pow84.2%
difference-of-squares91.3%
metadata-eval91.3%
pow291.3%
metadata-eval91.3%
pow291.3%
metadata-eval91.3%
pow291.3%
metadata-eval91.3%
pow291.3%
Applied egg-rr91.3%
Taylor expanded in x around inf 85.6%
unpow285.6%
Simplified85.6%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (<= x 5.9e+84) (* (* y y) (- (* y y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 5.9e+84) {
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.9d+84) 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.9e+84) {
tmp = (y * y) * -(y * y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.9e+84: tmp = (y * y) * -(y * y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 5.9e+84) tmp = Float64(Float64(y * y) * Float64(-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 <= 5.9e+84) tmp = (y * y) * -(y * y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.9e+84], 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.9 \cdot 10^{+84}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(-y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if x < 5.89999999999999984e84Initial program 92.3%
Taylor expanded in x around 0 68.8%
neg-mul-168.8%
Simplified68.8%
sqr-pow68.7%
metadata-eval68.7%
pow268.7%
metadata-eval68.7%
pow268.7%
Applied egg-rr68.7%
if 5.89999999999999984e84 < x Initial program 77.6%
sqr-pow77.6%
sqr-pow77.6%
difference-of-squares87.8%
metadata-eval87.8%
pow287.8%
metadata-eval87.8%
pow287.8%
metadata-eval87.8%
pow287.8%
metadata-eval87.8%
pow287.8%
Applied egg-rr87.8%
Taylor expanded in x around inf 93.9%
unpow293.9%
Simplified93.9%
Taylor expanded in x around 0 50.0%
unpow250.0%
unpow250.0%
Simplified50.0%
Final simplification65.1%
(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 89.5%
sqr-pow89.4%
sqr-pow89.2%
difference-of-squares95.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
Applied egg-rr95.5%
Taylor expanded in x around inf 57.3%
unpow257.3%
Simplified57.3%
Taylor expanded in x around 0 32.0%
unpow232.0%
unpow232.0%
Simplified32.0%
Final simplification32.0%
herbie shell --seed 2023275
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))