## 1 Introduction

Following the ideas in [3, 7, 19], we note that many different numerical problems can be described within the following simple general framework. We consider a space of inputs and a space of outputs denoted by $$\mathcal {I}$$ and $$\mathcal {O}$$, respectively, and some equation of the form $$ev(i,o)=0$$ stating when an output is a solution for a given input. Both $$\mathcal {I}$$ and $$\mathcal {O}$$, and the solution variety

\begin{aligned} \mathcal {V}=\{(i,o)\in \mathcal {I}\times \mathcal {O}:o\text { is an output to }i\}=\{(i,o)\in \mathcal {I}\times \mathcal {O}: ev(i,o)=0\} \end{aligned}

are frequently real algebraic or just semialgebraic sets. The numerical problem to be solved can then be written as “given $$i\in \mathcal {I}$$, find $$o\in \mathcal {O}$$ such that $$(i,o)\in \mathcal {V}$$,” or “find all $$o\in \mathcal {O}$$ such that $$(i,o)\in \mathcal {V}$$.” One can have in mind the following examples:

1. 1.

Polynomial Root Finding: $$\mathcal {I}$$ is the set of univariate real polynomials of degree d, $$\mathcal {O}=\mathbb {R}$$ and $$\mathcal {V}=\{(f,\zeta ):f(\zeta )=0\}$$. If we look for, say, the largest real zero, then the solution variety $$\mathcal {V}=\{(f,\zeta ):f(\zeta )=0,\not \exists \eta >\zeta :f(\eta )=0\}$$ is semialgebraic.

2. 2.

Polynomial System Solving, which we can see as the homogeneous multivariate version of Polynomial Root Finding: $$\mathcal {I}$$ is the projective space of (dense or structured) systems of n real homogeneous polynomials of degrees $$d_1,\ldots ,d_n$$ in variables $$x_0,\ldots ,x_n$$, $$\mathcal {O}=\mathbb {R}\text {P}^n$$ is the real projective space of dimension n and $$\mathcal {V}=\{(f,\zeta ):f(\zeta )=0\}$$.

3. 3.

EigenValue Problem: $$\mathcal {I}=\mathbb {R}^{n\times n}$$, $$\mathcal {O}=\mathbb {R}$$ and $$\mathcal {V}=\{(A,\lambda ):\text {det}(A-\lambda \,\text {Id})= 0\}$$.

4. 4.

(Homogeneous) Polynomial EigenValue Problem (in the sequel called PEVP): $$\mathcal {I}$$ is the set of tuples of $$d+1$$ real $$n\times n$$ matrices $$A=(A_0,\ldots ,A_d)$$, $$\mathcal {O}=\mathbb {R}\text {P}^1$$ and $$\mathcal {V}=\{(A,[\alpha :\beta ]):P(A,\alpha ,\beta )=\det (\alpha ^0\beta ^dA_0+\alpha ^1\beta ^{d-1} A_1+\cdots +\alpha ^d\beta ^0A_d)=0\}$$. One can force some of the matrices to be symmetric and/or positive definite (which leads to a semialgebraic solution variety), a particularly important case in applications, or consider other structured problems, see [10, 13, 18, 21]. In the cases $$d=1$$ and $$d=2$$ polynomial eigenvalues are often referred to as generalized eigenvalues and quadratic eigenvalues, respectively. If $$n=1$$, we recover the homogeneous version of 1.

In this paper, we prove a general theorem computing exactly the expected value of the condition number in a wide collection of problems, including problem 4 above.

We start by recalling the general geometric definition of the condition number, which is usually thought of as “a measure of the sensitivity of the solution o under an infinitesimal perturbation of the input i.” A Finsler structure on a differentiable manifold M is a smooth field of norms $$\Vert \cdot \Vert _p: T_pM \rightarrow \mathbb {R},\,p\in M$$ on M (see [3, p. 223] for more details). In particular, a Riemannian structure $$\langle \cdot ,\cdot \rangle$$ on M defines a Finsler structure on it by $$\Vert \dot{p}\Vert _p=\sqrt{\langle \dot{p},\dot{p}\rangle _p}$$, $$p\in M$$, $$\dot{p}\in T_pM$$.

### Definition 1

(Condition number in the algebraic setting) Let $$\mathcal {I},\mathcal {O}$$ and $$\mathcal {V}\subseteq \mathcal {I}\times \mathcal {O}$$ be real algebraic varieties such that the smooth loci of $$\mathcal {I},\mathcal {O}$$ are endowed with Finsler structures and let $$(i,o)\in \mathcal {V}$$ be a smooth point of $$\mathcal {V}$$ such that $$i\in \mathcal {I}, o\in \mathcal {O}$$ are smooth points of $$\mathcal {I}$$ and $$\mathcal {O}$$, respectively. Moreover, assume that $$D_{(i,o)}p_1: T_{(i,o)}\mathcal {V} \rightarrow T_{i}\mathcal {I}$$ is invertible. Then, the condition number$$\mu (i,o)$$ of $$(i,o)\in \mathcal {V}$$ is defined as

\begin{aligned} \mu (i,o)=\left\| D_{(i,o)}p_2\circ D_{(i,o)}p_1^{-1}\right\| _{\text {op}}, \end{aligned}

where $$p_1:\mathcal {V}\rightarrow \mathcal {I},\, p_2:\mathcal {V}\rightarrow \mathcal {O}$$ are the projections and $$\Vert \cdot \Vert _{\text {op}}$$ is the operator norm. For points $$(i,o)\in \mathcal {V}$$ not satisfying the above assumptions, the condition number is set to $$\infty$$.

See [7, Sec. 14.1] for more on this geometric approach to the condition number.

### Remark 1

Definition 1 is intrinsic in $$\mathcal {I}$$, i.e., changing $$\mathcal {I}$$ to some subvariety $$\mathcal {I}^{\prime }\subset \mathcal {I}$$ leads (in general) to different, smaller, value of the condition number, since perturbations of the input are only allowed in the direction of the tangent space to the input set. Note also that the condition number depends on choices of Finsler structures on $$\mathcal {I}$$ and $$\mathcal {O}$$.

### Example 1

The classical Turing’s condition number $$\mu (A) = \Vert A\Vert _{\text {op}} \Vert A^{-1}\Vert _{\text {op}}$$ for matrix inversion corresponds to the following setting:

• $$\mathcal {O} =\mathcal {I}=M(n,\mathbb {R})$$ is the set of $$n\times n$$ real matrices endowed with the Finsler structure associated to relative errors in operator norm: $$\Vert \dot{A}\Vert _A=\Vert \dot{A}\Vert _{\text {op}}/\Vert A\Vert _{\text {op}}$$.

• $$\mathcal {V}=\{(A,B):AB=\text {Id}\} = \{(A,B): B=A^{-1}\}$$.

In the PEVP, the input space $$\mathcal {I}$$ is endowed with the following Riemannian structure: $$\langle \dot{A},\dot{B}\rangle _A = ((\dot{A}_0,\dot{B}_0) + \dots + (\dot{A}_d,\dot{B}_d))/((A_0,A_0)+\dots +(A_d,A_d))$$, where $$(\cdot ,\cdot )$$ is the Frobenius inner product $$(A,B)=\text {trace}(B^tA)$$, $$A= (A_0,\dots ,A_d)$$ and $$\dot{A}=(\dot{A}_0,\dots ,\dot{A}_d), \dot{B}= (\dot{B}_0,\dots ,\dot{B}_d)\in T_{A}\mathcal {I}$$. The output space $$\mathcal {O}=\mathbb {R}\text {P}^1$$ possesses the standard metric, and the solution variety $$\mathcal {V}= \{(A,[\alpha :\beta ]) : P(A,\alpha ,\beta )=0\}$$ is endowed with the induced product Riemannian structure. An explicit formula for the condition number for the Homogeneous PEVP was derived in [10, Th. 4.2] (we write here the relative condition number version):

\begin{aligned} \mu (A,(\alpha ,\beta ))=\left( \sum _{k=0}^d \alpha ^{2k} \beta ^{2d-2k}\right) ^{1/2}\frac{\Vert r\Vert \Vert \ell \Vert }{|\ell ^t v|}\,\Vert A\Vert , \end{aligned}
(1)

