
(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: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 6.5e+153) (* (+ (* 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 <= 6.5e+153) {
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 <= 6.5d+153) 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 <= 6.5e+153) {
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 <= 6.5e+153: 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 <= 6.5e+153) 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 <= 6.5e+153) 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, 6.5e+153], 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 6.5 \cdot 10^{+153}:\\
\;\;\;\;\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 < 6.49999999999999972e153Initial program 87.2%
sqr-pow87.1%
sqr-pow86.9%
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%
if 6.49999999999999972e153 < y 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 86.2%
unpow286.2%
Simplified86.2%
Taylor expanded in x around 0 96.6%
unpow296.6%
mul-1-neg96.6%
distribute-rgt-neg-out96.6%
Simplified96.6%
Final simplification95.8%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 1.6e-35)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 6.5e+153)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.6e-35) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 6.5e+153) {
tmp = (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.6d-35) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 6.5d+153) then
tmp = (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.6e-35) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 6.5e+153) {
tmp = (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.6e-35: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 6.5e+153: tmp = (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.6e-35) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 6.5e+153) 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
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.6e-35) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 6.5e+153) tmp = (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.6e-35], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.5e+153], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-35}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;\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 < 1.5999999999999999e-35Initial program 89.1%
sqr-pow88.9%
sqr-pow88.8%
difference-of-squares94.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
Applied egg-rr94.8%
Taylor expanded in x around inf 64.1%
unpow264.1%
Simplified64.1%
if 1.5999999999999999e-35 < y < 6.49999999999999972e153Initial program 79.5%
sqr-pow79.5%
sqr-pow79.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 91.0%
unpow291.0%
Simplified91.0%
if 6.49999999999999972e153 < y 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 86.2%
unpow286.2%
Simplified86.2%
Taylor expanded in x around 0 96.6%
unpow296.6%
mul-1-neg96.6%
distribute-rgt-neg-out96.6%
Simplified96.6%
Final simplification72.4%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 6.5e+153) (* (* y y) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 6.5e+153) {
tmp = (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 <= 6.5d+153) then
tmp = (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 <= 6.5e+153) {
tmp = (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 <= 6.5e+153: tmp = (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 <= 6.5e+153) 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
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.5e+153) tmp = (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, 6.5e+153], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;\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.49999999999999972e153Initial program 87.2%
sqr-pow87.1%
sqr-pow86.9%
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 69.5%
unpow269.5%
Simplified69.5%
if 6.49999999999999972e153 < y 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 86.2%
unpow286.2%
Simplified86.2%
Taylor expanded in x around 0 96.6%
unpow296.6%
mul-1-neg96.6%
distribute-rgt-neg-out96.6%
Simplified96.6%
Final simplification72.5%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 6.5e+171) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 6.5e+171) {
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 <= 6.5d+171) 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 <= 6.5e+171) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 6.5e+171: 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 <= 6.5e+171) 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 <= 6.5e+171) 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[LessEqual[x, 6.5e+171], 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 6.5 \cdot 10^{+171}:\\
\;\;\;\;\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 < 6.5e171Initial program 89.8%
sqr-pow89.7%
sqr-pow89.5%
difference-of-squares97.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
Applied egg-rr97.5%
Taylor expanded in x around 0 75.4%
unpow275.4%
Simplified75.4%
Taylor expanded in x around 0 68.5%
unpow268.5%
mul-1-neg68.5%
distribute-rgt-neg-out68.5%
Simplified68.5%
if 6.5e171 < x Initial program 54.8%
sqr-pow54.8%
sqr-pow54.8%
difference-of-squares74.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 41.9%
unpow241.9%
Simplified41.9%
Taylor expanded in y around 0 51.6%
unpow251.6%
unpow251.6%
Simplified51.6%
Final simplification66.4%
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 85.5%
sqr-pow85.4%
sqr-pow85.3%
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 0 71.4%
unpow271.4%
Simplified71.4%
Taylor expanded in y around 0 30.0%
unpow230.0%
unpow230.0%
Simplified30.0%
Final simplification30.0%
herbie shell --seed 2023200
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))