
(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 84.4%
sqr-pow84.2%
sqr-pow84.2%
difference-of-squares92.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
Applied egg-rr92.4%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y 1.7e+77) (and (not (<= y 3.6e+100)) (<= y 2.4e+111))) (* (* x x) (* x x)) (* (* y y) (- (+ (* x x) (* y y))))))
double code(double x, double y) {
double tmp;
if ((y <= 1.7e+77) || (!(y <= 3.6e+100) && (y <= 2.4e+111))) {
tmp = (x * x) * (x * x);
} else {
tmp = (y * y) * -((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 ((y <= 1.7d+77) .or. (.not. (y <= 3.6d+100)) .and. (y <= 2.4d+111)) then
tmp = (x * x) * (x * x)
else
tmp = (y * y) * -((x * x) + (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 1.7e+77) || (!(y <= 3.6e+100) && (y <= 2.4e+111))) {
tmp = (x * x) * (x * x);
} else {
tmp = (y * y) * -((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 1.7e+77) or (not (y <= 3.6e+100) and (y <= 2.4e+111)): tmp = (x * x) * (x * x) else: tmp = (y * y) * -((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= 1.7e+77) || (!(y <= 3.6e+100) && (y <= 2.4e+111))) tmp = Float64(Float64(x * x) * Float64(x * x)); else tmp = Float64(Float64(y * y) * Float64(-Float64(Float64(x * x) + Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 1.7e+77) || (~((y <= 3.6e+100)) && (y <= 2.4e+111))) tmp = (x * x) * (x * x); else tmp = (y * y) * -((x * x) + (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 1.7e+77], And[N[Not[LessEqual[y, 3.6e+100]], $MachinePrecision], LessEqual[y, 2.4e+111]]], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * (-N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{+77} \lor \neg \left(y \leq 3.6 \cdot 10^{+100}\right) \land y \leq 2.4 \cdot 10^{+111}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(-\left(x \cdot x + y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 1.69999999999999998e77 or 3.6e100 < y < 2.40000000000000006e111Initial program 90.0%
Taylor expanded in x around inf 68.5%
sqr-pow68.3%
metadata-eval68.3%
pow268.3%
metadata-eval68.3%
pow268.3%
Applied egg-rr68.3%
if 1.69999999999999998e77 < y < 3.6e100 or 2.40000000000000006e111 < y Initial program 57.8%
sqr-pow57.8%
sqr-pow57.8%
difference-of-squares77.8%
metadata-eval77.8%
pow277.8%
metadata-eval77.8%
pow277.8%
metadata-eval77.8%
pow277.8%
metadata-eval77.8%
pow277.8%
Applied egg-rr77.8%
Taylor expanded in x around 0 80.0%
unpow280.0%
mul-1-neg80.0%
distribute-rgt-neg-out80.0%
Simplified80.0%
Final simplification70.4%
(FPCore (x y) :precision binary64 (if (<= y 3.3e+173) (* (* x x) (* x x)) (* (* x x) (* y (- y)))))
double code(double x, double y) {
double tmp;
if (y <= 3.3e+173) {
tmp = (x * x) * (x * x);
} 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 (y <= 3.3d+173) then
tmp = (x * x) * (x * x)
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.3e+173) {
tmp = (x * x) * (x * x);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.3e+173: tmp = (x * x) * (x * x) else: tmp = (x * x) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.3e+173) tmp = Float64(Float64(x * x) * Float64(x * x)); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.3e+173) tmp = (x * x) * (x * x); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.3e+173], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+173}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 3.29999999999999996e173Initial program 87.8%
Taylor expanded in x around inf 65.9%
sqr-pow65.8%
metadata-eval65.8%
pow265.8%
metadata-eval65.8%
pow265.8%
Applied egg-rr65.8%
if 3.29999999999999996e173 < y Initial program 53.8%
sqr-pow53.8%
sqr-pow53.8%
difference-of-squares73.1%
metadata-eval73.1%
pow273.1%
metadata-eval73.1%
pow273.1%
metadata-eval73.1%
pow273.1%
metadata-eval73.1%
pow273.1%
Applied egg-rr73.1%
Taylor expanded in x around 0 92.3%
unpow292.3%
mul-1-neg92.3%
distribute-rgt-neg-out92.3%
Simplified92.3%
Taylor expanded in x around inf 65.4%
mul-1-neg65.4%
unpow265.4%
unpow265.4%
*-commutative65.4%
Simplified65.4%
Final simplification65.7%
(FPCore (x y) :precision binary64 (* (* x x) (* x x)))
double code(double x, double y) {
return (x * x) * (x * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (x * x)
end function
public static double code(double x, double y) {
return (x * x) * (x * x);
}
def code(x, y): return (x * x) * (x * x)
function code(x, y) return Float64(Float64(x * x) * Float64(x * x)) end
function tmp = code(x, y) tmp = (x * x) * (x * x); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 84.4%
Taylor expanded in x around inf 60.1%
sqr-pow59.9%
metadata-eval59.9%
pow259.9%
metadata-eval59.9%
pow259.9%
Applied egg-rr59.9%
Final simplification59.9%
herbie shell --seed 2023223
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))