# Expected ratio of x’Ax and x’AAx on a unit sphere?

Suppose $$A$$ is symmetric positive definite matrix. Is there a nice expression for the first moment of the following quantity?

$$\frac{x^TAx}{x^TA^2 x}$$

Where $$x$$ is distributed as $$\text{Normal}(0,I_n)$$. This is the ratio of two quadratic forms evaluated on the surface of the sphere.

When $$A$$ has eigenvalues $$\langle 1, \frac{1}{2}\rangle$$, this expectation is equal to $$\frac{4}{3}$$, visualized below (notebook)

Edit Aug 18
To expand on hyperplane’s answer, we can take $$A$$ to be diagonal without loss of generality and write solution as

$$E\left[\frac{x^TAx}{x^TA^2 x}\right]=\langle a, z\rangle$$

Where
\begin{align} a_i=&\frac{1}{A_{ii}}\\ z_i=&E_{y\sim\mathcal{N}(0,A)} \frac{y_i^2}{\|y\|^2} \end{align}

## Answer

For symmetric matrices $$A, B$$, the quantities $$\mathcal R_A(x) = \frac{x^T A x}{x^T x}$$ and $$\mathcal R_{A, B}(x) = \frac{x^T Ax}{x^TBx}$$ are known as the (generalized) Rayleigh quotient. A question about this was already asked here: Distribution of the Rayleigh quotient or here Expected value of Rayleigh quotient

The accepted answer refers to the 1992 book Quadratic Forms in Random Variables by Mathai and Provost.

There, on page 144, we are referred to the 1956 paper Quadratic Forms in Normally Distributed Random Variables by Gurland, where the distribution and the expectation of the generalized Rayleigh Quotient are discussed. Among other things, the author shows:

$$\mathbf E\left[\frac{x^T Ax}{x^TBx}\right] = \sum_{j=0}^{n-1} \sum_{k=0}^{\infty} \frac{(-1)^{j+1}}{2^{j+2} v^{j+k+1}}c_{j} g_{k} B\left(j+k+1, \frac{3 n}{2}-j-1\right)$$

Here, $$B(x, y)$$ is the Beta Function and $$v$$, $$c_j$$ and $$g_k$$ are coefficients related to eigenvalues/characteristic polynomials of $$A$$ and $$B$$.

There are many other references giving different series/integral expansions/representations for the moments of $$\mathcal R_{A, B}(x)$$

None of which indicate that there is a general simple “closed form” for $$\mathbf E[\mathcal R_{A, B}(x)]$$.

Some simplification steps we can do in any case, given Eigenvalue Decomposition $$B=U^T\Lambda U$$:

$$\mathbf E_{x\sim\mathcal N(0,𝕀)}\left[\frac{x^T Ax}{x^TBx}\right] = \mathbf E_{y\sim\mathcal N(0,𝕀)}\left[\frac{y^TU^T AUy}{y^T \Lambda y}\right] = \mathbf E_{z\sim\mathcal N(0,\Lambda)}\left[\frac{z^T\Lambda ^{1/2}U^T AU\Lambda ^{1/2}z}{z^T z}\right]$$

Letting $$C=\Lambda ^{1/2}U^T AU\Lambda ^{1/2}$$ and using linearity we have:

$$\mathbf E_{z\sim\mathcal N(0,\Lambda)}\left[\frac{z^TCz}{z^T z}\right] = \mathbf E_{z\sim\mathcal N(0,\Lambda)}\left[\left\langle C, \;\tfrac{zz^T}{z^T z}\right\rangle\right] = \left\langle C, \; \mathbf E_{z\sim\mathcal N(0,\Lambda)}\left[\tfrac{zz^T}{z^T z}\right]\right\rangle$$

Here, both $$\mathbf E_{z\sim\mathcal N(0,\Lambda)}[zz^T] = \Lambda$$ and $$\mathbf E_{z\sim\mathcal N(0,\Lambda)}[z^Tz] = \operatorname{tr}(\Lambda)$$ are trivial, however numerical simulation suggests that $$\mathbf E_{z\sim\mathcal N(0,\Lambda)}\left[\tfrac{zz^T}{z^T z}\right]$$ is a diagonal matrix whose diagonal has some non-trivial, non-linear relationship w.r.t. $$\Lambda$$.

Attribution
Source : Link , Question Author : Yaroslav Bulatov , Answer Author : Hyperplane