
(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 3 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}
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= x_m 2.8e+82) (- (pow x_m 4.0) (pow y 4.0)) (if (<= x_m 1.3e+93) (- (pow y 4.0)) (pow x_m 4.0))))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 2.8e+82) {
tmp = pow(x_m, 4.0) - pow(y, 4.0);
} else if (x_m <= 1.3e+93) {
tmp = -pow(y, 4.0);
} else {
tmp = pow(x_m, 4.0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (x_m <= 2.8d+82) then
tmp = (x_m ** 4.0d0) - (y ** 4.0d0)
else if (x_m <= 1.3d+93) then
tmp = -(y ** 4.0d0)
else
tmp = x_m ** 4.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (x_m <= 2.8e+82) {
tmp = Math.pow(x_m, 4.0) - Math.pow(y, 4.0);
} else if (x_m <= 1.3e+93) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow(x_m, 4.0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if x_m <= 2.8e+82: tmp = math.pow(x_m, 4.0) - math.pow(y, 4.0) elif x_m <= 1.3e+93: tmp = -math.pow(y, 4.0) else: tmp = math.pow(x_m, 4.0) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 2.8e+82) tmp = Float64((x_m ^ 4.0) - (y ^ 4.0)); elseif (x_m <= 1.3e+93) tmp = Float64(-(y ^ 4.0)); else tmp = x_m ^ 4.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (x_m <= 2.8e+82) tmp = (x_m ^ 4.0) - (y ^ 4.0); elseif (x_m <= 1.3e+93) tmp = -(y ^ 4.0); else tmp = x_m ^ 4.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 2.8e+82], N[(N[Power[x$95$m, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 1.3e+93], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x$95$m, 4.0], $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x_m \leq 2.8 \cdot 10^{+82}:\\
\;\;\;\;{x_m}^{4} - {y}^{4}\\
\mathbf{elif}\;x_m \leq 1.3 \cdot 10^{+93}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x_m}^{4}\\
\end{array}
\end{array}
if x < 2.8e82Initial program 92.1%
if 2.8e82 < x < 1.3e93Initial program 25.0%
Taylor expanded in x around 0 75.4%
neg-mul-175.4%
Simplified75.4%
if 1.3e93 < x Initial program 48.6%
Taylor expanded in x around inf 78.4%
Final simplification89.8%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(if (or (<= (pow y 4.0) 1.05e-28)
(and (not (<= (pow y 4.0) 3.5e+246)) (<= (pow y 4.0) 4e+279)))
(pow x_m 4.0)
(- (pow y 4.0))))x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if ((pow(y, 4.0) <= 1.05e-28) || (!(pow(y, 4.0) <= 3.5e+246) && (pow(y, 4.0) <= 4e+279))) {
tmp = pow(x_m, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (((y ** 4.0d0) <= 1.05d-28) .or. (.not. ((y ** 4.0d0) <= 3.5d+246)) .and. ((y ** 4.0d0) <= 4d+279)) then
tmp = x_m ** 4.0d0
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if ((Math.pow(y, 4.0) <= 1.05e-28) || (!(Math.pow(y, 4.0) <= 3.5e+246) && (Math.pow(y, 4.0) <= 4e+279))) {
tmp = Math.pow(x_m, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if (math.pow(y, 4.0) <= 1.05e-28) or (not (math.pow(y, 4.0) <= 3.5e+246) and (math.pow(y, 4.0) <= 4e+279)): tmp = math.pow(x_m, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (((y ^ 4.0) <= 1.05e-28) || (!((y ^ 4.0) <= 3.5e+246) && ((y ^ 4.0) <= 4e+279))) tmp = x_m ^ 4.0; else tmp = Float64(-(y ^ 4.0)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (((y ^ 4.0) <= 1.05e-28) || (~(((y ^ 4.0) <= 3.5e+246)) && ((y ^ 4.0) <= 4e+279))) tmp = x_m ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[Or[LessEqual[N[Power[y, 4.0], $MachinePrecision], 1.05e-28], And[N[Not[LessEqual[N[Power[y, 4.0], $MachinePrecision], 3.5e+246]], $MachinePrecision], LessEqual[N[Power[y, 4.0], $MachinePrecision], 4e+279]]], N[Power[x$95$m, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 1.05 \cdot 10^{-28} \lor \neg \left({y}^{4} \leq 3.5 \cdot 10^{+246}\right) \land {y}^{4} \leq 4 \cdot 10^{+279}:\\
\;\;\;\;{x_m}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 1.05000000000000003e-28 or 3.49999999999999975e246 < (pow.f64 y 4) < 4.00000000000000023e279Initial program 100.0%
Taylor expanded in x around inf 91.4%
if 1.05000000000000003e-28 < (pow.f64 y 4) < 3.49999999999999975e246 or 4.00000000000000023e279 < (pow.f64 y 4) Initial program 68.5%
Taylor expanded in x around 0 78.3%
neg-mul-178.3%
Simplified78.3%
Final simplification85.0%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (pow x_m 4.0))
x_m = fabs(x);
double code(double x_m, double y) {
return pow(x_m, 4.0);
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = x_m ** 4.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return Math.pow(x_m, 4.0);
}
x_m = math.fabs(x) def code(x_m, y): return math.pow(x_m, 4.0)
x_m = abs(x) function code(x_m, y) return x_m ^ 4.0 end
x_m = abs(x); function tmp = code(x_m, y) tmp = x_m ^ 4.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := N[Power[x$95$m, 4.0], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{x_m}^{4}
\end{array}
Initial program 84.8%
Taylor expanded in x around inf 58.1%
Final simplification58.1%
herbie shell --seed 2024019
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))