I'm studying Introduction to Smooth Manifolds by John M. Lee. The books defines a metric on a smooth manifold in the following way:
Let $M$ be a smooth manifold, a Riemannian metric on $M$ is a smooth symmetric covariant $2-$tensor field on $M$ that is positive definite at each point.
From this definition, I understand that a Riemannian metric is a function $g$, such that, at each point $p \in M$, $$ g_p: T_{p}M \times T_{p}M \to \mathbb{R} $$ From what I understand, If $M$ is a smooth $n-$dimensional manifold and we give a point $p \in M$, and a smooth chart $(U,\varphi)$ that contains $p$, a tensor field can be written as a linear combination: $$ g_{p} = \sum_{i=1}^{n}\sum_{j=1}^{n} g_{ij}(p) d\varphi^{i}|_{p}\otimes d\varphi^{j}|_{p} $$ where $\{d\varphi_{1}|_{p}, \ldots, d\varphi_{n}|_{p}\}$ is the basis for the cotangent space $T_{p}^{*}M$ dual to the basis $\{\frac{\partial}{\partial \varphi_{1}}|_{p}, \ldots, \frac{\partial}{\partial \varphi_{n}}|_{p}\}$ asociated to the local coordinates of the chart $(U,\varphi)$, and the coefficients $g_{ij}(p)$ are smooth functions and the matrix $(g_{ij})$ that his functions form is symmetric, positive definite.
How do I find these coefficients?
I saw somewhere that at each point, $g_{ij}(p)$ can be calculated with the given metric as: $$ g_{ij}(p) = g_{p} \left(\left. \frac{\partial}{\partial \varphi_{i}} \right|_{p} ,\left. \frac{\partial}{\partial \varphi_{j}} \right|_{p}\right) $$ but I'm not sure if that's correct, since it seems recursive to me.
I have also seen that the metric can be represented in different ways, for example, I have seen the metric of the sphere of radius $R$ represented as: $$ G(\theta,\phi) = \begin{bmatrix} R^{2} & 0 \\ 0 & R^{2}\sin^{2}(\phi) \end{bmatrix}$$
and as the matrix: $$G(x) = \begin{bmatrix} \frac{4R^{4}}{(R^{2} + \|x\|^2)^2} & 0 \\ 0 & \frac{4R^{4}}{(R^{2} + \|x\|^2)^2} \end{bmatrix} $$
I don't understand why one of the matrix takes two inputs and the other takes a single one, or how, given two tangent vectors, am I supposed to get a real number out of the matrices.