where $$A=(A_0,\ldots ,A_d)$$, $$(\alpha ,\beta )\in \mathbb {R}^2$$ is a (representative of a) polynomial eigenvalue of A, r and $$\ell$$ are the corresponding right and left eigenvectors and

\begin{aligned} v=\beta \frac{\partial }{\partial \alpha } P( A,\alpha ,\beta )r-\alpha \frac{\partial }{\partial \beta }P( A,\alpha ,\beta )r. \end{aligned}

A given tuple A can have up to nd real isolated polynomial eigenvalues. We define the condition number of A simply as the sum of the condition numbers over all these PEVs:

\begin{aligned} \mu (A) =\sum _{[\alpha :\beta ]\in \mathbb {R}\text {P}^1\text {is a PEV of } A} \mu (A,(\alpha ,\beta )). \end{aligned}

(If $$A=(A_0,\dots ,A_d)$$ has infinitely many polynomial eigenvalues, we have $$\mu (A)=\infty$$). The most important result in this paper is a very general theorem which is designed to provide exact formulas for the expected value of the condition number in the PEVP and other problems. A simple particular case of our general theorem is as follows. We say that a random matrix $$A\in M(n,\mathbb {R})$$ is $$\mathcal {N}_{M(n,\mathbb {R})}$$-distributed if the entries of A are i.i.d. standard Gaussian variables, i.e., the probability density function for each entry of A is $$(2\pi )^{-1/2}e^{-x^2/2}$$.

### Theorem 1

(Gaussian Homogeneous PEVP is well conditioned on the average) If $$A_0,\dots ,A_d\in M(n,\mathbb {R})$$ are independent $$\mathcal {N}_{M(n,\mathbb {R})}$$-distributed matrices, then

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathcal {N}_{M(n,\mathbb {R})}}{\mathbb {E}}\, \mu (A)&= \pi \frac{\varGamma \left( \frac{(d+1)n^2}{2}\right) }{\varGamma \left( \frac{(d+1)n^2-1}{2}\right) } \frac{\varGamma \left( \frac{n+1}{2}\right) }{\varGamma \left( \frac{n}{2}\right) } \nonumber \\&= \frac{\pi }{2} \sqrt{(d+1)n^3}\left( 1 + \mathcal {O}\left( \frac{1}{n}\right) \right) ,\ n\rightarrow +\infty \end{aligned}
(2)

In Corollary 3, we provide an analogous formula in the case when $$A_0,\ldots ,A_d$$ are independent GOE(n)-distributed matrices.

### Remark 2

Recently in  Armentano and the first author of the current article investigated the expectation of the squared condition number for polynomial eigenvalues of complex Gaussian matrices. Theorem 1 establishes the “asymptotic square root law” for the considered problem, i.e., when $$n\rightarrow +\infty$$ (and up to the factor $$\pi /2$$) our answer in (2) equals the square root of the answer in . See [2, 5, 8, 15, 20] for different contexts where a square root law has been established. For an example of a problem where a square root law fails to hold, see .

In Sect. 1, we state our main results, of which Theorem 1 is an easy consequence. Their proofs are given in Sect. 3 and in Sect. 4; some technical results are left for Appendix.

## 2 Main Results

In this section, we state our most general result, from which Theorem 1 will follow. First, let us fix a general framework which analyzes the input–output problems described above in a semialgebraic context. For the rest of this paper, the input and the output sets will be, respectively, the punctured real vector space $$\mathcal {I}=\mathbb {R}^m{\setminus }\{0\}$$ and the unit circle $$S^1\subset \mathbb {R}^2$$ endowed with the standard Riemannian structures. The solution variety will be a semialgebraic set $$\mathcal {S}\subset \mathbb {R}^m\times S^1\subset \mathbb {R}^m\times \mathbb {R}^2$$ (we change letter from $$\mathcal {V}$$ to $$\mathcal {S}$$ to remark the fact that it is semialgebraic). We denote by $$\mathcal {S}_{\text {top}}$$ the union of top-dimensional (smooth) strata of $$\mathcal {S}$$ (see Sect. 2 for details). Then, the smooth manifold $$\mathcal {S}_{\text {top}}\subset \mathbb {R}^m\times S^1$$ is endowed with the induced Riemannian product structure. The two projections defined on $$\mathcal {S}$$ are denoted by $$p_1: \mathcal {S} \rightarrow \mathbb {R}^m,\,p_2: \mathcal {S} \rightarrow S^1$$.

### Definition 2

(Condition number in the semialgebraic setting) Let $$\mathcal {S}\subseteq \mathbb {R}^m\times S^1$$ be any m–dimensional semialgebraic set. Near a regular point $$(a,x)\in \mathcal {S}_{\text {top}}$$ the first projection $$p_1: \mathcal {S}_{\text {top}} \rightarrow \mathbb {R}^m$$ is locally invertible, i.e., there exists a neighborhood $$U\subset \mathbb {R}^m$$ of $$a\in U$$ and a unique smooth map $$p_1^{-1}: U \rightarrow \mathcal {S}_{\text {top}}$$ such that $$p_1^{-1}(a) = (a,x)$$ and $$p_1\circ p_1^{-1} = \text {id}_{U}$$. In this case, the local relative condition number$$\mu (a,x)$$ is defined as

\begin{aligned} \mu (a,x):= \Vert a\Vert \sup \limits _{\dot{a} \in \mathbb {R}^m{\setminus } \{0\}} \frac{\Vert D_a(p_2\circ p^{-1}_1)(\dot{a})\Vert }{\Vert \dot{a}\Vert } \end{aligned}

For points $$(a,x)\in \mathcal {S}_{\text {low}} = \mathcal {S}{\setminus } \mathcal {S}_{\text {top}}$$ in the strata of lower dimension of $$\mathcal {S}$$ as well as for critical points $$(a,x)\in \mathcal {S}_{\text {top}}$$ of $$p_1:\mathcal {S}_{\text {top}} \rightarrow \mathbb {R}^m$$, we set $$\mu (a,x):= \infty$$.

The relative condition number$$\mu (a)$$ of $$a\in \mathbb {R}^m$$ is defined to be the sum of all local relative condition numbers $$\mu (a,x)$$:

\begin{aligned} \mu (a) := \sum \limits _{x\in S^1:\, (a,x)\in \mathcal {S}} \mu (a,x) \end{aligned}

### Remark 3

Note that, by convention, if $$p_1^{-1}(a)=\emptyset$$, that is, if there is no output for $$a\in \mathbb {R}^m{\setminus }\{0\}$$, then $$\mu (a)=0$$. Note also that Definition 2 agrees with Definition 1 if $$\mathcal {S}$$ is algebraic and we endow the input space $$\mathcal {I}=\mathbb {R}^m{\setminus }\{0\}$$ with the Riemannian structure associated to relative errors, that is, $$\langle \dot{a},\dot{b}\rangle _a=(\dot{b}^{\,t}\dot{a})/\Vert a\Vert ^2,\, a\in \mathbb {R}^m{\setminus } \{0\}$$.

To simplify terminology, throughout the rest of the paper, we omit the word “relative” when referring to (local) relative condition number.

We deal with a large class of semialgebraic subsets of $$\mathbb {R}^m\times S^1$$ that we define next.

### Definition 3

We say that the semialgebraic set $$\mathcal {S}\subset \mathbb {R}^m\times S^1$$ is non-degenerate if the following conditions are satisfied:

1.:

for any $$x\in S^1$$, the fiber $$p_2^{-1}(x)$$ is of dimension $$m-1$$,

2.:

the semialgebraic set $$\varSigma _1\subset \mathcal {S}_{\text {top}}$$ of critical points of $$p_1: \mathcal {S}_{\text {top}} \rightarrow \mathbb {R}^m$$ is at most $$(m-1)$$-dimensional. In Proposition 1, we show that this condition is equivalent to the following one:

$$2^{\prime }$$.:

there exists a semialgebraic subset $$B\subset \mathbb {R}^m$$ of dimension at most $$m-2$$ such that for any $$a\notin B$$ the fiber $$p_1^{-1}(a)$$ is finite.

