
(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}
(FPCore (x y) :precision binary64 (if (<= (pow x 4.0) 1e+307) (- (pow x 4.0) (pow y 4.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 1e+307) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = pow(x, 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 ** 4.0d0) <= 1d+307) then
tmp = (x ** 4.0d0) - (y ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.pow(x, 4.0) <= 1e+307) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(x, 4.0) <= 1e+307: tmp = math.pow(x, 4.0) - math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x ^ 4.0) <= 1e+307) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x ^ 4.0) <= 1e+307) tmp = (x ^ 4.0) - (y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 1e+307], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 10^{+307}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 9.99999999999999986e306Initial program 100.0%
if 9.99999999999999986e306 < (pow.f64 x #s(literal 4 binary64)) Initial program 64.4%
Taylor expanded in x around inf 83.2%
(FPCore (x y)
:precision binary64
(if (or (<= (pow x 4.0) 4e-143)
(and (not (<= (pow x 4.0) 2e+122)) (<= (pow x 4.0) 5e+207)))
(- (pow y 4.0))
(pow x 4.0)))
double code(double x, double y) {
double tmp;
if ((pow(x, 4.0) <= 4e-143) || (!(pow(x, 4.0) <= 2e+122) && (pow(x, 4.0) <= 5e+207))) {
tmp = -pow(y, 4.0);
} else {
tmp = pow(x, 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 ** 4.0d0) <= 4d-143) .or. (.not. ((x ** 4.0d0) <= 2d+122)) .and. ((x ** 4.0d0) <= 5d+207)) then
tmp = -(y ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.pow(x, 4.0) <= 4e-143) || (!(Math.pow(x, 4.0) <= 2e+122) && (Math.pow(x, 4.0) <= 5e+207))) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.pow(x, 4.0) <= 4e-143) or (not (math.pow(x, 4.0) <= 2e+122) and (math.pow(x, 4.0) <= 5e+207)): tmp = -math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if (((x ^ 4.0) <= 4e-143) || (!((x ^ 4.0) <= 2e+122) && ((x ^ 4.0) <= 5e+207))) tmp = Float64(-(y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x ^ 4.0) <= 4e-143) || (~(((x ^ 4.0) <= 2e+122)) && ((x ^ 4.0) <= 5e+207))) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Power[x, 4.0], $MachinePrecision], 4e-143], And[N[Not[LessEqual[N[Power[x, 4.0], $MachinePrecision], 2e+122]], $MachinePrecision], LessEqual[N[Power[x, 4.0], $MachinePrecision], 5e+207]]], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 4 \cdot 10^{-143} \lor \neg \left({x}^{4} \leq 2 \cdot 10^{+122}\right) \land {x}^{4} \leq 5 \cdot 10^{+207}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 3.9999999999999998e-143 or 2.00000000000000003e122 < (pow.f64 x #s(literal 4 binary64)) < 4.9999999999999999e207Initial program 100.0%
Taylor expanded in x around 0 95.6%
neg-mul-195.6%
Simplified95.6%
if 3.9999999999999998e-143 < (pow.f64 x #s(literal 4 binary64)) < 2.00000000000000003e122 or 4.9999999999999999e207 < (pow.f64 x #s(literal 4 binary64)) Initial program 72.7%
Taylor expanded in x around inf 81.1%
Final simplification88.1%
(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 85.9%
Taylor expanded in x around inf 60.5%
herbie shell --seed 2024110
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))