
(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 y 4.0) INFINITY) (- (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) <= ((double) INFINITY)) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.pow(y, 4.0) <= Double.POSITIVE_INFINITY) {
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) <= math.inf: 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) <= Inf) 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) <= Inf) 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], Infinity], 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 \infty:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y #s(literal 4 binary64)) < +inf.0Initial program 85.9%
if +inf.0 < (pow.f64 y #s(literal 4 binary64)) Initial program 85.9%
Taylor expanded in x around 0 58.0%
neg-mul-158.0%
Simplified58.0%
Final simplification85.9%
(FPCore (x y)
:precision binary64
(if (or (<= (pow x 4.0) 2.4e-290)
(and (not (<= (pow x 4.0) 8.4e-140)) (<= (pow x 4.0) 2.05e+154)))
(- (pow y 4.0))
(pow x 4.0)))
double code(double x, double y) {
double tmp;
if ((pow(x, 4.0) <= 2.4e-290) || (!(pow(x, 4.0) <= 8.4e-140) && (pow(x, 4.0) <= 2.05e+154))) {
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) <= 2.4d-290) .or. (.not. ((x ** 4.0d0) <= 8.4d-140)) .and. ((x ** 4.0d0) <= 2.05d+154)) 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) <= 2.4e-290) || (!(Math.pow(x, 4.0) <= 8.4e-140) && (Math.pow(x, 4.0) <= 2.05e+154))) {
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) <= 2.4e-290) or (not (math.pow(x, 4.0) <= 8.4e-140) and (math.pow(x, 4.0) <= 2.05e+154)): 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) <= 2.4e-290) || (!((x ^ 4.0) <= 8.4e-140) && ((x ^ 4.0) <= 2.05e+154))) 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) <= 2.4e-290) || (~(((x ^ 4.0) <= 8.4e-140)) && ((x ^ 4.0) <= 2.05e+154))) 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], 2.4e-290], And[N[Not[LessEqual[N[Power[x, 4.0], $MachinePrecision], 8.4e-140]], $MachinePrecision], LessEqual[N[Power[x, 4.0], $MachinePrecision], 2.05e+154]]], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 2.4 \cdot 10^{-290} \lor \neg \left({x}^{4} \leq 8.4 \cdot 10^{-140}\right) \land {x}^{4} \leq 2.05 \cdot 10^{+154}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 2.4000000000000001e-290 or 8.4000000000000007e-140 < (pow.f64 x #s(literal 4 binary64)) < 2.05e154Initial program 100.0%
Taylor expanded in x around 0 92.5%
neg-mul-192.5%
Simplified92.5%
if 2.4000000000000001e-290 < (pow.f64 x #s(literal 4 binary64)) < 8.4000000000000007e-140 or 2.05e154 < (pow.f64 x #s(literal 4 binary64)) Initial program 72.7%
Taylor expanded in x around inf 75.9%
Final simplification83.9%
(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 56.1%
Final simplification56.1%
herbie shell --seed 2024059
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))