The first condition in Definition 3 implies that $$\mathcal {S}$$ is m-dimensional (see Lemma 1). To perform our probabilistic study, we take the input variables $$a=(a_1,\dots ,a_m)\in \mathbb {R}^m$$ to be independent standard Gaussians: $$a\sim N(0,1)$$. In the following theorem, we establish a general formula for the expectation of the condition number $$\mu (a)$$ of a randomly chosen $$a\in \mathbb {R}^m$$:

### Theorem 2

If $$\mathcal {S}\subset \mathbb {R}^m\times S^1$$ is a non-degenerate semialgebraic set, then $$\mathrm{dim}(\mathcal {S})=m$$ and

\begin{aligned} \mathbb {E}_{a\sim N(0,1)} \left( \sum \limits _{x\in S^1 :\, (a,x)\in \mathcal {S}} \mu (a,x) \right) = \frac{1}{\sqrt{2\pi }^{\,m}} \int \limits _{x\in S^1} \int \limits _{a\in p_2^{-1}(x)}\Vert a\Vert e^{-\frac{\Vert a\Vert ^2}{2}} \mathrm{d}a\,\mathrm{d}x, \end{aligned}
(3)

where $$\mu$$ is given in Definition 2. If, moreover, $$\mathcal {S}$$ is scale-invariant with respect to the first m variables, i.e., $$(a,x)\in \mathcal {S}$$ if and only if $$(ta,x)\in \mathcal {S}$$ for any $$t>0$$, then

\begin{aligned} \mathbb {E}_{a\sim N(0,1)} \left( \sum \limits _{x\in S^1 :\, (a,x)\in \mathcal {S}} \mu (a,x) \right) = \frac{\varGamma \left( \frac{m}{2}\right) }{2\sqrt{\pi }^{\,m}} \int \limits _{x\in S^1} |p_2^{-1}(x) \cap S^{m-1}|\, \mathrm{d}x, \end{aligned}

where $$S^{m-1}\subseteq \mathbb {R}^m$$ is the unit sphere and $$|p_2^{-1}(x)\cap S^{m-1}|$$ denotes the volume of the $$(m-2)$$-dimensional semialgebraic spherical set $$p_2^{-1}(x)\cap S^{m-1}$$.

The following form of Theorem 2 for sets in $$\mathbb {R}^m\times \mathbb {R}\text {P}^1$$ better fits our purposes.

### Corollary 1

Let $$\mathcal {S}\subset \mathbb {R}^m\times S^1$$ be a non-degenerate semialgebraic set that is scale-invariant with respect to the first m variables and suppose that $$\mathcal {S}$$ is invariant under the map $$(a,x)\mapsto (a,-x),\, (a,x)\in \mathbb {R}^m\times S^1$$. Then $$\mu (a,x)=\mu (a,-x),\,(a,x)\in \mathcal {S}$$, the fibers $$p_2^{-1}(x), p_2^{-1}(-x)$$ are isometric and

\begin{aligned} \mathbb {E}_{a\sim N(0,1)} \left( \sum \limits _{[x]\in \mathbb {R}\text {P}^1:\, (a,x)\in \mathcal {S}} \mu (a,x) \right) = \frac{\varGamma \left( \frac{m}{2}\right) }{2\sqrt{\pi }^{\,m}} \int \limits _{[x]\in \mathbb {R}\text {P}^1} |p_2^{-1}(x) \cap S^{m-1}|\, d[x], \end{aligned}

Note that Corollary 1 is just a “projective” version of the second part of Theorem 2.

As pointed out in the introduction, we are specifically interested in the polynomial eigenvalue problem. Given $$d+1$$ matrices $$A_0,\dots ,A_d \in M(n,\mathbb {R})$$ a point $$[x]=[\alpha :\beta ]\in \mathbb {R}\text {P}^1$$ is a (real) polynomial eigenvalue (PEV) of $$A=(A_0,\dots ,A_d)$$ if

\begin{aligned} \text {det}(\alpha ^0\beta ^d A_0 + \dots +\alpha ^d\beta ^0 A_d)=0. \end{aligned}

The space $$M(n,\mathbb {R})$$ of $$n\times n$$ real matrices is endowed with the Frobenius inner product and the associated norm:

\begin{aligned} (A,B) = \text {tr}(A^t B),\quad \Vert A\Vert ^2 = (A,A),\quad A,B\in M(n,\mathbb {R}). \end{aligned}
(4)

Then, a k-dimensional vector subspace $$V\subset M(n,\mathbb {R})$$ is endowed with the standard normal probability distribution $$\mathcal {N}_V$$:

\begin{aligned} \mathbb {P}_{\mathcal {N}_V} (U) = \frac{1}{\sqrt{2\pi }^{\,k}} \int \limits _U e^{-\frac{\Vert v\Vert ^2}{2}}\mathrm{d}v, \end{aligned}

where $$\mathrm{d}v$$ is the Lebesgue measure on $$(V,(\cdot ,\cdot ))$$ and $$U\subset V$$ is a measurable subset. Denote by $$\varSigma _V=\{A\in V: \text {det}\, A = 0\}\subset V$$ the variety of singular matrices in V.

The condition number for polynomial eigenvalues of $$A=(A_0,\dots ,A_d)\in V^{d+1}$$ is defined via

\begin{aligned} \mu (A) :=\sum _{[x]\in \mathbb {R}\text {P}^1\text {is a PEV of } A} \mu (A,x), \end{aligned}

where $$\mu (A,x)$$ is as in Definition 2 with $$\mathbb {R}^m=(V,(\cdot ,\cdot ))^{d+1}$$ so that $$m=(d+1)k$$ and

\begin{aligned} \mathcal {S}&= \{(A,x)=((A_0,\dots ,A_d),(\alpha ,\beta ))\in V^{d+1}\times S^1 :\\&\qquad \text {det}(\alpha ^0\beta ^d A_0 + \dots +\alpha ^d\beta ^0 A_d)=0\}. \end{aligned}

As proved in , in the case $$V=M(n,\mathbb {R})$$ this definition for $$\mu (A,x)$$ is equivalent to (1). In the following theorem, we investigate the expected condition number for polynomial eigenvalues of independent $$\mathcal {N}_V$$-distributed matrices $$A_0,\dots ,A_d\in V$$.

### Theorem 3

If $$\varSigma _V\subset V$$ is of codimension one, then

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathcal {N}_V}{\mathbb {E}}\, \mu (A) = \sqrt{\pi } \frac{\varGamma \left( \frac{(d+1)k}{2}\right) }{\varGamma \left( \frac{(d+1)k-1}{2}\right) }\frac{|\varSigma _V\cap S^{k-1}|}{|S^{k-2}|}. \end{aligned}
(5)

Poincaré’s formula [14, (3–5)] allows to derive the following universal upper bound.

### Corollary 2

If $$\varSigma _V\subset V$$ is of codimension one, then

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathcal {N}_V}{\mathbb {E}}\, \mu (A) \le \sqrt{\pi } n \frac{\varGamma \left( \frac{(d+1)k}{2}\right) }{\varGamma \left( \frac{(d+1)k-1}{2}\right) } \end{aligned}
(6)

In the case $$V=M(n,\mathbb {R})$$ of all square matrices, we provide an explicit formula for the expected condition number, that is the claim of our Theorem 1 above.

We give an explicit answer also in the case $$V=Sym(n,\mathbb {R})$$ of symmetric matrices. In this case, the probability space $$(Sym(n,\mathbb {R}),\mathcal {N}_{Sym(n,\mathbb {R})})$$ is usually referred to as Gaussian Orthogonal Ensemble (GOE).

### Corollary 3

If $$A_0,\dots ,A_d\in Sym(n,\mathbb {R})$$ are independent $$\mathrm{GOE}(n)$$-matrices and n is even, then

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathrm{GOE}(n)}{\mathbb {E}}\, \mu (A)&= \sqrt{2}n\frac{\varGamma \left( \frac{(d+1)n(n+1)}{4}\right) }{\varGamma \left( \frac{(d+1)n(n+1)-2}{4}\right) }\frac{\varGamma \left( \frac{n+1}{2}\right) }{\varGamma \left( \frac{n+2}{2}\right) }\nonumber \\&=\sqrt{(d+1)n^3}\left( 1+\mathcal {O}\left( \frac{1}{\sqrt{n}}\right) \right) ,\ n\rightarrow +\infty . \end{aligned}
(7)

