<s>[INST] Find the symmetric matrix given its eigenvalues and eigenvector. 
$A$ is a $3 \times 3$ symmetric matrix. It has the eigenvalue $\lambda_1 = 3$ with the eigenvector
$$
\begin{bmatrix} 
1 \\ 0 \\ -1 
\end{bmatrix}
$$
and a double eigenvalue $\lambda_2 = -1$.
Find the matrix $A$.

Since $A$ is symmetric, it can be diagonalized orthogonally, with an orthogonal matrix $P$ as $A = PDP^T$. The matrix is made of the eigenvectors that are orthogonal to each other. What I then did was with the help of inner product, I got a vector that is orthogonal to $v_1$ and with the help of cross product I got another orthogonal vector. Those vectors are
$$
\begin{bmatrix} 
1 \\ 1 \\ 1 
\end{bmatrix}
\quad\text{and}\quad 
\begin{bmatrix} 
1 \\ -2 \\ 1 
\end{bmatrix}
$$
so
$$
A = PDP^{-1} 
= \begin{bmatrix} 
 1 &  1 & -5 \\ 
 1 & -5 &  1 \\ 
-5 &  1 & -5 
\end{bmatrix}. 
$$
But my answer is wrong obviously since $Av \neq \lambda v$. The answer is
$$
\begin{bmatrix} 
 1 &  0 & -2 \\ 
 0 & -1 &  0 \\ 
-2 &  0 & 1 
\end{bmatrix}
$$
where the vectors are
$v_2 = \begin{bmatrix} 1 & 0 & 1 \end{bmatrix}^T$ and
$\begin{bmatrix} 0 & 1 & 0 \end{bmatrix}^T$. The answer sheet says that these vectors are orthogonal to $v_1$. Also they didn't do $A = PDP^T$ instead they did $A = PDP^{-1}$. Can anyone help me understand?
 [/INST] Since $3, -1, -1$ are all eigenvalues of $A$, $4, 0, 0$ are all eigenvalues of the matrix $A + I$, which means the rank of the symmetric matrix $A + I$ is $1$, hence $A + I = vv^T$ for some length-$3$ vector $v$.
Denote $\begin{bmatrix} 1 & 0 & -1 \end{bmatrix}^T$ by $w$, $Aw = 3w$ and $A + I = vv^T$ implies that
\begin{align}
Aw + w = 3w + w = 4w = vv^Tw,
\end{align}
i.e.,
\begin{align}
vv^Tw = 4w. \tag{1}
\end{align}
In other words:
\begin{align}
(v^Tw)v = 4w. \tag{2}
\end{align}
Since $w \neq 0$, $(2)$ implies that $v^Tw \neq 0$, hence $v$ is a multiple of $w$, say $v = \lambda w$. Multiply both sides in equation $(1)$ by $v^T$, we have
\begin{align}
v^Tvv^Tw = 4v^Tw, \text{ or } v^Tw(v^Tv - 4) = 0.
\end{align}
Since $v^Tw \neq 0$, it follows that $v^Tv = \lambda^2w^Tw = 4$. Because $w^Tw = 1^2 + 0^2 + (-1)^2 = 2$, it follows that $\lambda^2 = 4/2 = 2$. Therefore,
\begin{align}
 & A = vv^T - I = \lambda^2ww^T - I = \\
=& 2\begin{bmatrix} 1 \\ 0 \\ - 1\end{bmatrix}\begin{bmatrix} 1 & 0 & - 1\end{bmatrix} - \operatorname{diag}(1, 1, 1) \\
=& \begin{bmatrix} 
2 & 0 & -2 \\
0 & 0 & 0 \\
-2 & 0 & 2 
\end{bmatrix} - 
\begin{bmatrix} 
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 
\end{bmatrix} \\
=& \begin{bmatrix} 
1 & 0 & -2 \\
0 & -1 & 0 \\
-2 & 0 & 1  
\end{bmatrix}.
\end{align}
</s>