Help with a Gaussian Integral with Matrix Terms in It. From A. Zee's QFT in a Nutshell, Chapter 1 (Path Integral formulation of QM), Appendix 2 In appendix 2 (on Gaussian Integrals) of Chapter 1 (Path Integral Formulation to Quantum Physics) from Zee's 'QFT in a Nutshell' book, there is this integral
$$\begin{align}
\int_{-\infty}^{\infty} dx \space e^{-\frac{1}{2}ax^2+Jx}=\left(\frac{2\pi}{a}\right)^{\frac{1}{2}}\cdot e^{\frac{J^2}{2a}}  
\end{align}\tag{19}$$
Now he has promoted $\bf{a}$ to a real symmetric ${N}$ by ${N}$ matrix $A_{ij}$ and ${x}$ to a vector $x_i$ $(i=1,...,N)$. Then $(19)$ generalizes to
$$\begin{align}
\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}...\int_{-\infty}^{\infty}\space dx_1 dx_2...dx_N\space e^{-\frac{1}{2}x\cdot A \cdot x + J\cdot x}=\left(\frac{(2\pi)^N}{det[A]}\right)^\frac{1}{2} e^{\frac{1}{2}J\cdot A^{-1}\cdot J}
\end{align}\tag{22}$$
with $x\cdot A \cdot x=x_i A_{ij} x_{j}$ and $J\cdot x=J_i x_i$.
Also here we have followed diagonalization of $A$ as $A=O^{-1}\cdot D\cdot O$, $D$ being diagonal. Also call $y_i=O_{ij}x_j$.
So that exponential of LHS of $(19) $ becomes
\begin{align}
-\frac{1}{2}y\cdot D\cdot y + (OJ)\cdot y\space ;
\end{align}
then use
\begin{align}
\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}...\int_{-\infty}^{\infty}\space dx_1 dx_2...dx_N=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}...\int_{-\infty}^{\infty}\space dy_1 dy_2...dy_N\space .
\end{align}
Then each of $N$ integrals of $(22)$ becomes of the form:
\begin{align}
\int_{-\infty}^{\infty}\space dy_i\space e^{-\frac{1}{2}D_{ii}y_i^{2}+(OJ)_i y_i}.
\end{align}
We plug this in $(1)$, so R.H.S of $(2)$ becomes (with $(OJ)\cdot D^{-1}\cdot (OJ)=J\cdot A^{-1}\cdot J$) what we already wrote.
So this is what is given by ZEE.
Now my doubts are:

*

*If $a$ is promoted to a matrix, then what becomes of $\frac{1}{a}$, esp. in this context?


*In eqn. $(22)$, how we are arriving at the term in $e$'s index, in the RHS? I don't mean the whole process shown here. But only the fact of comparing with the form of eqn $(19)$, after we are done with Zee's guide.


*What is the importance of promoting such terms of an integrand to matrices?
 A: Q1: $a$ becomes $A$ and $1/a$ becomes $A^{-1}$: the inverse of $A$. Is this what you mean?
Q2: completing the square can be generalized to matrices 'easily'. Start by recalling how to complete the square:
\begin{align}
-\tfrac 1 2 ax^2+Jx&=-\tfrac 1 2 a\left(x^2-\frac{2J}{a}\right)\\
&=-\tfrac 1 2 a\left(\left(x-\frac{J} a\right)^2-\frac{J^2}{a^2}\right)\\
&=-\tfrac 1 2 a\left(x-\frac{J}a\right)^2+\frac{J^2}{2a}
\end{align}
Now generalize:
\begin{align}
-\tfrac 1 2J^T AJ+J^T x&=-\tfrac 1 2(x^T-J^TA^{-1})A\underbrace{(x-A^{-1}J)}_{z}+\tfrac 1 2 J^TA^{-1}J\\
&=-\tfrac 1 2z^TAz+\tfrac 1 2 J^TA^{-1}J
\end{align}
To pull out a $z$ in the term that contains transposes I used the fact that $(A^{-1})^T=(A^T)^{-1}$ for symmetric matrices. I encourage you to try this for yourself.
Q3 The importance of this generalization is clear: the objects in our theories are often vectors/vector like objects (for example Dirac spinors in the Dirac Lagrangian). This computations helps us in calculating the path integral for these kinds of theories. At least, for simple Lagrangians. Adding even quite simple terms to the quadratic Lagrangian makes it quickly impossible to calculate and an important part of QFT is devoted to circumventing this.