If n is odd, the explicit formula is more complicated and is given in the proof of the corollary. However, the above asymptotic formula is valid for both even and odd n.

## 3 Preliminaries

Below, we state few classical results in semialgebraic geometry that we will use; the proofs can be found in [4, 9].

Given a semialgebraic set $$S\subset \mathbb {R}^N$$ of dimension $$k\le N$$, we fix a semialgebraic stratification of S, i.e., a partition of S into finitely many semialgebraic subsets (called strata) such that each stratum is a smooth submanifold of $$\mathbb {R}^N$$ and the boundary of any stratum of dimension $$i\le N$$ is a union of some strata of dimension less than i. We denote by $$S_{\text {top}}$$ the union of all k-dimensional strata of S and by $$S_{\text {low}} = S{\setminus } S_{\text {top}}$$ the union of the strata of dimension less than k. The sets $$S_{\text {top}}, S_{\text {low}}\subset \mathbb {R}^N$$ are semialgebraic, and $$S_{\text {top}}$$ is a smooth k-dimensional submanifold of $$\mathbb {R}^N$$.

One of the central results about semialgebraic mappings is Hardt’s theorem.

### Theorem 4

(Hardt’s semialgebraic triviality) Let $$S\subset \mathbb {R}^N$$ be a semialgebraic set and let $$f: S\rightarrow \mathbb {R}^M$$ be a continuous semialgebraic mapping. Then, there exists a finite partition of $$\mathbb {R}^M$$ into semialgebraic sets $$C_1,\dots ,C_r\subset \mathbb {R}^M$$ such that f is semialgebraically trivial over each $$C_i$$, i.e., there are a semialgebraic set $$F_i$$ and a semialgebraic homeomorphism $$h_i: f^{-1}(C_i) \rightarrow C_i\times F_i$$ such that the composition of $$h_i$$ with the projection $$C_i\times F_i\rightarrow C_i$$ equals $$f|_{f^{-1}(C_i)}$$.

The following two corollaries of Hardt’s theorem are frequently used to estimate dimension of semialgebraic sets.

### Corollary 4

Let $$f: S\rightarrow \mathbb {R}^M$$ be as above. The set $$A_d=\{x\in \mathbb {R}^M: {\mathrm{dim}}(f^{-1}(x)) = d\}$$ is semialgebraic and has dimension not greater than $$\mathrm{dim}(S)-d$$.

### Proof

With the notations of Hardt’s theorem, let us write

\begin{aligned} D_i=C_i\cap A_d= \{x\in C_i: \text {dim}(h_i^{-1}(\{x\}\times F_i)) = d\}. \end{aligned}

Now, since $$h_i$$ is a semialgebraic homeomorphism we have $$\text {dim}(h_i^{-1}(\{x\}\times F_i))=\text {dim}(F_i)$$ independently of $$x\in C_i$$. In other words, $$D_i=C_i$$ if $$\text {dim}(F_i)=d$$ and $$D_i=\emptyset$$ otherwise. We thus have $$A_d=\cup _{i\in I}C_i$$ for some finite index set I, and we conclude that $$A_d$$ is a semialgebraic set. Moreover, for $$i\in I$$ we have that $$f^{-1}(C_i)\equiv C_i\times F_i$$ has dimension $$\text {dim}(C_i)+\text {dim}(F_i)=\text {dim}(C_i)+d$$. In other words,

\begin{aligned} \text {dim}(C_i)+d\le \text {dim}(S), \end{aligned}

and the second claim of the corollary follows. $$\square$$

### Corollary 5

Let $$f: S\rightarrow \mathbb {R}^M$$ be as above and let $$Z\subseteq \mathbb {R}^M$$. Then, for some $$z\in Z$$ we have $${\mathrm{dim}}(f^{-1}(Z))\le {\mathrm{dim}}(Z)+{\mathrm{dim}}(f^{-1}(z))$$.

### Proof

Again using the notation of Hardt’s theorem for the restriction $$g:f^{-1}(Z)\rightarrow Z$$ of f to $$f^{-1}(Z)$$, we have $$Z=\cup _{i\in I} C_i$$ for some finite index set I and $$f^{-1}(Z)\equiv \cup _{i\in I}\,C_i\times F_i$$. Without loss of generality, we assume that $$\text {dim}(f^{-1}(Z))=\text {dim}(C_1\times F_1)$$ that for $$z\in C_1$$ equals

\begin{aligned} \text {dim}(f^{-1}(Z)) = \text {dim}(C_1)+\text {dim}(f^{-1}(z))\le \text {dim}(Z)+\text {dim}(f^{-1}(z)). \end{aligned}

$$\square$$

## 4 Proof of Main Results

In this section, we prove our main results, Theorems 2 and 3. Let us first fix some notations that are used in the rest of the paper: For a non-degenerate subset $$\mathcal {S}\subset \mathbb {R}^m\times S^1$$ by $$\varSigma _1, \varSigma _2 \subset \mathcal {S}_{\text {top}}$$, we denote the semialgebraic sets of critical points of $$p_1: \mathcal {S}_{\text {top}} \rightarrow \mathbb {R}^m$$ and $$p_2: \mathcal {S}_{\text {top}} \rightarrow S^1$$, respectively, the corresponding semialgebraic sets of critical values are denoted by $$\sigma _1=p_1(\varSigma _1)\subset \mathbb {R}^m$$ and $$\sigma _2=p_2(\varSigma _2)\subset S^1$$.

### 4.1 Proof of Theorem 2

In this subsection, $$\mathcal {S}$$ denotes a non-degenerate semialgebraic subset of $$\mathbb {R}^m\times S^1$$. For the proof of Theorem 2, we need few technical lemmas which we state and prove below.

### Lemma 1

The semialgebraic sets $$\mathcal {S}\subset \mathbb {R}^m\times S^1$$ and $$p_1(\mathcal {S})\subset \mathbb {R}^m$$ are of dimension m.

### Proof

Since $$\mathcal {S}$$ is non-degenerate, for every $$x\in S^1$$ the fiber $$p_2^{-1}(x)$$ is $$(m-1)$$-dimensional. From Theorem 4, it follows that for some $$x\in S^1$$ we have $$\text {dim}(\mathcal {S}) = \text {dim}(p_2^{-1}(x))+\text {dim}(S^1) = (m-1)+1 = m$$.

The map $$p_1: \mathcal {S}_{\text {top}} \rightarrow \mathbb {R}^m$$ has a regular point $$(a,x)\in \mathcal {S}_{\text {top}}{\setminus } \varSigma _1$$ since $$\mathcal {S}$$ is m-dimensional and the set $$\varSigma _1$$ of critical points of $$p_1$$ is at most $$(m-1)$$-dimensional. The image $$p_1(U)$$ of a small open neighborhood $$U\subset \mathcal {S}_{\text {top}}{\setminus } \varSigma _1$$ of $$(a,x)\in U$$ is open in $$\mathbb {R}^m$$, and hence, $$\text {dim}(p_1(\mathcal {S})) =m$$. $$\square$$

### Lemma 2

There exists an open semialgebraic subset $$M\subset \mathcal {S}_{\mathrm{top}}$$ such that $$p_1(M)$$ is open in $$\mathbb {R}^m$$, $$M= p_1^{-1}(p_1(M))$$, the restriction $$p_1: M \rightarrow p_1(M)$$ is a submersion and $$\mathrm{dim}\,(\mathcal {S}{\setminus } M)\le m-1$$.

### Proof

