
(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 1.9e+103) (- (pow x_m 4.0) (pow y 4.0)) (if (<= x_m 1e+141) (- (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 <= 1.9e+103) {
tmp = pow(x_m, 4.0) - pow(y, 4.0);
} else if (x_m <= 1e+141) {
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 <= 1.9d+103) then
tmp = (x_m ** 4.0d0) - (y ** 4.0d0)
else if (x_m <= 1d+141) 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 <= 1.9e+103) {
tmp = Math.pow(x_m, 4.0) - Math.pow(y, 4.0);
} else if (x_m <= 1e+141) {
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 <= 1.9e+103: tmp = math.pow(x_m, 4.0) - math.pow(y, 4.0) elif x_m <= 1e+141: 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 <= 1.9e+103) tmp = Float64((x_m ^ 4.0) - (y ^ 4.0)); elseif (x_m <= 1e+141) 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 <= 1.9e+103) tmp = (x_m ^ 4.0) - (y ^ 4.0); elseif (x_m <= 1e+141) 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, 1.9e+103], N[(N[Power[x$95$m, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 1e+141], (-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 1.9 \cdot 10^{+103}:\\
\;\;\;\;{x\_m}^{4} - {y}^{4}\\
\mathbf{elif}\;x\_m \leq 10^{+141}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{4}\\
\end{array}
\end{array}
if x < 1.8999999999999998e103Initial program 90.2%
if 1.8999999999999998e103 < x < 1.00000000000000002e141Initial program 40.0%
Taylor expanded in x around 0 60.6%
neg-mul-160.6%
Simplified60.6%
if 1.00000000000000002e141 < x Initial program 56.8%
Taylor expanded in x around inf 83.8%
Final simplification88.7%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(if (or (<= (pow x_m 4.0) 6.2e-52)
(and (not (<= (pow x_m 4.0) 1.7e+33)) (<= (pow x_m 4.0) 5.1e+135)))
(- (pow y 4.0))
(pow x_m 4.0)))x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if ((pow(x_m, 4.0) <= 6.2e-52) || (!(pow(x_m, 4.0) <= 1.7e+33) && (pow(x_m, 4.0) <= 5.1e+135))) {
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 ** 4.0d0) <= 6.2d-52) .or. (.not. ((x_m ** 4.0d0) <= 1.7d+33)) .and. ((x_m ** 4.0d0) <= 5.1d+135)) 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 ((Math.pow(x_m, 4.0) <= 6.2e-52) || (!(Math.pow(x_m, 4.0) <= 1.7e+33) && (Math.pow(x_m, 4.0) <= 5.1e+135))) {
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 (math.pow(x_m, 4.0) <= 6.2e-52) or (not (math.pow(x_m, 4.0) <= 1.7e+33) and (math.pow(x_m, 4.0) <= 5.1e+135)): 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 ^ 4.0) <= 6.2e-52) || (!((x_m ^ 4.0) <= 1.7e+33) && ((x_m ^ 4.0) <= 5.1e+135))) 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 ^ 4.0) <= 6.2e-52) || (~(((x_m ^ 4.0) <= 1.7e+33)) && ((x_m ^ 4.0) <= 5.1e+135))) 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[Or[LessEqual[N[Power[x$95$m, 4.0], $MachinePrecision], 6.2e-52], And[N[Not[LessEqual[N[Power[x$95$m, 4.0], $MachinePrecision], 1.7e+33]], $MachinePrecision], LessEqual[N[Power[x$95$m, 4.0], $MachinePrecision], 5.1e+135]]], (-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}^{4} \leq 6.2 \cdot 10^{-52} \lor \neg \left({x\_m}^{4} \leq 1.7 \cdot 10^{+33}\right) \land {x\_m}^{4} \leq 5.1 \cdot 10^{+135}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{4}\\
\end{array}
\end{array}
if (pow.f64 x 4) < 6.1999999999999998e-52 or 1.7e33 < (pow.f64 x 4) < 5.09999999999999982e135Initial program 100.0%
Taylor expanded in x around 0 90.5%
neg-mul-190.5%
Simplified90.5%
if 6.1999999999999998e-52 < (pow.f64 x 4) < 1.7e33 or 5.09999999999999982e135 < (pow.f64 x 4) Initial program 65.2%
Taylor expanded in x around inf 80.0%
Final simplification85.8%
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.4%
Taylor expanded in x around inf 57.6%
Final simplification57.6%
herbie shell --seed 2024050
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))