
(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}
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.28e+154) (* (+ (* x x) (* y y)) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.28e+154) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (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 <= 1.28d+154) then
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.28e+154) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.28e+154: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.28e+154) tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.28e+154) tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.28e+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[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.28 \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)\right)\\
\end{array}
\end{array}
if y < 1.2800000000000001e154Initial program 89.7%
sqr-pow89.6%
sqr-pow89.5%
difference-of-squares95.3%
metadata-eval95.3%
pow295.3%
metadata-eval95.3%
pow295.3%
metadata-eval95.3%
pow295.3%
metadata-eval95.3%
pow295.3%
Applied egg-rr95.3%
if 1.2800000000000001e154 < y Initial program 48.5%
Taylor expanded in x around 0 78.8%
neg-mul-178.8%
Simplified78.8%
sqr-pow78.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
Applied egg-rr78.8%
Final simplification93.2%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (or (<= x 7.8e+148) (and (not (<= x 1.95e+164)) (<= x 1.4e+175))) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
y = abs(y);
double code(double x, double y) {
double tmp;
if ((x <= 7.8e+148) || (!(x <= 1.95e+164) && (x <= 1.4e+175))) {
tmp = (y * y) * (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 ((x <= 7.8d+148) .or. (.not. (x <= 1.95d+164)) .and. (x <= 1.4d+175)) then
tmp = (y * y) * (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 ((x <= 7.8e+148) || (!(x <= 1.95e+164) && (x <= 1.4e+175))) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if (x <= 7.8e+148) or (not (x <= 1.95e+164) and (x <= 1.4e+175)): tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if ((x <= 7.8e+148) || (!(x <= 1.95e+164) && (x <= 1.4e+175))) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = 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 <= 7.8e+148) || (~((x <= 1.95e+164)) && (x <= 1.4e+175))) tmp = (y * y) * (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[Or[LessEqual[x, 7.8e+148], And[N[Not[LessEqual[x, 1.95e+164]], $MachinePrecision], LessEqual[x, 1.4e+175]]], N[(N[(y * y), $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}\;x \leq 7.8 \cdot 10^{+148} \lor \neg \left(x \leq 1.95 \cdot 10^{+164}\right) \land x \leq 1.4 \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 < 7.80000000000000004e148 or 1.94999999999999993e164 < x < 1.4000000000000001e175Initial program 85.7%
Taylor expanded in x around 0 64.7%
neg-mul-164.7%
Simplified64.7%
sqr-pow64.6%
metadata-eval64.6%
pow264.6%
metadata-eval64.6%
pow264.6%
Applied egg-rr64.6%
if 7.80000000000000004e148 < x < 1.94999999999999993e164 or 1.4000000000000001e175 < x Initial program 75.0%
sqr-pow75.0%
sqr-pow75.0%
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 90.6%
unpow290.6%
Simplified90.6%
Taylor expanded in x around 0 68.8%
unpow268.8%
unpow268.8%
*-commutative68.8%
Simplified68.8%
Final simplification65.1%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.15e-12) (* (* x x) (+ (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.15e-12) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (y * y) * (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 <= 1.15d-12) then
tmp = (x * x) * ((x * x) + (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.15e-12) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.15e-12: tmp = (x * x) * ((x * x) + (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.15e-12) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.15e-12) tmp = (x * x) * ((x * x) + (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.15e-12], N[(N[(x * x), $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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{-12}:\\
\;\;\;\;\left(x \cdot x\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.14999999999999995e-12Initial program 89.3%
sqr-pow89.2%
sqr-pow89.1%
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 68.6%
unpow268.6%
Simplified68.6%
if 1.14999999999999995e-12 < y Initial program 68.3%
Taylor expanded in x around 0 75.1%
neg-mul-175.1%
Simplified75.1%
sqr-pow74.9%
metadata-eval74.9%
pow274.9%
metadata-eval74.9%
pow274.9%
Applied egg-rr74.9%
Final simplification70.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 84.4%
sqr-pow84.3%
sqr-pow84.2%
difference-of-squares91.2%
metadata-eval91.2%
pow291.2%
metadata-eval91.2%
pow291.2%
metadata-eval91.2%
pow291.2%
metadata-eval91.2%
pow291.2%
Applied egg-rr91.2%
Taylor expanded in x around inf 58.5%
unpow258.5%
Simplified58.5%
Taylor expanded in x around 0 36.5%
unpow236.5%
unpow236.5%
*-commutative36.5%
Simplified36.5%
Final simplification36.5%
herbie shell --seed 2023279
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))