Define $$M:=p_1^{-1}(\mathbb {R}^m{\setminus } N) = \mathcal {S}_{\text {top}}{\setminus } p_1^{-1}(N)$$, where $$N:=\overline{p_1(\mathcal {S}_{\text {low}} \cup \varSigma _1)}$$ and the bar stands for the Euclidean closure of a set. Note that M is an open subset of $$\mathcal {S}_{\text {top}}$$ and $$M= p_1^{-1}(p_1(M))$$. Moreover, M consists of regular points of the projection $$p_1:\mathcal {S}_{\text {top}}\rightarrow \mathbb {R}^m$$, which implies that $$p_1(M)$$ is an open subset of $$\mathbb {R}^m$$ and $$p_1:M\rightarrow p_1(M)$$ is a submersion of smooth manifolds. Indeed, for $$a\in p_1(M)$$ and $$(a,x)\in M$$ the image $$p_1(U)$$ of a small open neighborhood $$U\subset M$$ of $$(a,x)\in U$$ is open in $$\mathbb {R}^m$$ and $$a\in p_1(U)$$.

We now prove that $$\mathcal {S}{\setminus } M = p_1^{-1}(N)$$ is at most $$(m-1)$$-dimensional. Since $$\mathcal {S}$$ is non-degenerate, there exists a semialgebraic set $$B\subset \mathbb {R}^m$$ with $$\text {dim}(B)\le m-2$$ such that $$p_1^{-1}(a)$$ is finite for $$a\notin B$$. We decompose the semialgebraic set $$N = (N\cap B) \cup (N{\setminus } B)$$. From Corollary 5, it follows that there exists some $$a\in N\cap B$$ such that $${\text {dim}(p_1^{-1}(N\cap B))} \le \text {dim}(p_1^{-1}(a)) +\text {dim}(N\cap B)\le 1 + (m-2) = m-1$$. For $$a\in N{\setminus } B$$, the fiber $$p_1^{-1}(a)$$ is discrete, which together with the non-degeneracy of $$\mathcal {S}$$ and Corollary 5 implies $$\text {dim}(p_1^{-1}(N{\setminus } B)) \le \text {dim}(p_1^{-1}(a))+\text {dim}(N{\setminus } B) \le \text {dim}(\mathcal {S}_{\text {low}} \cup \varSigma _1) \le m-1$$. Thus, $$\text {dim}(\mathcal {S}{\setminus } M) = \text {dim}(p_1^{-1}(N)) = \text {dim}(p_1^{-1}(N\cap B)\cup p_1^{-1}(N{\setminus } B))\le m-1$$. $$\square$$

### Lemma 3

There exists an open semialgebraic subset $$R\subset \mathcal {S}_{\mathrm{top}}$$ such that $$S^1{\setminus } p_2(R)$$ is finite, $$p_2: R\rightarrow p_2(R)$$ is a submersion, $$\text {dim}(\mathcal {S}{\setminus } R)\le m-1$$ and $$\mathrm{dim} (p_2^{-1}(x){\setminus } R) \le m-2$$ for $$x\in p_2(R)$$.

### Proof

Since $$\mathcal {S}$$ is non-degenerate, every fiber $$p_2^{-1}(x), x\in S^1$$ is $$(m-1)$$-dimensional.

Note that the set $$S^1{\setminus } p_2(\mathcal {S}_{\text {top}})$$ is semialgebraic and zero-dimensional, thus finite. Indeed, if it was one-dimensional Theorem 4 together with $$\text {dim}(p_2^{-1}(x))=m-1, x\in S^1$$ would imply that $$p_2^{-1}(S^1{\setminus } p_2(\mathcal {S}_{\text {top}}))\subset \mathcal {S}{\setminus } \mathcal {S}_{\text {top}}$$ is m-dimensional which would contradict to $$\text {dim}(\mathcal {S}{\setminus } \mathcal {S}_{\text {top}})\le m-1$$.

The semialgebraic set $$\sigma _2=p_2(\varSigma _2)\subset S^1$$ of critical values of $$p_2: \mathcal {S}_{\text {top}} \rightarrow S^1$$ has measure zero by Sard’s theorem (see [12, p. 39]). Hence, $$\sigma _2\subset S^1$$ consists of a finite number of points.

Applying Corollary 4 to $$p_2: \mathcal {S}_{\text {low}} \rightarrow S^1$$, we have that $$C:=\{x\in S^1: \text {dim}(p_2^{-1}(x)\cap \mathcal {S}_{\text {low}}) = m-1\}$$ is a semialgebraic subset of $$S^1$$ and $$\text {dim}(C)\le \text {dim}(\mathcal {S}_{\text {low}})-(m-1)\le 0$$. Thus, C is a (possibly empty) finite set.

Set now $$R:=\mathcal {S}_{\text {top}}{\setminus } p_2^{-1}(\sigma _2\cup C)$$. Note that R is an open semialgebraic subset of $$\mathcal {S}_{\text {top}}$$ and $$S^1{\setminus } p_2(R) = \sigma _2\cup C\cup (S^1{\setminus } p_2(\mathcal {S}_{\text {top}}))$$ is finite by the above arguments. Since R consists of regular points of $$p_2:\mathcal {S}_{\text {top}}\rightarrow S^1$$, the map $$p_2: R\rightarrow p_2(R)$$ is a submersion. Since $$\text {dim}(\mathcal {S}_{\text {low}})\le m-1$$ and $$p_2^{-1}(\sigma _2\cup C)$$ is a finite collection of $$(m-1)$$-dimensional fibers, we have that $$\text {dim}(\mathcal {S}{\setminus } R)=\text {dim}(\mathcal {S}_{\text {low}} \cup p_2^{-1}(\sigma _2\cup C))\le m-1$$. Finally, $$\text {dim}(p_2^{-1}(x){\setminus } R)=\text {dim}( p_2^{-1}(x) \cap \mathcal {S}_{\text {low}})\le m-2$$ for $$x\in p_2(R)$$ because $$p_2(R)\cap C=\varnothing$$. $$\square$$

### Lemma 4

For any measurable function $$f: \mathcal {S} \rightarrow [0,+\infty )$$, we have

\begin{aligned} \int \limits _{a\in \mathbb {R}^m} \sum \limits _{x\in S^1 :\, (a,x)\in \mathcal {S}} f(a,x)\,\mathrm{d}a = \int \limits _{x\in S^1} \int \limits _{a\in p_2^{-1}(x)} \frac{NJ_{(a,x)} p_1}{NJ_{(a,x)} p_2} f(a,x)\, \mathrm{d}a\,\mathrm{d}x. \end{aligned}

Here, NJ stands for the normal Jacobian of a smooth map, that is, the absolute value of the determinant of the differential restricted to the orthogonal complement to its kernel.

### Proof

Let $$M\subset \mathcal {S}_{\text {top}}$$ be as in Lemma 2. The smooth coarea formula [14, (A-2)] applied to the measurable function $$f: M \rightarrow [0,+\infty )$$ and to the submersion $$p_1: M\rightarrow p_1(M)$$ reads

\begin{aligned} \int \limits _{(a,x)\in M} NJ_{(a,x)} p_1\, f(a,x)\, \mathrm{d}(a,x) = \int \limits _{a\in p_1(M)} \sum \limits _{x\in S^1:\, (a,x)\in \mathcal {S}} f(a,x)\, \mathrm{d}a, \end{aligned}
(8)

where we used that $$M=p_1^{-1}(p_1(M))$$ (Lemma 2) to be able to sum over the whole fiber $$p_1^{-1}(a)=\{(a,x)\in \mathcal {S}\},\, a\in p_1(M)$$. By Lemma 2, we have $$\text {dim}(\mathcal {S}{\setminus } M)\le m-1$$, and hence, $$\text {dim}(p_1(\mathcal {S}){\setminus } p_1(M))=\text {dim}(p_1(\mathcal {S}{\setminus } M))\le \text {dim}(\mathcal {S}{\setminus } M)\le m-1$$. Thus, we extend the integrations in (8) over $$\mathcal {S}$$ and $$p_1(\mathcal {S})$$, respectively, without changing the result. Moreover, the integration over $$p_1(\mathcal {S})$$ can be further extended to the whole space $$\mathbb {R}^m$$ since for a point $$a\in \mathbb {R}^m{\setminus } p_1(\mathcal {S})$$ the summation $$\sum _{x\in S^1: (a,x)\in \mathcal {S}} f(a,x)$$ is performed over the empty set $$p_1^{-1}(a)$$ and the sum is conventionally set to 0. All together, the above arguments imply

