
(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}
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (+ (* x x) (* y y)))) (if (<= x 1.05e+150) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
x = abs(x);
double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 1.05e+150) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
NOTE: x 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) :: t_0
real(8) :: tmp
t_0 = (x * x) + (y * y)
if (x <= 1.05d+150) then
tmp = t_0 * ((x * x) - (y * y))
else
tmp = (x * x) * t_0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 1.05e+150) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = (x * x) + (y * y) tmp = 0 if x <= 1.05e+150: tmp = t_0 * ((x * x) - (y * y)) else: tmp = (x * x) * t_0 return tmp
x = abs(x) function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * y)) tmp = 0.0 if (x <= 1.05e+150) tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * t_0); end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = (x * x) + (y * y); tmp = 0.0; if (x <= 1.05e+150) tmp = t_0 * ((x * x) - (y * y)); else tmp = (x * x) * t_0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.05e+150], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 1.05 \cdot 10^{+150}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\
\end{array}
\end{array}
if x < 1.04999999999999999e150Initial program 87.8%
sqr-pow87.7%
sqr-pow87.5%
difference-of-squares97.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
Applied egg-rr97.0%
if 1.04999999999999999e150 < x Initial program 45.7%
sqr-pow45.7%
sqr-pow45.7%
difference-of-squares62.9%
metadata-eval62.9%
pow262.9%
metadata-eval62.9%
pow262.9%
metadata-eval62.9%
pow262.9%
metadata-eval62.9%
pow262.9%
Applied egg-rr62.9%
Taylor expanded in x around inf 82.9%
unpow282.9%
Simplified82.9%
Final simplification95.1%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 5.6e-52)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 1.65e+137)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))x = abs(x);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-52) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.65e+137) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
NOTE: x 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 <= 5.6d-52) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 1.65d+137) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (y <= 5.6e-52) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.65e+137) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if y <= 5.6e-52: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 1.65e+137: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (y <= 5.6e-52) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 1.65e+137) 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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.6e-52) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 1.65e+137) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[y, 5.6e-52], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e+137], 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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-52}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+137}:\\
\;\;\;\;\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 < 5.59999999999999989e-52Initial program 89.8%
sqr-pow89.6%
sqr-pow89.6%
difference-of-squares93.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
Applied egg-rr93.5%
Taylor expanded in x around inf 68.5%
unpow268.5%
Simplified68.5%
if 5.59999999999999989e-52 < y < 1.65000000000000001e137Initial program 76.5%
sqr-pow76.3%
sqr-pow76.0%
difference-of-squares99.5%
metadata-eval99.5%
pow299.5%
metadata-eval99.5%
pow299.5%
metadata-eval99.5%
pow299.5%
metadata-eval99.5%
pow299.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 90.5%
unpow290.5%
Simplified90.5%
if 1.65000000000000001e137 < y Initial program 44.8%
sqr-pow44.8%
sqr-pow44.8%
difference-of-squares72.4%
metadata-eval72.4%
pow272.4%
metadata-eval72.4%
pow272.4%
metadata-eval72.4%
pow272.4%
metadata-eval72.4%
pow272.4%
Applied egg-rr72.4%
Taylor expanded in x around 0 72.4%
unpow272.4%
Simplified72.4%
Taylor expanded in x around 0 86.2%
unpow286.2%
mul-1-neg86.2%
distribute-rgt-neg-out86.2%
Simplified86.2%
Final simplification74.9%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (or (<= x 4e+131) (and (not (<= x 2.8e+175)) (<= x 7e+180))) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if ((x <= 4e+131) || (!(x <= 2.8e+175) && (x <= 7e+180))) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
NOTE: x 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 <= 4d+131) .or. (.not. (x <= 2.8d+175)) .and. (x <= 7d+180)) then
tmp = (y * y) * (y * -y)
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if ((x <= 4e+131) || (!(x <= 2.8e+175) && (x <= 7e+180))) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if (x <= 4e+131) or (not (x <= 2.8e+175) and (x <= 7e+180)): tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if ((x <= 4e+131) || (!(x <= 2.8e+175) && (x <= 7e+180))) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 4e+131) || (~((x <= 2.8e+175)) && (x <= 7e+180))) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[Or[LessEqual[x, 4e+131], And[N[Not[LessEqual[x, 2.8e+175]], $MachinePrecision], LessEqual[x, 7e+180]]], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{+131} \lor \neg \left(x \leq 2.8 \cdot 10^{+175}\right) \land x \leq 7 \cdot 10^{+180}:\\
\;\;\;\;\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.9999999999999996e131 or 2.8000000000000001e175 < x < 6.9999999999999996e180Initial program 86.9%
sqr-pow86.8%
sqr-pow86.7%
difference-of-squares95.7%
metadata-eval95.7%
pow295.7%
metadata-eval95.7%
pow295.7%
metadata-eval95.7%
pow295.7%
metadata-eval95.7%
pow295.7%
Applied egg-rr95.7%
Taylor expanded in x around 0 72.7%
unpow272.7%
Simplified72.7%
Taylor expanded in x around 0 61.8%
unpow261.8%
mul-1-neg61.8%
distribute-rgt-neg-out61.8%
Simplified61.8%
if 3.9999999999999996e131 < x < 2.8000000000000001e175 or 6.9999999999999996e180 < x Initial program 50.0%
sqr-pow50.0%
sqr-pow50.0%
difference-of-squares70.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
Applied egg-rr70.6%
Taylor expanded in x around 0 56.0%
unpow256.0%
Simplified56.0%
Taylor expanded in y around 0 73.7%
unpow273.7%
unpow273.7%
Simplified73.7%
Final simplification63.3%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.05e+150) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.05e+150) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
NOTE: x 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 <= 1.05d+150) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 1.05e+150) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 1.05e+150: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 1.05e+150) 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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.05e+150) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.05e+150], 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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+150}:\\
\;\;\;\;\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 < 1.04999999999999999e150Initial program 87.8%
sqr-pow87.7%
sqr-pow87.5%
difference-of-squares97.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
Applied egg-rr97.0%
Taylor expanded in x around 0 74.0%
unpow274.0%
Simplified74.0%
if 1.04999999999999999e150 < x Initial program 45.7%
sqr-pow45.7%
sqr-pow45.7%
difference-of-squares62.9%
metadata-eval62.9%
pow262.9%
metadata-eval62.9%
pow262.9%
metadata-eval62.9%
pow262.9%
metadata-eval62.9%
pow262.9%
Applied egg-rr62.9%
Taylor expanded in x around 0 48.6%
unpow248.6%
Simplified48.6%
Taylor expanded in y around 0 68.6%
unpow268.6%
unpow268.6%
Simplified68.6%
Final simplification73.2%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* y y)))
x = abs(x);
double code(double x, double y) {
return (x * x) * (y * y);
}
NOTE: x 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
x = Math.abs(x);
public static double code(double x, double y) {
return (x * x) * (y * y);
}
x = abs(x) def code(x, y): return (x * x) * (y * y)
x = abs(x) function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
x = abs(x) function tmp = code(x, y) tmp = (x * x) * (y * y); end
NOTE: x should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 82.0%
sqr-pow81.9%
sqr-pow81.8%
difference-of-squares92.3%
metadata-eval92.3%
pow292.3%
metadata-eval92.3%
pow292.3%
metadata-eval92.3%
pow292.3%
metadata-eval92.3%
pow292.3%
Applied egg-rr92.3%
Taylor expanded in x around 0 70.5%
unpow270.5%
Simplified70.5%
Taylor expanded in y around 0 36.2%
unpow236.2%
unpow236.2%
Simplified36.2%
Final simplification36.2%
herbie shell --seed 2023274
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))