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?
 A: (I will use row vectors because they are easier to type and use up less space; interpret them as transposes of the vectors you want)
Symmetric matrices are always orthogonally diagonalizable. So we know that the eigenspace of $-1$ will be the orthogonal complement of the eigenspace of $3$; you know the eigenspace of $3$ is $\mathrm{span}\bigl((1,0,-1)\bigr)$. So a basis of eigenvectors is obtained by finding the orthogonal complement of this span, and taking an basis for it (and you might as well make it orthogonal). There are multiple ways of doing this. The most mindless/automatic is to start with $(1,0,-1)$, complete to a basis, and then apply the orthogonalization part of the Gram-Schmidt process. Doing slightly less work and more thought, we might notice that $(0,1,0)$ and $(1,0,1)$ are both orthogonal to the vector we already had, and also orthogonal to each other, so these two will do, as will any two vectors that are orthogonal to each other and to $(1,0,-1)$. Your choice of $(1,1,1)$ and $(1,-2,1)$ is certainly a valid choice.
Now, if we let $\beta=[(1,0,-1),(1,1,1),(1,-2,1)]$ be an ordered orthogonal basis for $\mathbb{R}^3$, then we know that if $Q$ is the change-of-basis matrix from the standard basis to $\beta$, then
$$QAQ^{-1} = \left(\begin{array}{rrr}
3 & 0 & 0\\
0 & -1 & 0\\
0 & 0 & -1
\end{array}\right).$$
That means that if we let $P$ be the inverse of $Q$, so that $P=Q^{-1}$ is the change-of-basis matrix fvrom $\beta$ to the standard basis, then
$$A = P\left(\begin{array}{rrr}
3 & 0 & 0\\
0 & -1 & 0\\
0 & 0 & -1
\end{array}\right)P^{-1}.$$
I don't know how you did the calculations. The matrix $P$ has the vectors of $\beta$ as columns,
$$P = \left(\begin{array}{rrr}
1 & 1 & 1\\
0 & 1 & -2\\
-1 & 1 & 1
\end{array}\right).$$
Its inverse is given by
$$P^{-1} = \left(\begin{array}{rrr}
\frac{1}{2}_{\vphantom{2_2}} & 0 & -\frac{1}{2}\\
\frac{1}{3}_{\vphantom{2_2}} & \frac{1}{3} & \frac{1}{3}\\
\frac{1}{6} & -\frac{1}{3} & \frac{1}{6}
\end{array}\right),$$
which can be computed by hand (or with a calculator), and verified by multiplying them together. Note that because the columns of $P$ are not an orthonormal basis (although they are mutually orthogonal, the vectors do not have size $1$), the inverse of $P$ is not merely $P^T$.
So we get
$$\begin{align*}
A &= P\left(\begin{array}{rrr}
3 & 0 & 0\\
0 & -1 & 0\\
0 & 0 & -1
\end{array}\right)P^{-1}\\
&= \left(\begin{array}{rrr}
1 & 1 & 1\\
0 & 1 & -2\\
-1 & 1 & 1
\end{array}\right) \left(\begin{array}{rrr}
3 & 0 & 0\\
0 & -1 & 0\\
0 & 0 & -1
\end{array}\right)
\left(\begin{array}{rrr}
\frac{1}{2}_{\vphantom{2_2}} & 0 & -\frac{1}{2}\\
\frac{1}{3}_{\vphantom{2_2}} & \frac{1}{3} & \frac{1}{3}\\
\frac{1}{6} & -\frac{1}{3} & \frac{1}{6}
\end{array}\right)\\
&= \left(\begin{array}{rrr}
3 & -1 & -1\\
0 & -1 & 2\\
-3 & -1 & -1
\end{array}\right)
\left(\begin{array}{rrr}
\frac{1}{2}_{\vphantom{2_2}} & 0 & -\frac{1}{2}\\
\frac{1}{3}_{\vphantom{2_2}} & \frac{1}{3} & \frac{1}{3}\\
\frac{1}{6} & -\frac{1}{3} & \frac{1}{6}
\end{array}\right)\\
&=\left(\begin{array}{rrr}
1 & 0 & -2\\
0 & -1 & 0\\
-2 & 0 & 1
\end{array}\right),
\end{align*}$$
which is the same as the answer they gave.
From what I can tell, you mistakenly compute $PDP^T$ instead of $PDP^{-1}$. Note that because you do not have an orthonormal basis, the inverse of $P$ is not $P^T$, as noted above. That is the source of your error. Had you used $P^{-1}$ instead of $P$, you would have obtained the same matrix $A$.
A: Diagonalization: For a given matrix $A$, if we have a basis of eigenvectors $v_1, v_2, v_3$ of eigenvalues $\lambda_1, \lambda_2, \lambda_3$ (not necessarily distinct), and we form the (invertible) matrix $P$ with columns given by the eigenvectors and the diagonal matrix $D$ with the eigenvalues on the diagonal, then
$$
A = PDP^{-1} 
\tag{1}
$$
If the eigenvectors are orthogonal, the $P^\top P$ is diagonal: the $(i, j)$-entry is the inner product of $v_i$ with $v_j$. Be careful, though: sometimes a matrix is called orthogonal when we should call it orthonormal. That is, not only are distinct columns orthogonal to one another, but also each column has unit length. This puts ones on the diagonal, so in this case, $P^\top P = I$, the identity matrix. Hence $P^{-1} = P^\top$, and they're used interchangeably.
You can scale your eigenvectors to have unit length, but then the entries will likely involve lots of radicals and be messy. Instead, just be content with orthogonal eigenvectors of any nonzero length and be sure to use the true inverse in the change-of-basis formula $(1)$.
A: 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}