\begin{aligned} \int \limits _{(a,x)\in \mathcal {S}} NJ_{(a,x)} p_1\, f(a,x)\, \mathrm{d}(a,x) = \int \limits _{a\in \mathbb {R}^m} \sum \limits _{x\in S^1:\, (a,x)\in \mathcal {S}} f(a,x)\, \mathrm{d}a. \end{aligned}
(9)

Let $$R\subset \mathcal {S}_{\text {top}}$$ be as in Lemma 3. Applying the smooth coarea formula [14, (A-2)] to the measurable function $$\frac{NJ p_1}{NJ p_2} f: R \rightarrow [0,+\infty )$$ and to the submersion $$p_2: R\rightarrow p_2(R)$$, we obtain

\begin{aligned} \int \limits _{(a,x)\in R} NJ_{(a,x)} p_1\, f(a,x)\, \mathrm{d}(a,x) = \int \limits _{x\in p_2(R)} \int \limits _{a\in p_2^{-1}(x)\cap R} \frac{NJ_{(a,x)} p_1}{NJ_{(a,x)} p_2} f(a,x)\, \mathrm{d}a\, \mathrm{d}x. \end{aligned}
(10)

By Lemma 3$$\text {dim}(\mathcal {S}{\setminus } R)\le m-1$$, $$S^1{\setminus } p_2(R)$$ is finite, and $$\text {dim}(p_2^{-1}(x){\setminus } R)\le m-2$$ for $$x\in p_2(R)$$. Thus, the integrations in (10) can be extended over $$\mathcal {S}, S^1$$ and $$p_2^{-1}(x)$$, respectively, leading to

\begin{aligned} \int \limits _{(a,x)\in \mathcal {S}} NJ_{(a,x)} p_1\, f(a,x)\, \mathrm{d}(a,x) = \int \limits _{x\in S^1} \int \limits _{a\in p_2^{-1}(x)} \frac{NJ_{(a,x)} p_1}{NJ_{(a,x)} p_2} f(a,x)\, \mathrm{d}a\, \mathrm{d}x. \end{aligned}
(11)

Combining (11) with (9), we finish the proof. $$\square$$

Now comes the proof of Theorem 2.

### Proof of Theorem 2

The following identity is the key point of the proof:

\begin{aligned} \mu (a,x) = \Vert a \Vert \, \frac{NJ_{(a,x)}p_2}{NJ_{(a,x)}p_1},\quad (a,x)\in M\cap R\subset \mathcal {S}_{\text {top}} \end{aligned}
(12)

where $$M\subset \mathcal {S}_{\text {top}}$$ and $$R\subset \mathcal {S}_{\text {top}}$$ are as in Lemmas 2 and 3, respectively, and $$\mu (a,x)$$, the local condition number of $$(a,x)\in \mathcal {S}$$, is defined in Definition 2. The proof of the identity comes after we derive the statement of Theorem 2.

Applying Lemma 4 to the measurable function $$f(a,x) = \mu (a,x) e^{-\Vert a\Vert ^2/2}/\sqrt{2\pi }^{\,m}, (a,x)\in \mathcal {S}$$, and using (12), we obtain:

\begin{aligned} \mathbb {E}_{a\sim N(0,1)} \left( \sum \limits _{x\in S^1:\,(a,x)\in \mathcal {S}} \mu (a,x) \right)&= \frac{1}{\sqrt{2\pi }^{\,m}}\int \limits _{a\in \mathbb {R}^{\,m}} \left( \sum \limits _{x\in S^1:\, (a,x)\in \mathcal {S}} \mu (a,x)\right) e^{-\frac{\Vert a\Vert ^2}{2}} \mathrm{d}a \\&=\frac{1}{\sqrt{2\pi }^{\,m}} \int \limits _{x\in S^1} \int \limits _{a\in p_2^{-1}(x)}\Vert a\Vert e^{-\frac{\Vert a\Vert ^2}{2}} \mathrm{d}a\,\mathrm{d}x = (*), \end{aligned}

which gives the claimed formula (3). If $$\mathcal {S}$$ is scale-invariant with respect to $$a\in \mathbb {R}^m$$ by Lemma 5, we have

\begin{aligned} (*) = \frac{\varGamma \left( \frac{m}{2}\right) }{2\sqrt{\pi }^{\,m}} \int \limits _{x\in S^1} |p_2^{-1}(x)\cap S^{m-1}|\, \mathrm{d}x. \end{aligned}

Now, we turn to the proof of (12).

For $$(a,x)\in M\cap R\subset \mathcal {S}_{\text {top}}$$ let $$(\dot{a}_0,\dot{x}_0),(\dot{a}_1,0),\dots ,(\dot{a}_{m-1},0)$$ be an orthonormal basis of $$T_{(a,x)} R$$ with $$(\dot{a}_j,0)\in \ker D_{(a,x)} p_2,\, j=1,\dots ,m-1$$. Note that $$\dot{a}_0\in \mathbb {R}^m, \dot{x}_0\in T_x S^1$$ are nonzero since $$p_1: M\rightarrow p_1(M), p_2: R\rightarrow p_2(R)$$ are submersions and $$\dot{a}_0\in \mathbb {R}^m$$ is orthogonal to $$\dot{a}_j\in \mathbb {R}^m,\, j=1,\dots ,m-1$$. We compute the normal Jacobians $$NJ_{(a,x)} p_1$$ and $$NJ_{(a,x)} p_2$$ using the following orthonormal bases:

\begin{aligned} \left\{ (\dot{a}_0,\dot{x}_0), (\dot{a}_1,0),\dots ,(\dot{a}_{m-1},0)\right\}&\subset T_{(a,x)} \mathcal {S}_{\text {top}}\\ \left\{ \frac{\dot{a}_0}{\Vert \dot{a}_0\Vert }, \dot{a}_1,\dots ,\dot{a}_{m-1}\right\}&\subset T_a\mathbb {R}^m\\ \left\{ \frac{\dot{x}_0}{\Vert \dot{x}_0\Vert }\right\}&\subset T_x S^1 \end{aligned}

It is straightforward to see that $$NJ_{(a,x)} p_1 = \Vert \dot{a}_0\Vert$$ and $$NJ_{(a,x)} p_2 = \Vert \dot{x}_0\Vert$$ and hence

\begin{aligned} \frac{NJ_{(a,x)} p_2}{NJ_{(a,x)} p_1} = \frac{\Vert \dot{x}_0\Vert }{\Vert \dot{a}_0\Vert } \end{aligned}
(13)

Since $$D_{a}( p_2\circ p_1^{-1})(\dot{a}_j) = D_{(a,x)} p_2\circ D_a p^{-1}_1(\dot{a}_j) = 0$$ for $$j=1,\dots ,m-1$$ and since $$D_{a}( p_2\circ p_1^{-1})(\dot{a}_0) = D_{(a,x)} p_2\circ D_a p^{-1}_1(\dot{a}_0) = \dot{x}_0$$, we obtain

\begin{aligned} \mu (a,x) = \Vert a \Vert \,\sup \limits _{\dot{a} \in \mathbb {R}^m{\setminus } \{0\}} \frac{\Vert D_a( p_2\circ p^{-1}_1)(\dot{a})\Vert }{\Vert \dot{a}\Vert } = \Vert a\Vert \frac{\Vert \dot{x}_0\Vert }{\Vert \dot{a}_0\Vert } \end{aligned}

This together with (13) implies the claimed identity (12). $$\square$$

### 4.2 Proof of Theorem 3

For a k-dimensional vector subspace $$V\subset M(n,\mathbb {R})$$ and for a basis $$f=(f_0(\alpha ,\beta ),\dots ,f_d(\alpha ,\beta ))$$ of the space $$P_{d,2}$$ of binary forms of degree $$d\ge 1$$, let us define the algebraic variety

\begin{aligned} \mathcal {S}(V,f):=\{(A,x)\in V^{d+1}\times S^1 : \text {det}(A_0\, f_0(\alpha ,\beta ) +\dots +A_d\, f_d(\alpha ,\beta )) = 0\} \end{aligned}

Theorem 3 follows from the following more general result that we state for any choice of basis (not necessarily the monomial basis) since for some problems it may be useful to consider other bases such as the one coming from harmonic forms .

### Theorem 5

