# Confusion over what indices to contract when deriving Ricci curvature from the curvature tensor?

My question here is just an example of a more general problem I'm having of working in local coordinates, so any help would be appreciated.

I am told that $\mathrm{Ric}_{ij}=g^{kl}R_{iklj}$, where $R_{iklj}$ are the components of the curvature tensor $R$. Here $R$ is considered as a $(0,4)$-tensor, related to $R$ considered as a $(1,3)$-tensor by $$R(X,Y,Z,W)=g(R(X,Y)Z,W)$$

I am slightly confused as to how to obtain $\mathrm{Ric}_{ij}=g^{kl}R_{iklj}$, given the definition of Ricci curvature I've been given: $$\mathrm{Ric}(v,w)=\mathrm{trace}(x\mapsto R(x,v)w).$$ It seems to me that first I want to convert $R$ from its $(0,4)$ form to its $(1,3)$ form, but with $R=R_{iklj}\sigma^i\otimes\sigma^k\otimes\sigma^l\otimes\sigma^j$ I'm not sure which of the factors I should be converting? Suppose for instance I take the second factor, so $$\sigma^k\rightarrow g^{ks} E_s$$ (this is by the usual isomorphism between $TM$ and $T^*M$ on a Riemannian manifold, where $E_i$ is our frame and $\sigma^i$ our coframe). Thus we obtain a $(1,3)$-tensor $$\begin{split} R & = g^{ks}R_{iklj}\sigma^i \otimes E_s \otimes \sigma^l \otimes \sigma^j \\ &= {R_i^{~~s}}_{lj}\,\sigma^i \otimes E_s \otimes \sigma^l \otimes \sigma^j \end{split}$$

Even if this is the correct choice to make, in order to obtain the Ricci tensor (considered as a $(0,2)$-tensor) I must now contract the $E_s$ factor with one of the $\sigma$ factors. Again, I am not sure which factor I should be contracting with to obtain the Ricci tensor. Choosing the $\sigma^l$ factor I obtain

$$S = S_{ij}\sigma^i\otimes \sigma^j$$ where $S_{ij} = {R_i^{~~s}}_{sj}$.

Is this tensor $S$ the Ricci tensor? Does $S_{ij}=g^{kl}R_{iklj}$? How am I to know what choices to make (when working in coordinates as above) when changing tensor types/performing contractions, from the definitions I've been given that are not in coordinates? Thanks in advance.

We have that $x \mapsto R(x,v)w$ is a linear map for fixed $v,w$. We would like to find its matrix, so as to be able to extract its trace, which is the Ricci curvature.
Suppose we have a system of local coördinates $x_1, \ldots, x_n$ about a point $p \in M$ of our manifold, and we take the corresponding local basis of the tangent space $\frac{\partial}{\partial x_1}, \ldots, \frac{\partial}{\partial x_n}$. In these coördinates, we have the curvature tensor field $R_{ijkl}$, which we may also regard as a $C^\infty(M)$-multilinear map $\mathfrak X(M)^4 \to \mathcal C^\infty(M)$. Then we try to compute the trace of the map $$x \mapsto R\left(x,\frac{\partial}{\partial x_i}\right)\frac{\partial}{\partial x_j}.$$ This map, being a linear map between vector spaces, may be written (in the given basis) as a matrix $A \in \mathbb R^{n\times n}$, where we suppose that the linear operator is left-multiplication by $A$. The trace will then be the sum of the diagonal entries of that matrix.
In order to extract the matrix $A$, we note first that we have, denoting the Riemannian metric at $p$ simply by $\langle \cdot, \cdot \rangle$ $$\left\langle R\left(\frac{\partial}{\partial x_i},\frac{\partial}{\partial x_j}\right)\frac{\partial}{\partial x_k}, \frac{\partial}{\partial x_l} \right\rangle = R_{ijkl}$$ by definition. Noting that the matrix of the form $\langle \cdot, \cdot \rangle$ is given by $$\left( \left\langle \frac{\partial}{\partial x_i}, \frac{\partial}{\partial x_j} \right\rangle \right)_{i,j} =: G$$ and that the $i,j$-th entry of its inverse is denoted by $g^{ij}$, we get that the $i$-th column of the matrix $A$ is given by $$\begin{pmatrix} R_{ijk1} & \cdots & R_{ijkn} \end{pmatrix} = \begin{pmatrix} a_{1i} & \cdots & a_{ni} \end{pmatrix}G,$$ and after multiplying by $G^{-1}$ on the right, we get $$\begin{pmatrix} R_{ijk1} & \cdots & R_{ijkn} \end{pmatrix} G^{-1} = \begin{pmatrix} a_{1i} & \cdots & a_{ni} \end{pmatrix}.$$ But the $m$-th entry of left-hand side equals $$R_{ijkl} g^{lm}$$ so that we get $\operatorname{Ric}_{jk} = R_{ijkl} g^{li}$.