I'm reading Petersen's Riemannian geometry. Here the Ricci curvature is defined as the trace of $R$, where $R$ is the curvature tensor. More precisely,if $e_1,...e_n \in T_p M $ is an orthonormal basis,then $$\begin{align} \mathrm{Ric}(v,w)&=\mathrm{tr}(x \rightarrow R(x,v)w) \tag1\\ &=\sum_{i=1}^n g(R(e_i,v)w,e_i) \tag2\\ \end{align}$$
Here is my confusion:
Why $(1)$ implies $(2)$? I've referred some books about tensor's trace or contraction but I cannot figure it out in a good way.
The same as the definition of Scalar curvature, which is the trace of Ricci curvature. More precisely: $$\begin{align} \mathrm{Scal}&=\mathrm{tr}(\mathrm{Ric}) \tag3\\ &=\sum_{i,j=1}^n g(R(e_i,e_j)e_j,e_i) \tag4\\ &=2\sum_{i\lt j} \mathrm{sec}(e_i,e_j) \tag5\\ \end{align}$$
Why $(3)$ can imply $(4)$ and $(5)$?
Also, if conveniently, can anyone else give me a good reference or notes for tensors? I'm not habituated to the language of tensors, thanks.