TITLE: Estimate $\sum_{k=1}^{n} k^{k-1} \binom{n}{k} (n-k)^{n+1-k}$
QUESTION [9 upvotes]: I'm interested in estimating
$$X_n=\sum_{k=1}^{n} \binom{n}{k} k^{k-1} (n-k)^{n+1-k}$$
up to and including terms of order $n^n$; that is, I want $f_n$ in
  $X_n=f_n+o\left(n^n\right)$.

The following identity looks very similar but I am not sure how to use it.
$$\sum_{k=0}^n{n \choose k}(k-1)^k(n-k+1)^{n-k-1}= n^n$$
I think the answer should be
$$f_n=\frac{n^n}{2} \left(2+2n-\sqrt{2 \pi n}\right)\;.$$
The question arises from Asymptotics of sum of binomials .
The reason why I am interested is to give the asymptotics of
$$Y=n  + 1 - \sum_{k=1}^{n} k^{k-1} \binom{n}{k} \frac{(n-k)^{n+1-k}}{n^{n}}$$
I believe  that $Y$ equals $1 + \sum_{k=1}^n \frac{n!}{(n-k)!n^k} \sim \sqrt{\frac{\pi n}{2}}$.  (Separate question posted for this identity.)
Update. $X_n$ is oeis A219706.

REPLY [4 votes]: Here is my version (up to computaitonal errors).  Information on Lambert's W function $W(z)$ can be found in (Corless, Gonnet, Hare, Jeffrey, & Knuth, "On the Lambert W Function").  Begin with
\begin{equation*}
-W(-z) = \sum_{n=1}^\infty \frac{n^{n-1}}{n!}\,z^n
\tag{1}
\end{equation*}
The radius of covergence is $e^{-1}$.  It is analytic beyond the circle 
$|z|=e^{-1}$ everywhere except the point $e^{-1}$, where it has a
quadratic branch point.  We may expand at that point:
$$
-W(-z) = 1 - \sqrt{2}(1-ez)^{1/2} + \frac{2}{3}(1-ez)
-\frac{11\sqrt{2}}{36}(1-ez)^{3/2} +\dots
$$
as $z \to e^{-1}$ from the left (that is, $z$ approaches from
inside the circle of convergence).
From (1), differentiate then multiply by $z$ to get
$\sum n^{n} z^n/n!$.  Again, differentiate then multiply by $z$ to get
$\sum n^{n+1} z^n/n!$.  The result is
\begin{equation*}
 \frac{-W(-z)}{\big(1+W(-z)\big)^3}
 =\sum_{n=0}^\infty \frac{n^{n+1}}{n!}z^n
\tag{2}\end{equation*}
Multiply (1) and (2) to get
\begin{align*}
 h(z) &:= \frac{W(-z)^2}{\big(1+W(-z)\big)^3} =
 \sum_{n=1}^\infty \left(\sum_{k=1}^n \frac{k^{k-1}}{k!}\;
 \frac{(n-k)^{n-k+1}}{(n-k)!}\right)z^n
 \\ &=
 \sum_{n=1}^\infty\left(\frac{1}{n!}
 \sum_{k=1}^n \binom{n}{k} k^{k-1}(n-k)^{n-k+1}\right)z^n
 =: \sum_{n=1}^\infty c_n z^n
\tag{3}\end{align*}
The singularity for $h(z)$  nearest the origin is again at $z=e^{-1}$,
and the expansion there is
\begin{align*}
 h(z) = \frac{1}{2\sqrt{2}}(1-ez)^{-3/2}
 &-\frac{1}{2}(1-ez)^{-1}
 -\frac{1}{8\sqrt{2}}(1-ez)^{-1/2}
 \\ &
 +\frac{149}{540}
 -\frac{767}{8640\sqrt{2}}(1-ez)^{1/2} +O\big((1-ez)\big)
\end{align*}
as $z \to e^{-1}$ from the left.
Now, we use a theorem of Szegö (or Darboux?) to deduce the asymptotics
of the coefficents of power series $h(z)$.
(Szegö, Orthogonal Polynomials, Theorem 8.4;
quoted in Wilf, generatingfunctionology, 1st edition,
Theorem 5.3.2).  We have an asymptotic series, as $n \to \infty$
\begin{align*}
 c_n &\approx e^n\Bigg[\frac{1}{2\sqrt{2}}\binom{n+1/2}{n}
 -\frac{1}{2}\binom{n}{n}
 -\frac{1}{8\sqrt{2}}\binom{n-1/2}{n}
 \\ & \qquad\qquad
 +\frac{149}{540}\binom{n-1}{n}
 -\frac{767}{8640\sqrt{2}}\binom{n-3/2}{n} +\dots
 \Bigg]&
 \\ c_n &= e^n
 \Bigg[\frac{1}{2\sqrt{2}}\left(\frac{2}{\sqrt{\pi}}n^{1/2}+
 \frac{3}{4\sqrt{\pi}}n^{-1/2}
 -\frac{7}{64\sqrt{\pi}}n^{-3/2} +O\left(n^{-5/2}\right)\right)
 -\frac{1}{2}\big(1\big)
 \\ & \qquad\qquad
 -\frac{1}{8\sqrt{2}}\left(\frac{1}{\sqrt{\pi}}n^{-1/2}
 -\frac{1}{8\sqrt{\pi}} n^{-3/2}+O\left(n^{-5/2}\right)\right)
 +\frac{149}{540}\big(0\big)
 \\ & \qquad\qquad
 -\frac{767}{8640\sqrt{2}}\left(-\frac{1}{2\sqrt{\pi}}n^{-3/2}
 +O\left(n^{-5/2}\right)\right)
 +O\left(n^{-5/2}\right)\Bigg]
 \\ &=
 e^n\left[\frac{1}{\sqrt{2\pi}}n^{1/2} -\frac{1}{2}
 +\frac{1}{4\sqrt{2\pi}} n^{-1/2}
 +\frac{23}{4320\sqrt{2\pi}}n^{-3/2}
 +O\left(n^{-5/2}\right)\right]
\tag{4}\end{align*}
Now from (3) we see that the required expression is $n! c_n$.
So we need the asymptotic expression
\begin{align*}
 n! &=
 e^{-n} n^n \sqrt{2\pi}\left(
 n^{1/2}+\frac{1}{12}n^{-1/2}+\frac{1}{288}n^{-3/2}
 +O\left(n^{-5/2}\right)
 \right)
\tag{5}\end{align*}
Multiply (4) and (5) to get
\begin{align*}
 &\sum_{k=1}^n \binom{n}{k} k^{k-1}(n-k)^{n-k+1} = n!c_n
 \\ &\qquad =
 n^n\Bigg( n
 -\frac{\sqrt{2\pi}}{2} n^{1/2} + \frac{1}{3}
 -\frac{\sqrt{2\pi}}{24} n^{-1/2}
 +\frac{4}{135}n^{-1}
 -\frac{\sqrt{2\pi}}{576}n^{-3/2}
 +O\left(n^{-2}\right)\Bigg)
\end{align*}