If $$\varSigma _V\subset V$$ is of codimension one and f is any basis of $$P_{d,2}$$, then $$\mathcal {S}(V,f)$$ is non-degenerate and

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathcal {N}_{V}}{\mathbb {E}} \left( \sum \limits _{[x]\in \mathbb {R}\text {P}^1:\, (A,x)\in \mathcal {S}(V,f)} \mu (A,x) \right) = \sqrt{\pi } \frac{\varGamma \left( \frac{(d+1)k}{2}\right) }{\varGamma \left( \frac{(d+1)k-1}{2}\right) }\frac{|\varSigma _V\cap S^{k-1}|}{|S^{k-2}|}, \end{aligned}

### Proof

Observe first that for any $$x=(\alpha ,\beta )\in S^1$$, the vector $$f(x)=(f_0(\alpha ,\beta ),\dots ,f_d(\alpha ,\beta ))$$ is nonzero. For any such x, let $$g=(g_{ij})\in O(d+1)$$ be an orthogonal matrix that sends f(x) to $$(c,0,\dots ,0)\in \mathbb {R}^{d+1}{\setminus } \{0\}$$, where $$c\ne 0$$ is a constant, i.e.,

\begin{aligned} \sum \limits _{j=0}^d g_{ij} f_j(\alpha ,\beta ) = {\left\{ \begin{array}{ll} c, i=0,\\ 0, i=1,\dots , d \end{array}\right. } \end{aligned}

It is easy to verify that the linear change of coordinates $$A_j = \sum _{i=0}^d g_{ij} \tilde{A}_i,\, j=0,\dots ,d$$ is an isometry of the product space $$(V,(\cdot ,\cdot ))^{d+1}$$ (where the inner product $$(\cdot ,\cdot )$$ on V is defined in (4)) and

\begin{aligned} \sum \limits _{j=0}^d f_j(\alpha ,\beta ) A_j&= \sum \limits _{j=0}^d f_j(\alpha ,\beta ) \left( \sum \limits _{i=0}^d g_{ij} \tilde{A}_i\right) = \sum \limits _{i=0}^d\left( \sum \limits _{j=0}^d g_{ij} f_j(\alpha ,\beta )\right) \tilde{A}_i = c\, \tilde{A}_0 \end{aligned}

Therefore, for $$x=(\alpha ,\beta )\in S^1$$ there is a global isometry $$\mathcal {I}_x : (V,(\cdot ,\cdot ))^{d+1} \rightarrow (V,(\cdot ,\cdot ))^{d+1}$$ that sends the fiber $$p_2^{-1}(x) = \{A\in V^{d+1}: \text {det}(A_0\,f_0(\alpha ,\beta )+\dots + A_d\,f_d(\alpha ,\beta ))=0\}$$ to $$\{\tilde{A}\in V^{d+1}: \text {det} (\tilde{A}_0) = 0\} = \varSigma _V \times V^d$$. In particular, under the assumption $$\text {dim}(\varSigma _V) = k-1$$ we have that $$p_2^{-1}(x)$$ is of codimension one in $$V^{d+1}$$, and hence, condition (1) in Definition 3 is satisfied.

Since both $$f_0(\alpha ,\beta ),\dots , f_d(\alpha ,\beta )$$ and $$\alpha ^0\beta ^d,\dots ,\alpha ^d\beta ^0$$ are bases of $$P_{d,2}$$, for some matrix $$h=(h_{ij})\in GL(d+1)$$, we have $$\alpha ^i \beta ^{d-i} = \sum _{j=0}^d h_{ij} f_j(\alpha ,\beta ),\, i=0,\dots ,d$$. Let us define $$B = \{A\in V^{d+1}: A_j = \sum \limits _{i=0}^d h_{ij}\tilde{A}_i,\, j=0,\dots ,d,\ \text {det}(\tilde{A}_0) = \text {det}(\tilde{A}_d) = 0\}$$. Since $$\text {dim}(\varSigma _V) = k-1$$ and since h is a non-degenerate transformation, the algebraic subset $$B\subset V^{d+1}$$ has codimension 2. For $$A\notin B$$, the matrix

\begin{aligned} \sum \limits _{j=0}^d f_j(\alpha ,\beta ) A_j&= \sum \limits _{j=0}^d f_j(\alpha ,\beta ) \left( \sum \limits _{i=0}^d h_{ij} \tilde{A}_i\right) \\&= \sum \limits _{i=0}^d\left( \sum \limits _{j=0}^d h_{ij} f_j(\alpha ,\beta )\right) \tilde{A}_i = \sum \limits _{i=0}^d \alpha ^i\beta ^{d-i} \tilde{A}_i \end{aligned}

is non-degenerate at $$(\alpha ,\beta )=(0,1)$$ (at $$(\alpha ,\beta )=(1,0)$$) if $$\text {det}(\tilde{A}_0)\ne 0$$ ($$\text {det}(\tilde{A}_d)\ne 0$$, respectively) and hence after the choice of some representatives the binary form $$\text {det}(A_0 f_0(\alpha ,\beta ) + \dots + A_d f_d(\alpha ,\beta ))$$ is nonzero. Consequently, the fiber

\begin{aligned} p_1^{-1}(A)\equiv \{(\alpha ,\beta )\in S^1: \text {det}(A_0 f_0(\alpha ,\beta )+ \dots + A_d f_d(\alpha ,\beta ))= 0\} \end{aligned}

is finite for any $$A\notin B$$ and condition $$(2^{\prime })$$ in Definition 3 is satisfied. Applying Theorem 2 to $$\mathcal {S}(V,f)\subset \mathbb {R}^{(d+1)k} \times S^1,\, \mathbb {R}^{(d+1)k} \simeq V^{d+1}$$ and noting that the solutions lie naturally in $$\mathbb {R}\text {P}^1$$, we obtain

\begin{aligned}&\underset{A_0,\dots , A_d\sim i.i.d.\, \mathcal {N}_{V}}{\mathbb {E}} \left( \sum \limits _{[x]\in \mathbb {R}\text {P}^1:\, (A,x)\in \mathcal {S}(V,f)} \mu (A,x) \right) \\&\quad = \frac{1}{2\sqrt{2\pi }^{(d+1)k}} \int \limits _{x\in S^1} \int \limits _{A\in p_2^{-1}(x)}\Vert A\Vert e^{-\frac{\Vert A\Vert ^2}{2}} \mathrm{d}A\,\mathrm{d}x, \end{aligned}

where $$\Vert A\Vert ^2 = \Vert A_0\Vert ^2+\dots +\Vert A_d\Vert ^2$$. Since each fiber $$p_2^{-1}(x), x\in S^1$$, is an algebraic subset of $$\mathbb {R}^{(d+1)k}$$ of codimension one we have by Lemma 5

\begin{aligned} \int \limits _{A\in p_2^{-1}(x)}\Vert A\Vert e^{-\frac{\Vert A\Vert ^2}{2}} \mathrm{d}A = \sqrt{2}\, \frac{\varGamma \left( \frac{(d+1)k}{2}\right) }{\varGamma \left( \frac{(d+1)k-1}{2}\right) } \int \limits _{A\in p_2^{-1}(x)} e^{-\frac{\Vert A\Vert ^2}{2}} \mathrm{d}A. \end{aligned}

Performing the isometric change of coordinates $$\mathcal {I}_x: (V,(\cdot ,\cdot ))^{d+1} \rightarrow (V,(\cdot ,\cdot ))^{d+1}$$ that was constructed above, we write the last integral as follows:

\begin{aligned} \int \limits _{A\in p_2^{-1}(x)} e^{-\frac{\Vert A\Vert ^2}{2}} \mathrm{d}A&= \int \limits _{\{\tilde{A} \in V^{d+1} :\, \text {det}(\tilde{A}_0) = 0\}} e^{-\frac{\Vert \tilde{A}_0\Vert ^2}{2}} e^{-\frac{\Vert \tilde{A}_1\Vert ^2}{2}}\dots e^{-\frac{\Vert \tilde{A}_d\Vert ^2}{2}} \mathrm{d}\tilde{A}_0 \mathrm{d}\tilde{A}_1\dots \mathrm{d}\tilde{A}_d\\&= \sqrt{2\pi }^{\,dk} \int \limits _{\tilde{A}_0\in \varSigma _V} e^{-\frac{\Vert \tilde{A}_0\Vert ^2}{2}} \mathrm{d}\tilde{A}_0 \\&= \sqrt{2\pi }^{\,dk} \sqrt{2}^{\,k-3} \varGamma \left( \frac{k-1}{2}\right) |\varSigma _V\cap S^{k-1}|, \end{aligned}

where in the last step Lemma 5 has been used. Note that this quantity is independent of $$x\in S^1$$. Collecting everything together, we write

\begin{aligned}&\underset{A_0,\dots , A_d\sim i.i.d.\, \mathcal {N}_{V}}{\mathbb {E}} \left( \sum \limits _{[x]\in \mathbb {R}\text {P}^1:\, (A,x)\in \mathcal {S}(V,f)} \mu (A,x) \right) \\&\quad =\sqrt{\pi }\frac{\varGamma \left( \frac{(d+1)k}{2}\right) }{\varGamma \left( \frac{(d+1)k-1}{2}\right) } \frac{\varGamma \left( \frac{k-1}{2}\right) }{2\sqrt{\pi }^{k-1}} |\varSigma _V\cap S^{k-1}|\\&\quad = \sqrt{\pi } \frac{\varGamma \left( \frac{(d+1)k}{2}\right) }{\varGamma \left( \frac{(d+1)k-1}{2}\right) } \frac{|\varSigma _V\cap S^{k-1}|}{|S^{k-2}|}, \end{aligned}

since $$|S^{k-2}| = 2\sqrt{\pi }^{k-1}/\varGamma \left( \frac{k-1}{2}\right)$$. This completes the proof. $$\square$$

### Proof of Theorem 3

Taking $$f_i(\alpha ,\beta ) = \alpha ^i\beta ^{d-i},\, i=0,\dots ,d$$, in Theorem 5, we obtain the claim of Theorem 3. $$\square$$

## 5 Applications of Main Results

In this section, we derive Theorem 1 and Corollaries 23.

### Proof of Corollary 2

Recall Poincaré’s formula [14, (3–5)] (see also [7, Th. A.55]): if MN are two algebraic subvarieties of $$S^{d}$$ of respective dimensions mn with $$m+n\ge d$$, then for the invariant Haar probability measure on the group of orthogonal matrices $$O(d+1)$$ we have

\begin{aligned} \mathbb {E}_{g\in O(d+1)}|M\cap gN|=|S^{m+n-d}|\frac{|M|\,|N|}{|S^m|\,|S^n|}. \end{aligned}

Applying this result to the $$(k-2)$$–dimensional subvariety $$M=\varSigma _V\cap S^{k-1} = \{A\in V:\Vert A\Vert =1, \det (A) = 0\}\subset S^{k-1}$$ and any one–dimensional great circle $$N\equiv S^1\subseteq S^{k-1}$$, we get

\begin{aligned} 2 \frac{|\varSigma _V\cap S^{k-1}|}{|S^{k-2}|}=\mathbb {E}_{g\in O(k)}\#\{A\in gN:\det (A)=0\}. \end{aligned}

Now, for almost all $$g\in O(k)$$ there are at most 2n isolated singular matrices in gN that correspond to the real projective roots $$[\alpha :\beta ]\in \mathbb {R}\text {P}^1$$ of $$\det (\alpha A+\beta B)=0$$, where AB are two different matrices in the circle gN. We conclude that

\begin{aligned} \frac{|\varSigma _V\cap S^{k-1}|}{|S^{k-2}|}\le n, \end{aligned}

which together with (5) implies the claimed bound (6). $$\square$$

In case of any particular space $$V\subset M(n,\mathbb {R})$$ satisfying $$\text {dim}(\varSigma _V) = k-1 = \text {dim}(V)-1$$ by Theorem 3 explicit computation of the expected condition number for polynomial eigenvalues amounts to computing the volume of the hypersurface $$\varSigma _V\cap S^{k-1}$$. In cases $$V=M(n,\mathbb {R})$$ and $$V=Sym(n,\mathbb {R})$$ formulas for the volume of $$\varSigma _V\cap S^{k-1}$$ were found in  and , respectively. It is easy to see that in both of these cases, the variety $$\varSigma _V$$ of singular matrices is of codimension one, and hence, the hypothesis of Theorem 3 is satisfied.

### Proof of Theorem 1

\begin{aligned} \frac{|\varSigma _{M(n,\mathbb {R})}\cap S^{n^2-1}|}{|S^{n^2-2}|} = \sqrt{\pi }\frac{\varGamma \left( \frac{n+1}{2}\right) }{\varGamma \left( \frac{n}{2}\right) } \end{aligned}

Plugging it in (5) for $$V=M(n,\mathbb {R}), k=\text {dim}(V)=n^2$$ leads to

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathcal {N}_{M(n,\mathbb {R})}}{\mathbb {E}}\, \mu (A)&= \pi \frac{\varGamma \left( \frac{(d+1)n^2}{2}\right) }{\varGamma \left( \frac{(d+1)n^2-1}{2}\right) } \frac{\varGamma \left( \frac{n+1}{2}\right) }{\varGamma \left( \frac{n}{2}\right) } \\&= \frac{\pi }{2} \sqrt{(d+1)n^3}\left( 1 + \mathcal {O}\left( \frac{1}{n}\right) \right) ,\ n\rightarrow +\infty , \end{aligned}

