Find a positive matrix near a non-negative matrix Here is my question:
Suppose that $A=\left(a_{ij}\right)\in M_n(\mathbb{R})$ is a symmetric matrix with  non-negative entries. Let $$\lambda_1,\lambda_2, \dots, \lambda_n$$
be the eigenvalues of $A$ satisfying that
$$\lambda_1 > 0 \geq \lambda_2 \geq  \dots\geq  \lambda_n.$$
For any $\epsilon>0$, can I find another symmetric matrix  $B=\left(b_{ij}\right)\in M_n(\mathbb{R})$ with positive entries such that

*

*The eigenvalues of $B$ satisfying that
$$\mu_1 > 0 > \mu_2 \geq  \dots\geq  \mu_n;$$

*The distance between $A$ and $B$ is small enough, that is,
$$\sum_{i,j}(a_{ij}-b_{ij})^2<\epsilon.$$
In a previous question, I state this problem in the wrong way. I am fixing it here. Any help will be appreciated.:)
 A: Yes. By permuting the rows and columns of $A$ simultaneously, we may assume that $A=A_r\oplus0$, where $A_r$ is some $r\times r$ irreducible matrix whose indices of inertia are $(n_+,n_-)=(1,r-1)$.
Let $\gamma=\frac{\epsilon}{n-r+1}$ and let $A_r=Q\,\operatorname{diag}(\rho(A),\lambda_2,\ldots,\lambda_r)\,Q^T$ be an orthogonal diagonalisation, where the first column of $Q=\pmatrix{u_r&V}$ is the Perron vector of $A_r$. Pick any sufficiently small $t>0$ such that $tu_ru_r^T-t^2VV^T$ is entrywise positive (this is possible because $u_r$ is a positive vector) and $\|tu_ru_r^T-t^2VV^T\|_F^2<\gamma$. Let
\begin{aligned}
B_r&=A_r+Q\,\operatorname{diag}(t,-t^2,\ldots,-t^2)\,Q^T\\
&=Q\,\operatorname{diag}(\rho(A_r)+t,\,\lambda_2-t^2,\ldots,\,\lambda_r-t^2)\,Q^T.
\end{aligned}
Clearly $B_r$ is symmetric and it has the same Perron vector and indices of inertia as $A_r$, but unlike $A_r$, this $B_r$ is entrywise positive because
$$
B_r-A_r=Q\,\operatorname{diag}(t,-t^2,\ldots,-t^2)\,Q^T=tu_ru_r^T-t^2VV^T
$$
is entrywise positive. Also, note that $\|A_r-B_r\|_F^2=\|tu_ru_r^T-t^2VV^T\|_F^2<\gamma$.
$B_r$ is only $r\times r$, not $n\times n$. We now try to enlarge its size and grow the number of negative eigenvalues by one. Pick a sufficiently small number $t_r>0$ such that $\frac{1}{t_r}>\rho(B_r)$ and $2t_r^2+t_r^6<\gamma$. Define
$$
B_{r+1}=\pmatrix{B_r&t_ru_r\\ t_{r+1}u_r^T&t_r^3}\in M_{r+1}(\mathbb R).
$$
Clearly $B_{r+1}$ is symmetric and entrywise positive. It is also congruent to $\left(B_r-\frac{1}{t_r}u_ru_r^T\right)\oplus t_r^3$. Since $\frac{1}{t_r}>\rho(B_r)$ and all eigenvalues except $\rho(B_r)$ are negative, $B_r-\frac{1}{t_r}u_ru_r^T$ is negative definite. It follows that the indices of inertia of $B_{r+1}$ are $(n_+,n_-)=(1,r)$.
Similarly, if we take $u_{r+1}$ as the Perron unit vector of $B_{r+1}$ and pick some $t_{r+1}>0$ such that $\frac{1}{t_{r+1}}>\rho(B_{r+1})$ and $2t_{r+1}^2+t_{r+1}^6<\gamma$, we can construct some $B_{r+2}\in M_{r+2}(\mathbb R)$ whose indices of inertia are $(n_+,n_-)=(1,r+1)$. Continue in this manner, we can finally obtain a symmetric and entrywise positive matrix $B_n\in M_n(\mathbb R)$ with one positive eigenvalue and $n-1$ negative eigenvalues. By construction, we have
$$
\|A-B_n\|_F^2
=\|A_r-B_r\|_F^2+\sum_{k=r}^{n-1}(2t_k^2+t_k^6)
<(n-r+1)\gamma=\epsilon.
$$
Hence we may take $B=B_n$.
