\[\left(0 \leq x \land x \leq 1.79 \cdot 10^{+308}\right) \land \left(0 \leq y \land y \leq 1.79 \cdot 10^{+308}\right)\]
Math FPCore C Julia Wolfram TeX \[{x}^{y} - {y}^{x}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{expm1}\left(\log x \cdot y\right) - x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(y \cdot 3\right)} - {y}^{\left(x \cdot 3\right)}}{\mathsf{fma}\left({y}^{x}, {y}^{x} + {x}^{y}, {x}^{\left(y \cdot 2\right)}\right)}\\
\end{array}
\]
(FPCore (x y) :precision binary64 (- (pow x y) (pow y x))) ↓
(FPCore (x y)
:precision binary64
(if (<= x 1.9e-11)
(- (expm1 (* (log x) y)) (* x (log y)))
(/
(- (pow x (* y 3.0)) (pow y (* x 3.0)))
(fma (pow y x) (+ (pow y x) (pow x y)) (pow x (* y 2.0)))))) double code(double x, double y) {
return pow(x, y) - pow(y, x);
}
↓
double code(double x, double y) {
double tmp;
if (x <= 1.9e-11) {
tmp = expm1((log(x) * y)) - (x * log(y));
} else {
tmp = (pow(x, (y * 3.0)) - pow(y, (x * 3.0))) / fma(pow(y, x), (pow(y, x) + pow(x, y)), pow(x, (y * 2.0)));
}
return tmp;
}
function code(x, y)
return Float64((x ^ y) - (y ^ x))
end
↓
function code(x, y)
tmp = 0.0
if (x <= 1.9e-11)
tmp = Float64(expm1(Float64(log(x) * y)) - Float64(x * log(y)));
else
tmp = Float64(Float64((x ^ Float64(y * 3.0)) - (y ^ Float64(x * 3.0))) / fma((y ^ x), Float64((y ^ x) + (x ^ y)), (x ^ Float64(y * 2.0))));
end
return tmp
end
code[x_, y_] := N[(N[Power[x, y], $MachinePrecision] - N[Power[y, x], $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_] := If[LessEqual[x, 1.9e-11], N[(N[(Exp[N[(N[Log[x], $MachinePrecision] * y), $MachinePrecision]] - 1), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, N[(y * 3.0), $MachinePrecision]], $MachinePrecision] - N[Power[y, N[(x * 3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Power[y, x], $MachinePrecision] * N[(N[Power[y, x], $MachinePrecision] + N[Power[x, y], $MachinePrecision]), $MachinePrecision] + N[Power[x, N[(y * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
{x}^{y} - {y}^{x}
↓
\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{expm1}\left(\log x \cdot y\right) - x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(y \cdot 3\right)} - {y}^{\left(x \cdot 3\right)}}{\mathsf{fma}\left({y}^{x}, {y}^{x} + {x}^{y}, {x}^{\left(y \cdot 2\right)}\right)}\\
\end{array}
Alternatives Alternative 1 Error 0.3 Cost 40004
\[\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{expm1}\left(\log x \cdot y\right) - x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(y \cdot 3\right)} - {y}^{\left(x \cdot 3\right)}}{{x}^{\left(y \cdot 2\right)} + {y}^{x} \cdot \left({y}^{x} + {x}^{y}\right)}\\
\end{array}
\]
Alternative 2 Error 0.5 Cost 39752
\[\begin{array}{l}
t_0 := {x}^{y} - {y}^{x}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 10^{-12}:\\
\;\;\;\;\log x \cdot y - x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t_0}}\\
\end{array}
\]
Alternative 3 Error 0.5 Cost 39625
\[\begin{array}{l}
t_0 := {x}^{y} - {y}^{x}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-8} \lor \neg \left(t_0 \leq 10^{-12}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\log x \cdot y - x \cdot \log y\\
\end{array}
\]
Alternative 4 Error 10.0 Cost 39497
\[\begin{array}{l}
t_0 := {x}^{y} - {y}^{x}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-14} \lor \neg \left(t_0 \leq 10^{-12}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot \left(-x\right)\\
\end{array}
\]
Alternative 5 Error 0.3 Cost 19780
\[\begin{array}{l}
\mathbf{if}\;x \leq 2.35 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{expm1}\left(\log x \cdot y\right) - x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{{x}^{y} - {y}^{x}}}\\
\end{array}
\]
Alternative 6 Error 19.9 Cost 6920
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{-30}:\\
\;\;\;\;{x}^{y} + -1\\
\mathbf{elif}\;x \leq 2.75 \cdot 10^{-11}:\\
\;\;\;\;\log y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - {y}^{x}\\
\end{array}
\]
Alternative 7 Error 31.4 Cost 6788
\[\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{-11}:\\
\;\;\;\;\log y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - {y}^{x}\\
\end{array}
\]
Alternative 8 Error 52.0 Cost 6656
\[\log y \cdot \left(-x\right)
\]