
(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 x 4.0) (pow y 4.0)) -5e-321) (* (pow y 4.0) (+ (/ (pow x 4.0) (pow y 4.0)) -1.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if ((pow(x, 4.0) - pow(y, 4.0)) <= -5e-321) {
tmp = pow(y, 4.0) * ((pow(x, 4.0) / pow(y, 4.0)) + -1.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) - (y ** 4.0d0)) <= (-5d-321)) then
tmp = (y ** 4.0d0) * (((x ** 4.0d0) / (y ** 4.0d0)) + (-1.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) - Math.pow(y, 4.0)) <= -5e-321) {
tmp = Math.pow(y, 4.0) * ((Math.pow(x, 4.0) / Math.pow(y, 4.0)) + -1.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -5e-321: tmp = math.pow(y, 4.0) * ((math.pow(x, 4.0) / math.pow(y, 4.0)) + -1.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -5e-321) tmp = Float64((y ^ 4.0) * Float64(Float64((x ^ 4.0) / (y ^ 4.0)) + -1.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x ^ 4.0) - (y ^ 4.0)) <= -5e-321) tmp = (y ^ 4.0) * (((x ^ 4.0) / (y ^ 4.0)) + -1.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -5e-321], N[(N[Power[y, 4.0], $MachinePrecision] * N[(N[(N[Power[x, 4.0], $MachinePrecision] / N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -5 \cdot 10^{-321}:\\
\;\;\;\;{y}^{4} \cdot \left(\frac{{x}^{4}}{{y}^{4}} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.99994e-321Initial program 100.0%
Taylor expanded in y around inf 100.0%
if -4.99994e-321 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) Initial program 83.0%
Taylor expanded in x around inf 91.5%
Final simplification94.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (- (pow x 4.0) (pow y 4.0)))) (if (<= t_0 INFINITY) t_0 (- (pow y 4.0)))))
double code(double x, double y) {
double t_0 = pow(x, 4.0) - pow(y, 4.0);
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = Math.pow(x, 4.0) - Math.pow(y, 4.0);
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): t_0 = math.pow(x, 4.0) - math.pow(y, 4.0) tmp = 0 if t_0 <= math.inf: tmp = t_0 else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) t_0 = Float64((x ^ 4.0) - (y ^ 4.0)) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; else tmp = Float64(-(y ^ 4.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x ^ 4.0) - (y ^ 4.0); tmp = 0.0; if (t_0 <= Inf) tmp = t_0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], t$95$0, (-N[Power[y, 4.0], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{4} - {y}^{4}\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < +inf.0Initial program 100.0%
if +inf.0 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) Initial program 0.0%
Taylor expanded in x around 0 50.0%
neg-mul-150.0%
Simplified50.0%
(FPCore (x y) :precision binary64 (if (<= (pow x 4.0) 1.06e+18) (- (pow y 4.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 1.06e+18) {
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) <= 1.06d+18) 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) <= 1.06e+18) {
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) <= 1.06e+18: 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) <= 1.06e+18) 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) <= 1.06e+18) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 1.06e+18], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 1.06 \cdot 10^{+18}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 1.06e18Initial program 100.0%
Taylor expanded in x around 0 91.6%
neg-mul-191.6%
Simplified91.6%
if 1.06e18 < (pow.f64 x #s(literal 4 binary64)) Initial program 79.8%
Taylor expanded in x around inf 79.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 89.8%
Taylor expanded in x around inf 55.9%
herbie shell --seed 2024100
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))