
(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 (if (<= (pow y 4.0) 2e+287) (- (pow x 4.0) (pow y 4.0)) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if (pow(y, 4.0) <= 2e+287) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y ** 4.0d0) <= 2d+287) then
tmp = (x ** 4.0d0) - (y ** 4.0d0)
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.pow(y, 4.0) <= 2e+287) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(y, 4.0) <= 2e+287: tmp = math.pow(x, 4.0) - math.pow(y, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((y ^ 4.0) <= 2e+287) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); else tmp = Float64(-(y ^ 4.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y ^ 4.0) <= 2e+287) tmp = (x ^ 4.0) - (y ^ 4.0); else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[y, 4.0], $MachinePrecision], 2e+287], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 2 \cdot 10^{+287}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y #s(literal 4 binary64)) < 2.0000000000000002e287Initial program 100.0%
if 2.0000000000000002e287 < (pow.f64 y #s(literal 4 binary64)) Initial program 70.2%
Taylor expanded in x around 0 86.9%
neg-mul-186.9%
Simplified86.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1.75e-71) (not (<= x 1.75e+31))) (pow x 4.0) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.75e-71) || !(x <= 1.75e+31)) {
tmp = pow(x, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.75d-71)) .or. (.not. (x <= 1.75d+31))) then
tmp = x ** 4.0d0
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.75e-71) || !(x <= 1.75e+31)) {
tmp = Math.pow(x, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.75e-71) or not (x <= 1.75e+31): tmp = math.pow(x, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.75e-71) || !(x <= 1.75e+31)) tmp = x ^ 4.0; else tmp = Float64(-(y ^ 4.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.75e-71) || ~((x <= 1.75e+31))) tmp = x ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.75e-71], N[Not[LessEqual[x, 1.75e+31]], $MachinePrecision]], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-71} \lor \neg \left(x \leq 1.75 \cdot 10^{+31}\right):\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if x < -1.75e-71 or 1.75e31 < x Initial program 81.1%
Taylor expanded in x around inf 78.8%
if -1.75e-71 < x < 1.75e31Initial program 100.0%
Taylor expanded in x around 0 94.8%
neg-mul-194.8%
Simplified94.8%
Final simplification86.5%
(FPCore (x y) :precision binary64 (pow x 4.0))
double code(double x, double y) {
return pow(x, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x ** 4.0d0
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0);
}
def code(x, y): return math.pow(x, 4.0)
function code(x, y) return x ^ 4.0 end
function tmp = code(x, y) tmp = x ^ 4.0; end
code[x_, y_] := N[Power[x, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{4}
\end{array}
Initial program 90.2%
Taylor expanded in x around inf 57.5%
(FPCore (x y) :precision binary64 0.0)
double code(double x, double y) {
return 0.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.0d0
end function
public static double code(double x, double y) {
return 0.0;
}
def code(x, y): return 0.0
function code(x, y) return 0.0 end
function tmp = code(x, y) tmp = 0.0; end
code[x_, y_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 90.2%
Taylor expanded in x around 0 57.4%
neg-mul-157.4%
Simplified57.4%
add-sqr-sqrt14.0%
sqrt-unprod20.7%
sqr-neg20.7%
sqrt-unprod19.2%
add-log-exp24.1%
add-sqr-sqrt24.1%
add-sqr-sqrt24.1%
sqrt-unprod24.1%
*-un-lft-identity24.1%
exp-prod24.1%
add-sqr-sqrt24.1%
sqrt-unprod24.1%
sqr-neg24.1%
sqrt-unprod14.0%
add-sqr-sqrt14.6%
exp-prod14.6%
*-un-lft-identity14.6%
exp-neg14.6%
rgt-mult-inverse15.4%
Applied egg-rr15.4%
herbie shell --seed 2024160
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))