where the asymptotic is obtained using formula (1) from . $$\square$$

### Proof of Corollary 3

In  it was proved that

\begin{aligned} \frac{|\varSigma _{Sym(n,\mathbb {R})}\cap S^{\frac{n(n+1)}{2}-1}|}{|S^{\frac{n(n+1)}{2}-2}|} = \sqrt{\frac{2}{\pi }}n \frac{\varGamma \left( \frac{n+1}{2}\right) }{\varGamma \left( \frac{n+2}{2}\right) } \end{aligned}
(14)

for even n and

\begin{aligned} \frac{|\varSigma _{Sym(n,\mathbb {R})}\cap S^{\frac{n(n+1)}{2}-1}|}{|S^{\frac{n(n+1)}{2}-2}|}=\frac{(-1)^m\sqrt{\pi }n!}{2^n m!\varGamma \left( \frac{n+2}{2}\right) } \left( 1-\frac{4\sqrt{2}}{\sqrt{\pi }}\sum \limits _{i=0}^{m-1} (-1)^i \frac{\varGamma \left( \frac{2i+3}{2}\right) }{i!}\right) \end{aligned}
(15)

for odd $$n=2m+1$$. Plugging (14) and (15) in (5) for $$V=Sym(n,\mathbb {R}), k=\frac{n(n+1)}{2}$$ leads to explicit formulas for the expected condition number (see (7) in case of even n). In [17, Remark 3] it was shown that

\begin{aligned} \frac{|\varSigma _{Sym(n,\mathbb {R})}\cap S^{\frac{n(n+1)}{2}-1}|}{|S^{\frac{n(n+1)}{2}-2}|}=\frac{2\sqrt{n}}{\sqrt{\pi }}\left( 1+\mathcal {O}\left( \frac{1}{\sqrt{n}}\right) \right) ,\ n\rightarrow +\infty \end{aligned}

regardless parity of n. This leads to the asymptotic

\begin{aligned} \underset{A_0,\dots ,A_d\sim i.i.d.\, \mathrm{GOE}(n)}{\mathbb {E}}\, \mu (A)&= \sqrt{\pi } \frac{\varGamma \left( \frac{(d+1)n(n+1)}{4}\right) }{\varGamma \left( \frac{(d+1)n(n+1)-2}{4}\right) }\frac{|\varSigma _{Sym(n,\mathbb {R})}\cap S^{\frac{n(n+1)}{2}-1}|}{|S^{\frac{n(n+1)}{2}-2}|}\\&=\sqrt{(d+1)n^3}\left( 1+\mathcal {O}\left( \frac{1}{\sqrt{n}}\right) \right) ,\ n\rightarrow +\infty , \end{aligned}

where we again used formula (1) from  for the asymptotic of the ratio of two Gamma functions. $$\square$$