1 Introduction

We consider the Nonsymmetric Algebraic \(T\)-Riccati Equation (\(T\)-NARE)

$$\begin{aligned} DX+X^TA-X^TBX+C=0, \end{aligned}$$
(1)

where \(A,B,C,D\in {\mathbb {R}}^{n\times n}\) are coefficient matrices and the \(n\times n\) matrix X is the unknown, while the superscript \(T\) denotes transposition.

Equation (1) has been considered in [3], with applications to Dynamic Stochastic General Equilibrium models. In the same paper, existence results are given in terms of nonnegativity properties of the coefficients, together with an analysis of the convergence of Netwon’s method to the required solution. Recently, the problem of the existence of solutions, when \(A=D=0\) and C is symmetric, has been studied in [6]. Matrix equations of the kind \(X^T B X=C\) are encountered also in image restoration problems [14], in inverse eigenvalue problems [1], and in the numerical solution of a cubic matrix equation arising in conservative dynamics [4].

The nonsymmetric \(T\)-Riccati equation takes the name from the Nonsymmetric Algebraic Riccati Equation (NARE)

$$\begin{aligned} DX+XA-XBX+C=0, \end{aligned}$$
(2)

that has received great attention in the literature in the last decades (see for instance the book [5]), and from the \(T\) operator applied to the unknown X in (1), when this premultiplies a matrix coefficient. Indeed, recently, there has been a great interest in the \(T\) counterpart of classical linear matrix equations. For instance, look at the Sylvester equation \(AX+XB=C\), whose \(T\) counterpart \(AX^T+X B=C\) has been the subject of a number of both computational and theoretical papers; see, e.g., [7, 9,10,11,12,13, 19].

It is well-known that there is a strict connection between Eq. (2) and the matrix

$$\begin{aligned} H=\begin{bmatrix} A &{} -B\\ -C &{} -D\end{bmatrix}. \end{aligned}$$
(3)

More specifically, X is a solution to (2) if and only if there exists an n-dimensional invariant subspace of H spanned by the columns of \(\begin{bmatrix} I \\ X\end{bmatrix}\), where I is the identity matrix (compare [5,   Thm. 2.1]). This property reduces a nonlinear equation to an eigenvalue problem, that can be associated with the linear matrix polynomial \(H-zI\). For this reason, perhaps with some abuse, we say that \(H-zI\) is a linearization of the matrix Eq. (2). (Note, however, the similarity with the linearization procedure for matrix polynomials.)

Apparently, a representation of the solutions of (1) in terms of a deflating subspace of a pencil is not known in the current literature. Moreover, the only available algorithms for the numerical solution of (1) are the fixed point iterations proposed in [3], whose convergence results are provided under specific nonnegativity assumptions on the matrix coefficients.

Our main contribution is the introduction of a linearization for the \(T\)-NARE (1). More specifically, we define the \(T\)-palindromic pencil \(\varphi (z)=M+zM^T\), where

$$\begin{aligned} M=\begin{bmatrix} C &{} D\\ A &{} -B\end{bmatrix}, \end{aligned}$$

and A, B, C, and D are the matrix coefficients in (1). We show that, if the pencil \(\varphi (z)\) is regular and X is a solution to (1), then the columns of \(\begin{bmatrix} I\\ X\end{bmatrix}\) span a deflating subspace of \(\varphi (z)\). Also, a converse result holds under suitable assumptions on some eigenvalues of \(\varphi (z)\). The precise statement is given in Theorem 2. We say that the pencil \(\varphi (z)\) is a linearization of the \(T\)-NARE (1). We also relate the solutions of the \(T\)-NARE with the solutions of a suitable Discrete-time Algebraic Riccati equation. Moreover, we show existence properties of the solutions under nonnegativity properties of the matrix coefficients, by weakening the assumptions of [3].

The linearization of the \(T\)-NARE, besides being interesting per se, is exploited to relate the solutions to (1) with the solution of certain discrete-time algebraic Riccati equations. More practically, it opens the way to compute the solution of a \(T\)-NARE by relying on invariant subspaces algorithms, such as the QZ and the Doubling Algorithm (DA). Moreover, it is possible to exploit the palindromic structure of the linearization by applying the palindromic QZ algorithm, a structured variant of the QZ algorithm, that we endow with an ordering procedure and that is shown to be superior, in terms of forward error, in some difficult problems.

In our tests, the proposed algorithms are shown to be more efficient than Newton’s method, the reference algorithm in [3]. Moreover, from the numerical experiments, we deduce that the (palindromic) QZ algorithm is the algorithm achieving the highest numerical accuracy, while the DA is the fastest one.

The paper is organized as follows: Sect. 2 provides some preliminary material on matrix pencils, in Sect. 3 we present the interplay between \(T\)-NAREs and \(T\)-palindromic pencils, while Sect. 4 is devoted to the case of matrix coefficients with nonnegativity properties. In Sect. 5 we describe the new algorithms for the \(T\)-NARE and some tests are performed in Sect. 6. The final section draws some conclusions.

2 Preliminaries

We recall some properties of matrix pencils that will be used throughout the paper. For more details on this subject we refer the reader to [15].

A matrix pencil \(p(z)=A+zB\), with \(A,B\in {\mathbb {C}}^{n\times n}\), is said to be regular if \(\det (p(z))\) is not identically 0. The finite eigenvalues of a regular pencil p(z) are the zeros of \(\det (p(z))\), while infinity is an eigenvalue of p(z) with multiplicity \(d\ge 1\) if \(\det (p(z))\) has degree \(n-d\). Notice that, for a regular pencil, 0 is an eigenvalue if and only if A is singular, while \(\infty \) is an eigenvalue if and only if B is singular.

A k-dimensional subspace \({\mathcal {V}}\subset {\mathbb {C}}^n\) is a deflating subspace of the regular matrix pencil \(p(z)=A+zB\) if there exists a k-dimensional subspace \({\mathcal {W}}\subset {\mathbb {C}}^n\) such that \(A{\mathcal {V}}\subset {\mathcal {W}}\) and \(B{\mathcal {V}}\subset {\mathcal {W}}\). If the columns of \(V\in {\mathbb {C}}^{n\times k}\) and \(W\in {\mathbb {C}}^{n\times k}\) span the subspaces \({\mathcal {V}}\) and \({\mathcal {W}}\), respectively, then there exist \(A',B'\in {\mathbb {C}}^{k\times k}\) such that \(AV=WA'\) and \(BV=WB'\). The eigenvalues of the \(k\times k\) pencil \(A'+zB'\) are a subset of the eigenvalues of p(z) and are said to be the eigenvalues of p(z) or, equivalently, the spectrum, associated with the deflating subspace \({\mathcal {V}}\).

A deflating subspace \({\mathcal {V}}\) is said to be a graph deflating subspace if, for any matrix \(V\in {\mathbb {C}}^{n\times k}\) whose columns span \({\mathcal {V}}\), the leading \(k\times k\) submatrix of V is invertible. In other words, \({\mathcal {V}}\) admits a basis made of the columns of the matrix \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \), for some matrix X.

A pencil \(p(z)=A+zB\) is said to be \(T\)-palindromic if \(B=A^T\), in this case \(p(z)^T=zp(1/z)\), that is, if \(\lambda \) is an eigenvalue of p(z), then \(1/\lambda \) is an eigenvalue of p(z) as well (this holds also for 0 and \(\infty \), with the conventions \(1/0=\infty \) and \(1/\infty =0\)).

A reciprocal-free set \({\mathcal {S}}\subset {\mathbb {C}}\cup \{\infty \}\) is a set such that if \(\lambda \in {\mathcal {S}}\) then \(1/\lambda \not \in {\mathcal {S}}\).

Given \(x\in {\mathbb {C}}^n\) and a matrix \(S\in {\mathbb {C}}^{n\times n}\), the vector x is said to be S-isotropic if \(x^TS x = 0\). More generally, if \({\mathcal {V}}\) is the subspace spanned by the columns of a full rank matrix \(V\in {\mathbb {C}}^{n\times k}\), then the subspace \({\mathcal {V}}\) and the matrix V are said to be S-isotropic if \(V^TS V = 0\).

The following result gives a sufficient condition under which a deflating subspace of a palindromic pencil is S-isotropic.

Theorem 1

[22,   Theorem 3.3] Suppose \(p(z) = S+zS^T\) is a regular \(n\times n\) palindromic pencil, and the columns of \(W\in {\mathbb {C}}^{n\times k}\) span a k-dimensional deflating subspace associated with the spectrum \({\varLambda }\subset {\mathbb {C}}\cup \{\infty \}\). If \({\varLambda }\) is reciprocal-free, then W is S-isotropic.

3 A linearization for nonsymmetric algebraic \(T\)-Riccati equations

In this section we introduce a linearization of the \(T\)-NARE (1), which allows us to show theoretical properties of the solutions and to relate the \(T\)-NARE to a suitable discrete-time algebraic Riccati equation.

We associate with the \(T\)-NARE (1) the \(2n\times 2n\) \(T\)-palindromic pencil

$$\begin{aligned} \varphi (z)=M+zM^T,~~M=\left[ \begin{matrix} C &{} D\\ A &{} -B \end{matrix}\right] . \end{aligned}$$
(4)

The solutions of the \(T\)-NARE (1) are related to the deflating subspaces of the pencil \(\varphi (z)\) in (4). In particular, the following result provides a necessary and a sufficient condition for a matrix X to be a solution of (1), in terms of the properties of the deflating subspaces of \(\varphi (z)\). Note that the sufficient condition requires a reciprocal free assumption on a suitable subset of eigenvalues of \(\varphi (z)\).

Theorem 2

Assume that the pencil \(\varphi (z)\) in (4) is regular. If the matrix X is a solution to (1), then

$$\begin{aligned} \varphi (z)\begin{bmatrix} I\\ X\end{bmatrix} = \begin{bmatrix} -X^T\\ I\end{bmatrix} \alpha (z), \end{aligned}$$
(5)

where

$$\begin{aligned} \alpha (z):=A-BX+z(D^T-B^TX), \end{aligned}$$
(6)

i.e., the columns of \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) span a deflating subspace of the pencil \(\varphi (z)\), associated with the eigenvalues of the \(n\times n\) pencil \(\alpha (z)\).

Conversely, if X is an \(n\times n\) matrix such that the columns of the matrix \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) span a deflating subspace of \(\varphi (z)\) corresponding to a reciprocal-free set of eigenvalues, then X is a solution to (1).

Proof

If X is a solution to (1), then we have

$$\begin{aligned} M\begin{bmatrix} I \\ X \end{bmatrix} = \begin{bmatrix} -X^T\\ I \end{bmatrix}(A-B X). \end{aligned}$$
(7)

Moreover, X solves also the equation obtained by applying the \(T\) operator to all the summands of Eq. (1), i.e.,

$$\begin{aligned} X^TD^T+A^TX -X^TB^TX+C^T=0. \end{aligned}$$

Therefore, one has

$$\begin{aligned} M^T\begin{bmatrix} I \\ X \end{bmatrix} = \begin{bmatrix} C^T&{} A^T\\ D^T&{} -B^T\end{bmatrix} \begin{bmatrix} I \\ X \end{bmatrix} = \begin{bmatrix} -X^T\\ I \end{bmatrix}(D^T-B^TX). \end{aligned}$$
(8)

From Eqs. (7) and (8) we obtain

$$\begin{aligned} \varphi (z)\begin{bmatrix} I\\ X\end{bmatrix} = \begin{bmatrix} -X^T\\ I\end{bmatrix} (A-BX+z(D^T-B^TX)), \end{aligned}$$

i.e., the columns of \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) span a deflating subspace of the pencil \(\varphi (z)\), associated with the eigenvalues of the pencil \(\alpha (z)\).

Conversely, assume that the columns of \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) span a deflating subspace of \(\varphi (z)\), associated with a reciprocal-free set of eigenvalues.

We may easily observe that X is a solution to (1) if and only if

$$\begin{aligned} \begin{bmatrix} I&X^T\end{bmatrix} M \begin{bmatrix} I\\ X \end{bmatrix}=0, \end{aligned}$$

i.e., the matrix \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) is M-isotropic. Since \(\varphi (z)=M+zM^T\) is a regular \(T\)-palindromic pencil, the matrix \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) is M-isotropic thanks to Theorem 1, and thus X solves (1). \(\square \)

In the following, when X is a solution to (1) such that the columns of \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) span a deflating subspace of the regular pencil \(\varphi (z)\), associated with the eigenvalues \(\lambda _1,\ldots ,\lambda _n\), we say that X is associated with the eigenvalues \(\lambda _1,\ldots ,\lambda _n\) of \(\varphi (z)\) as well. Notice that, in general, the solution X is a complex matrix. If the complex eigenvalues in the set \(\{ \lambda _1,\ldots ,\lambda _n\}\) appear in complex conjugate pairs, then the corresponding deflating subspace of \(\varphi (z)\) is spanned by the columns of a real matrix, therefore the solution X is real.

An interesting consequence of Theorem 2 is that certain solutions of the \(T\)-NARE are solutions of a suitable Discrete-time Algebraic Riccati Equation (DARE).

Corollary 1

If X is a solution to (1) such that \(\det (A-BX)\ne 0\), then X is a solution to

$$\begin{aligned} C^T+A^TX=(C+DX)(A-BX)^{-1}(D^T-B^TX). \end{aligned}$$
(9)

Similarly, if X is a solution to (1) such that \(\det (D^T-B^TX)\ne 0\) then X is a solution to

$$\begin{aligned} C+DX=(C^T+A^TX)(D^T-B^TX)^{-1}(A-BX). \end{aligned}$$

Proof

Since \(X^T(A-BX)+C+DX=0\), if \(A-BX\) is invertible, then \(X^T=-(C+DX)(A-BX)^{-1}\). By post-multiplying the latter equation by \(D^T-B^TX\) and by using (1), one gets (9). The case where \(\det (D^T-B^TX)\ne 0\) can be treated analogously. \(\square \)

The following result gives sufficient conditions under which the assumptions of Corollary 1 are satisfied.

Proposition 1

Assume that the pencil \(\varphi (z)\) in (4) is regular. If X is a solution to (1) associated with a reciprocal-free set of eigenvalues of \(\varphi (z)\), then at least one of the matrices \(A-BX\) and \(D^T-B^TX\) is nonsingular.

If the matrix M in (4) is nonsingular, then any solution X to (1) is such that \(\det (A-BX)\ne 0\) and \(\det (D^T-B^TX)\ne 0\).

Proof

By Theorem 2, the solution X is associated with the eigenvalues of the pencil \(\alpha (z)\) in (6). Since the eigenvalues of the pencil \(\alpha (z)\) constitute a reciprocal-free set by hypothesis, then 0 and \(\infty \) cannot be both eigenvalues, therefore one of the matrices \(A-BX\) and \(D^T-B^TX\) is nonsingular. Concerning the second part, assume that M is nonsingular, then 0 and \(\infty \) cannot be eigenvalues of \(\varphi (z)\) and thus of \(\alpha (z)\), this show that both \(A-BX\) and \(D^T-B^TX\) are nonsingular. \(\square \)

Under the assumption that \(\varphi (z)\) has no eigenvalues on the unit circle, the solution X associated with the eigenvalues of \(\varphi (z)\) lying inside (or outside) the unit circle is unique and real, according to the following result.

Theorem 3

Let \(\varphi (z)\) and \(\alpha (z)\) be as in (4) and (6), respectively. If \(\varphi (z)\) is regular with no eigenvalues on the unit circle and there exists an n-dimensional graph deflating subspace \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) of \(\varphi (z)\) corresponding to eigenvalues lying inside the open (outside the closed) unit disk, then X is the unique solution to (1) such that the eigenvalues of \(\alpha (z)\) are inside the open (outside the closed) unit disk. Moreover, X is a real matrix.

Proof

Since \(\varphi (z)\) is a palindromic pencil, its eigenvalues come in pairs \((\lambda ,1/\lambda )\), and since \(\det \varphi (z)\ne 0\) if \(|z|=1\), then \(\varphi (z)\) has n eigenvalues inside the open unit disk and n eigenvalues outside the closed unit disk. Since the n eigenvalues inside the open (outside the closed) unit disk are disjoint from the remaining n, then the deflating subspace corresponding to the n eigenvalues inside the open (outside the closed) unit disk is unique [2]. The assertion follows from Theorem 2 and from the property that complex conjugate eigenvalues have the same modulus. \(\square \)

By borrowing an idea from the study of nonsymmetric algebraic Riccati equations [5], we consider the dual equation

$$\begin{aligned} Y^TD+AY-B+Y^TC Y=0, \end{aligned}$$
(10)

that is obtained by exchanging the role of A and D, and the role of B and C in (1). By following the same arguments used in Theorem 2 for equation (1), we find that, if Y is a solution to (10), then

$$\begin{aligned} \varphi (z)\left[ \begin{array}{c} Y \\ I \end{array}\right] = \left[ \begin{array}{c} I \\ -Y^T\end{array}\right] \beta (z) ,~~~\beta (z)=D+CY+z(A^T+ C^TY). \end{aligned}$$
(11)

We say that Y is associated with the eigenvalues of \(\beta (z)\).

Therefore, if X and Y are solutions to (1) and (10), respectively, then

$$\begin{aligned} \varphi (z)\left[ \begin{array}{cc} I &{} Y \\ X &{} I \end{array}\right] = \left[ \begin{array}{cc} -X^T&{} I \\ I &{} -Y^T\end{array}\right] \left[ \begin{array}{cc} \alpha (z) &{} 0 \\ 0 &{} \beta (z) \end{array}\right] . \end{aligned}$$

Hence, if X and Y are such that \(I-XY\) is invertible (that is equivalent to require that \(\left[ {\begin{matrix} I &{} Y\\ X &{} I\end{matrix}}\right] \) is invertible), then we derive the following result, that provides a block diagonalization of the pencil \(\varphi (z)\).

Theorem 4

Let X and Y be solutions to Eqs. (1) and (10), respectively, such that \(\det (I-XY)\ne 0\). Then

$$\begin{aligned} \varphi (z)= \left[ \begin{array}{cc} -X^T&{} I \\ I &{} -Y^T\end{array}\right] \left[ \begin{array}{cc} \alpha (z) &{} 0 \\ 0 &{} \beta (z) \end{array}\right] \left[ \begin{array}{cc} I &{} Y \\ X &{} I \end{array}\right] ^{-1}, \end{aligned}$$

where \(\alpha (z)\) and \(\beta (z)\) are defined in (6) and (11), respectively.

We conclude with a result that will be useful to show the convergence of doubling algorithms for computing the solution associated with the eigenvalues inside/outside the unit circle.

Theorem 5

Assume that \(\varphi (z)\) is regular, with \(\det \varphi (z)\ne 0\) when \(|z|=1\), and that \(\varphi (z)\) has two deflating subspaces spanned by the columns of \(\left[ {\begin{matrix} I\\ X\end{matrix}}\right] \) and \(\left[ {\begin{matrix} Y\\ I\end{matrix}}\right] \), associated with the eigenvalues inside and outside the unit disk, respectively. Then X and Y solve (1) and (10), respectively, the matrices \(D^T-B^TX\) and \(D-CY\) are invertible, and

$$\begin{aligned} M\begin{bmatrix} I\\ X\end{bmatrix} =M^T\begin{bmatrix} I\\ X\end{bmatrix} W,\qquad M\begin{bmatrix} Y\\ I\end{bmatrix}V= M^T\begin{bmatrix} Y\\ I\end{bmatrix}, \end{aligned}$$
(12)

where \(W=(D^T-B^TX)^{-1}(A-BX)\), \(V=(D+CY)^{-1}(A^T+C^TY)\). Moreover, \(\rho (W)=\rho (V)<1\).

Proof

From the second part of Theorem 2, it follows that X is a solution to (1). Hence, from the first part of Theorem 2, Eq. (5) is verified. Under our assumptions, the eigenvalues of \(\alpha (z)\) lie inside the unit disk. This implies that \(D^T-B^TX\) is invertible since, if it were singular, then \(\alpha (z)\) in (6) would have an eigenvalue at \(\infty \). By equating the terms in z in (5), we obtain

$$\begin{aligned} \begin{bmatrix} -X^T\\ I \end{bmatrix}= M^T \begin{bmatrix} I \\ X \end{bmatrix}(D^T-B^TX)^{-1}. \end{aligned}$$

By plugging this expression in (5) and by comparing the constant terms, we obtain

$$\begin{aligned} M\begin{bmatrix} I\\ X\end{bmatrix} =M^T\begin{bmatrix} I\\ X\end{bmatrix} W, \end{aligned}$$

where \(W=(D^T-B^TX)^{-1}(A-BX)\). Since the eigenvalues of W coincide with the eigenvalues of \(\alpha (z)\), we have that \(\rho (W)<1\). Similarly, by using (11), we proceed for the deflating subspace \(\left[ {\begin{matrix} Y\\ I\end{matrix}}\right] \). The property \(\rho (V)=\rho (W)\) holds since the eigenvalues of V are the reciprocals of the eigenvalues of \(\beta (z)\) in (11), that coincide with the eigenvalues of \(\alpha (z)\). \(\square \)

4 A \(T\)-NARE with nonnegativity properties

Given a real matrix A, we write \(A\ge 0\) (\(A>0\)) if all the entries of A are nonnegative (positive), and we say that the matrix A is nonnegative (positive). Moreover, we write \(A\ge B\) if \(A-B\ge 0\).

An usual assumption for the NARE (2) is that the matrix

$$\begin{aligned} {\widehat{M}}=\begin{bmatrix} A &{} -B\\ C &{} D\end{bmatrix}, \end{aligned}$$
(13)

is an M-matrix, i.e., a matrix of the form \({\widehat{M}}=\sigma I-H\), where \(H\ge 0\) and \(\rho (H)\le \sigma \). Under mild assumptions on \({\widehat{M}}\), it can be proven that there exists a minimal solution of the NARE (2). More precisely, if there exists a vector \(v>0\) such that \({\widehat{M}}v\ge 0\), then the NARE (2) has a minimal nonnegative solution [17,   Thm. 2], where the ordering is meant component-wise. This holds, in particular, when \({\widehat{M}}\) is nonsingular or singular irreducible.

Apparently, the case of the \(T\)-NARE (1) where \(\widehat{M}\) is an M-matrix is much more complicated than the case of a NARE (2), and has been treated in [3]. In particular, in [3], the existence of a minimal nonnegative solution is guaranteed under the hypothesis that the matrix

$$\begin{aligned} W=I\otimes D+(A^T\otimes I){\varPi } \end{aligned}$$

has a nonnegative inverse, where \({\varPi }=\sum _{i,j}(e_ie_j^T)\otimes (e_ie_j^T)\) (\(e_k\) is the k-th vector of the canonical basis of \({\mathbb {R}}^n\)) and that there exists a nonnegative matrix \(\widetilde{X}\) such that

$$\begin{aligned} D\widetilde{X}+\widetilde{X}^TA-\widetilde{X}^TB\widetilde{X}+C\ge 0. \end{aligned}$$
(14)

We will show that under milder assumptions than those in [3], there exists a minimal nonnegative solution \(X_{\min }\), i.e., such that \(X_{\min }\le X\) for any other possible nonnegative solution X.

For this purpose, define the sequence \(\{ X_\ell \}_\ell \) by means of the recursion

$$\begin{aligned} D X_{\ell +1}+X_{\ell +1}^TA=X_\ell ^T B X_\ell -C,\quad \ell =0,1,\ldots ,\quad X_0=0. \end{aligned}$$

Under suitable assumptions on the coefficients of the \(T\)-NARE, the sequence \(\{ X_\ell \}_\ell \) is well defined and converges to \(X_{\min }\), as stated in the following proposition.

Proposition 2

Assume that \(\det (W)\ne 0\), \(W^{-1}\ge 0\), \(D^{-1}\ge 0\), \(B\ge 0\), \(C\le 0\), and that there exist \(u,v\in {\mathbb {R}}^n\) positive vectors such that \(Au-Bv\ge 0\) and \(Cu+Dv\ge 0\). Then there exists a minimal nonnegative solution \(X_{\min }\) to (1) and the sequence \(\{X_\ell \}_\ell \) generated by (14) is well defined and converges to \(X_{\min }\), with \(0\le X_\ell \le X_{\ell +1}\), and \(X_\ell u\le v\) for any \(\ell \ge 0\).

Proof

We show by induction on \(\ell \) that \(0\le X_\ell \le X_{\ell +1}\) and \(X_\ell u\le v\). If \(\ell =0\), then \(X_0u=0\le v\) and \(X_1\) solves the equation \(DX_{1}+X_{1}^TA=-C\), i.e., \(\mathrm {vec}(X_1)=-W^{-1}\mathrm {vec}(C)\). Since \(W^{-1}\ge 0\) and \(C\le 0\), then \(0=X_0\le X_1\). Under the assumption \(0\le X_\ell \le X_{\ell +1}\), \(X_\ell u\le v\), we show that \(0\le X_{\ell +1}\le X_{\ell +2}\). Since \(W^{-1}\ge 0\), \(B\ge 0\) and \(C\le 0\), we have

$$\begin{aligned} \mathrm {vec}(X_{\ell +2})=W^{-1}\mathrm {vec}(X_{\ell +1}^TBX_{\ell +1}-C)\ge W^{-1}\mathrm {vec}(X_{\ell }^TBX_{\ell }-C)=\mathrm {vec}(X_{\ell +1})\ge 0. \end{aligned}$$

Now we show that \(X_{\ell +1}u\le v\). The matrix \(X_{\ell +1}\) is such that

$$\begin{aligned} X_{\ell +1}=D^{-1}(X_\ell ^TBX_\ell -C-X_{\ell +1}^TA). \end{aligned}$$

Multiplying from the right by u yields

$$\begin{aligned} X_{\ell +1}u=D^{-1}(X_\ell ^TBX_\ell -C-X_{\ell +1}^TA)u. \end{aligned}$$
(15)

From the inequalities \(Au-Bv\ge 0\), \(D^{-1}\ge 0\), and \(X_{\ell +1}\ge 0\), we deduce that \(-D^{-1}X_{\ell +1}^TAu\le -D^{-1}X_{\ell +1}^TBv\). Moreover, from the inequality \(Cu+Dv\ge 0\), since \(D^{-1}\ge 0\), we deduce that \(-D^{-1}Cu\le v\). Hence, since \(B\ge 0\) and \(X_\ell u\le v\), from (15), we derive

$$\begin{aligned} X_{\ell +1}u\le v + D^{-1}(X_\ell ^T-X_{\ell +1}^T)Bv\le v, \end{aligned}$$

where the latter inequality follows since \(0\le X_\ell \le X_{\ell +1}\). Therefore, the sequence \(\{ X_\ell \}_\ell \) is monotonic nondecreasing and bounded from above, since \(X_\ell \ge 0\) and \(X_\ell u\le v\), with \(u,v>0\). Therefore there exists \(X=\lim _\ell X_\ell \). Such a matrix X solves (1) by continuity and is a nonnegative solution. We show that it is the minimal nonnegative solution. Assume that \(Y\ge 0\) is a solution to (1). We may easily show by induction on \(\ell \) that \(X_\ell \le Y\) for any \(\ell \ge 0\). Therefore the inequality holds also in the limit and \(X_{\min }:=X\) is the minimal nonnegative solution. \(\square \)

In the M-matrix case, it might be useful to consider the pencil

$$\begin{aligned} {{\widehat{\varphi }}}(z)=\begin{bmatrix} A &{} -B\\ C &{} D\end{bmatrix} + z \begin{bmatrix} D^\top &{} -B^\top \\ C^\top &{} A^\top \end{bmatrix}, \end{aligned}$$

that has an interesting structure. Indeed, when \({\widehat{M}}\) in (13) is an M-matrix, then the two matrices in the pencil are M-matrices as well. We may formulate a result analogous to Theorem 2, that relates any solution of the \(T\)-NARE with a graph deflating subspace of the pencil \({{\widehat{\varphi }}}(z)\).

5 Algorithms based on the linearization

The relationship between computing a graph deflating subspace of a palindromic pencil and solving a \(T\)-NARE allows one to devise new algorithms for the solution of the latter. In particular, we consider three algorithms:

  • the QZ algorithm [16,   Chapter 7];

  • the Doubling Algorithm [5,   Chapter 5];

  • the palindromic QZ algorithm [20, 22].

The first two are general algorithms that provide certain invariant subspaces of pencils, while the third one is specialized to the structure of the problem.

5.1 The QZ algorithm

Given \(A',B'\in {\mathbb {C}}^{n\times n}\), the QZ algorithm provides two unitary matrices QZ such that \(A'':=Q^*A'Z\) and \(B'':=Q^*B'Z\) are upper triangular, where the superscript “\(*\)” denotes complex conjugate transposition. The pencil \(A'+zB'\) is similar to the pencil \(A''+zB''\), so if the former is regular, then its eigenvalues can be read from the diagonal of the latter, as the solutions of the equation \((A'')_{ii}-z (B'')_{ii}=0\), when \((B'')_{ii}\ne 0\), or \(\infty \) when \((B'')_{ii}=0\), for \(i=1,\ldots ,n\) (the case \((A'')_{ii}=(B'')_{ii}=0\) cannot hold for a regular pencil).

One can also get deflating subspaces from the matrix Z. Indeed, for \(\ell =1,\ldots ,n\), the first \(\ell \) columns of Z span a right deflating subspace of the pencil \(A'+zB'\), associated with the eigenvalues related to the first \(\ell \) diagonal entries of \(A''+zB''\) from the top left corner.

There exists a variant of the QZ algorithm for real matrices \(A'\) and \(B'\) such that Q and Z are real orthogonal and \(A''+zB''\) is an upper quasi-triangular pencil, that is \(A''+zB''\) is block upper triangular with diagonal blocks of size 1, corresponding to real eigenvalues, or 2, corresponding to pairs of complex conjugate eigenvalues. Also in the real case, the first \(\ell \) columns of Z yield a real deflating subspace associated with the first \(\ell \) eigenvalues related to the diagonal blocks of \(A''+zB''\), with the only constraint on \(\ell \) that a \(2\times 2\) diagonal block cannot be split. In particular, if the sizes of the diagonal blocks are \(\nu _1,\ldots ,\nu _h\), then the first \(\sum _{i=1}^{j} \nu _i\) columns of Z provide a real deflating subspace for \(j=1,\ldots ,h\).

In our problem, \(\varphi (z)=M+zM^T\) is a real pencil of size 2n. If \(\det \varphi (z)\ne 0\) on the unit circle, one may want a deflating subspace corresponding to the n eigenvalues inside/outside the unit disk. This can be obtained by relying on the reordered real QZ algorithm that produces two upper quasi-triangular matrices \(M':=Q^TMZ\) and \(M'':=Q^TM^TZ\), such that the n eigenvalues of the leading \(n\times n\) principal submatrix of \(M'+zM''\) are the ones inside/outside the unit disk. The span of the first n columns of Z is the required deflating subspace.

In principle, one can compute a deflating subspace associated with any subset of n eigenvalues, provided this is reciprocal-free, to get a solution to (1), in view of Theorem 2. The general procedure is summarized in Algorithm 1.

More details on the QZ algorithm can be found in [16,   Chapter 7]. Concerning the computational cost, according to [16,   Chapter 7], the computation of \(M'\), \(M''\) and Z requires \(50(2n)^3\) floating point operations (flops) – up to lower order terms – to which we have to add the cost of computing \(\widetilde{Z}_{21}\widetilde{Z}_{11}^{-1}\), i.e., about \(8/3 n^3\) flops.

figure a

5.2 The Doubling algorithm

Given a pencil \(\varphi (z)=A'+zB'\), where \(A',B'\in {\mathbb {C}}^{(m+n)\times (m+n)}\), with m eigenvalues inside the unit disk and n outside, under suitable assumptions, the (Structured) Doubling Algorithm (DA) allows one to find a deflating subspace corresponding to the eigenvalues inside and outside the unit disk.

For a complete description of doubling algorithms, we refer the reader to [5,   Chapter 5] and [18].

We restrict our attention to the case of interest, where \(\varphi (z)=M+zM^T\), with M defined in (4), thus \(m=n\). In particular, we are interested in computing the matrices X and Y which define the deflating subspaces in Eq. (12), and which in turn solve Eqs. (1) and (10), respectively.

First, one constructs a new pencil \(N+zK\), right equivalent to \(\varphi (z)\), but in the form

$$\begin{aligned} N=\begin{bmatrix} E_0 &{} 0 \\ -P_0 &{} I \end{bmatrix},\qquad K=\begin{bmatrix} I &{} -G_0\\ 0 &{} F_0 \end{bmatrix}. \end{aligned}$$
(16)

This is possible if and only if the matrix \(S=\left[ {\begin{matrix} C^T &{} D\\ D^T &{} -B \end{matrix}}\right] \) is invertible. Moreover, the matrices \(E_0\), \(F_0\), \(G_0\), \(P_0\) can be recovered by comparing the block entries in equation [24]

$$\begin{aligned} N+zK=S^{-1}(M+zM^T). \end{aligned}$$
(17)

Then, the doubling algorithm consists in generating the sequences

$$\begin{aligned} \begin{aligned} E_{\ell +1}=E_\ell (I-G_\ell P_\ell )^{-1} E_\ell ,&\quad P_{\ell +1}=P_\ell +F_\ell (I-P_\ell G_\ell )^{-1} P_\ell E_\ell ,\\ F_{\ell +1}=F_\ell (I-P_\ell G_\ell )^{-1} F_\ell ,&\quad G_{\ell +1}=G_\ell +E_\ell (I-G_\ell P_\ell )^{-1}G_\ell F_\ell ,\\ \end{aligned} \end{aligned}$$
(18)

for \(\ell \ge 0\), which are well defined if, at each step, \(I-G_\ell P_\ell \) and \(I-P_\ell G_\ell \) are invertible. The (at least) quadratic convergence of the sequences generated by the doubling algorithm is stated in the following results.

Theorem 6

Let M be as in (4) such that the assumptions of Theorem 5 are satisfied. If the sequences \(\{E_\ell \}_\ell ,\{F_\ell \}_\ell ,\{G_\ell \}_\ell ,\{P_\ell \}_\ell \) generated by the doubling iteration (18), with \(E_0,F_0,G_0,P_0\) as in (16) and (17), are well defined, then for any matrix norm,

$$\begin{aligned} \begin{aligned} \limsup _{\ell \rightarrow \infty }\root 2^\ell \of {\Vert P_\ell -X\Vert }\le \tau ^2,\qquad&\limsup _{\ell \rightarrow \infty }\root 2^\ell \of {\Vert H_\ell -Y\Vert }\le \tau ^2,\\ \limsup _{\ell \rightarrow \infty }\root 2^\ell \of {\Vert E_\ell \Vert }\le \tau ,\qquad&\limsup _{\ell \rightarrow \infty }\root 2^\ell \of {\Vert F_\ell \Vert }\le \tau , \end{aligned} \end{aligned}$$

where X and Y are the solutions to (1) and (10) associated with the eigenvalues of \(\varphi (z)\) inside and outside the unit circle, respectively, and

$$\begin{aligned} \tau= & {} \rho \bigl ((D^T-B^TX)^{-1}(A-BX)\bigr )\\= & {} \rho \bigl ((D+CY)^{-1}(A^T+C^TY)\bigr ) < 1. \end{aligned}$$

Proof

Theorem 5 implies that (12) holds, therefore the proof follows from the application of Theorem 5.3 of [5]. \(\square \)

The quadratic convergence of the sequence \(\{P_\ell \}_{\ell }\) to the solution X can be proved also with the assumption that \(\{F_\ell \}_\ell \) is bounded and that the pencil \(\varphi (z)\) satisfies the hypotheses of Theorem 3 (see [5,   Thm. 5.3]).

We wish to point out that the application of the Doubling Algorithm here is different from the case of the NARE (2), where one looks for a graph invariant subspace of the matrix H in (3) corresponding to eigenvalues on the left/right half plane. Indeed, for solving a NARE with the doubling algorithm, a preprocessing step is needed to get a pencil whose graph invariant subspace of interest has eigenvalues inside the unit disk. This preprocessing consists in applying rational transformations to the pencil \(H-z I\), such as the (generalized) Cayley transform. The different rational transformations lead to the variants of the DA algorithm, namely SDA, SDA with shrink-and-shift, ADDA [18], that have been treated differently in the literature. In our case, for the \(T\)-NARE, the eigenvalues are naturally split with respect to the unit circle, so that we can directly apply the Doubling Algorithm starting from the form (16).

The Doubling Algorithm for (1) is reported in Algorithm 2. Note that one step of the algorithm can be implemented with eight \(n\times n\) matrix multiplications, two LU factorizations, 4n solutions of triangular linear systems and some matrix additions, for a total amount of about \(\frac{64}{3} n^3\) flops per step.

figure b

5.3 The ordered palindromic QZ algorithm

The algorithms described in the previous sections do not exploit the palindromic structure of the pencil \(\varphi (z)=M+zM^T\).

A structured version of the QZ algorithm for palindromic pencils, namely the Palindromic QZ (PQZ) algorithm, has been developed and studied in [20, 22, 25]. The idea is to reduce \(\varphi (z)\) to a similar pencil \(R+zR^T\), where R is anti-triangular.

We adapt the PQZ algorithm to our problem, endowing it with an ordering procedure on the anti-triangular entries of the matrix R that allows us to deduce the desired deflating subspace.

The first step of the PQZ is the computation of the anti-triangular Schur form of M, which exists in view of the following result.

Theorem 7

[22,   Theorems 2.3–2.5] Let \(M\in {\mathbb {C}}^{2n\times 2n}\). Then there exists a unitary matrix \(U\in {\mathbb {C}}^{2n\times 2n}\) such that

figure c

is in anti-triangular form.

Moreover, let the pencil \(\varphi (z)=M+zM^{T}\) be regular and suppose that the matrix \(R=U^TMU\) is anti-triangular. Then, the spectrum of \(\varphi (z)\) is given b

$$\begin{aligned} \left\{ \lambda _j\;:\;r_{j,2n-j+1}\cdot \lambda _j=-r_{2n-j+1,j},\quad j=1,\ldots ,2n\right\} \subset {\mathbb {C}}\cup \{\infty \}, \end{aligned}$$
(20)

where the list \((\lambda _1,\ldots ,\lambda _{2n})\) is reciprocally ordered, namely \(\lambda _j=1/\lambda _{2n-j+1}\) for all \(j=1,\ldots ,2n\).

Corollary 2

With the assumptions in Theorem 7, if \(\varphi (z)\) has only zero or two eigenvalues of modulus 1, then the subset

$$\begin{aligned} \left\{ \lambda _1,\ldots ,\lambda _n\right\} \end{aligned}$$

of the spectrum (20) of \(\varphi (z)\) is reciprocal-free.

Proof

The result directly comes from the fact that the spectrum (20) is reciprocally ordered. Moreover, if \(\lambda \) is an eigenvalue of \(\varphi (z)\) with modulus 1 and multiplicity 2, then it appears only once in the first half of the spectrum, namely \(\left\{ \lambda _1,\ldots ,\lambda _n\right\} \). \(\square \)

In the next theorem we show how to construct the solution X to (1) by exploiting the anti-triangular Schur form (19) of M. To this end, we consider the following \(2\times 2\) block partition of the unitary matrix U,

$$\begin{aligned} U=\begin{bmatrix} U_{11} &{} U_{12}\\ U_{21} &{} U_{22}\\ \end{bmatrix}, \quad U_{ij}\in {\mathbb {C}}^{n\times n},\;i,j=1,2. \end{aligned}$$
(21)

Theorem 8

Let \(\varphi (z)=M+zM^T\) with M as in (4). Assume that \(\varphi (z)\) is regular, with exactly zero or two eigenvalues of modulus 1. Let U be a unitary matrix such that \(R=U^TMU\) is anti-triangular and its (1, 1)-block \(U_{11}\) with the notation in (21) is nonsingular. Then the matrix \(X=U_{21}U_{11}^{-1}\) is a solution to (1).

Proof

By construction, the columns of the matrix \(\left[ {\begin{matrix} U_{11}\\ U_{21} \end{matrix}}\right] \) span the deflating subspace of \(\varphi (z)\) associated with the first n eigenvalues \(\{\lambda _1,\ldots ,\lambda _n\}\). Similarly, the columns of

$$\begin{aligned} \begin{bmatrix} U_{11}\\ U_{21}\\ \end{bmatrix}U_{11}^{-1}=\begin{bmatrix} I\\ U_{21}U_{11}^{-1}\\ \end{bmatrix}, \end{aligned}$$

span the same subspace.

Since \(\{\lambda _1,\ldots ,\lambda _n\}\) is a reciprocal-free set of eigenvalues as shown in Corollary 2, the matrix \(X=U_{21}U_{11}^{-1}\) is a solution to (1) thanks to Theorem 2. \(\square \)

The PQZ scheme is thus very similar to its unstructured counterpart. However, from a computational point of view, the design of structure-preserving algorithms for the anti-triangular Schur form (19) of M is a rather challenging task.

Different schemes have been illustrated in the literature and in all the numerical examples we present in this paper we employ [22,   Algorithm 3.5] equipped with the palindromic QR procedure [25].

We must mention that the solution constructed from the first n columns of the matrix U obtained from the PQZ algorithm is associated with a reciprocal-free set \(\left\{ \lambda _1,\ldots ,\lambda _n\right\} \) of eigenvalues of the pencil \(\varphi (z)\), determined by the lower n antidiagonal entries of \(R+zR^T\). Nevertheless, one might be interested in a solution associated with a different set of reciprocal-free eigenvalues of \(\varphi (z)\), for instance the set of eigenvalues lying inside or outside the unit disk, if \(\det (\varphi (z))\ne 0\) on the unit circle.

A remedy is to postprocess the pencil \(R+zR^T\) by applying a reordering procedure that puts the desired eigenvalues on the lower part of the antidiagonal, so that the first columns of the modified matrix U yield the desired solution. Taking inspiration from [20,   Section 4.1] we now illustrate the procedure that guarantees the computation of the solution X to (1) associated with the n eigenvalues which lie inside the unit disk when the latter set exists. In principle, the same procedure can be applied to get a solution associated with any given reciprocal-free set of eigenvalues of \(\varphi (z)\).

Given the 2n eigenvalues \(\{\lambda _1,\ldots ,\lambda _{2n}\}\) ordered as in (20), we start by defining

$$\begin{aligned} k_1=\max \{i\,:\,i=1,\ldots ,2n,~|\lambda _i|<1\}-n. \end{aligned}$$

Clearly, \(0\le k_1\le n\). If \(k_1=0\), we do not need to reorder any column of U and \(X=U_{21}U_{11}^{-1}\) is the sought solution.

If \(k_1>0\), we consider the following \(2k_1\times 2 k_1\) submatrix \(R^{(1)}\) of R:

$$\begin{aligned} R^{(1)}=[e_{n-k_1+1},\ldots ,e_{k_1+n}]^{T}R[e_{2-k_1+1},\ldots ,e_{k_1+n}], \end{aligned}$$

partitioned as follows

$$\begin{aligned} R^{(1)}= \begin{bmatrix} 0 &{} 0 &{} R_{13}^{(1)} \\ 0&{} R_{22}^{(1)} &{} R_{23}^{(1)}\\ R_{31}^{(1)} &{} R_{32}^{(1)} &{} R_{33}^{(1)}\\ \end{bmatrix}, \end{aligned}$$

where \(R_{13}^{(1)}\), \(R_{31}^{(1)}\), and \(R_{33}^{(1)}\) are scalars, \(R_{22}\in {\mathbb {R}}^{2(k_1-1)\times 2(k_1-1)}\) is anti-triangular, and \(R_{23}^{(1)}\in {\mathbb {R}}^{2(k_1-1)\times 1}\) while \(R_{32}^{(1)}\in {\mathbb {R}}^{1\times 2(k_1-1)}\).

We need to compute a \(T\)-congruence transformation such that

$$\begin{aligned} \begin{bmatrix} W &{} Z^{T} &{} 1\\ Y^{T} &{} I_{k_1-2} &{}0 \\ 1 &{} 0 &{}0\\ \end{bmatrix}\begin{bmatrix} 0 &{} 0 &{} R_{13}^{(1)} \\ 0&{} R_{22}^{(1)} &{} R_{23}^{(1)}\\ R_{31}^{(1)} &{} R_{32}^{(1)} &{} R_{33}^{(1)}\\ \end{bmatrix}\begin{bmatrix} W &{} Y &{} 1\\ Z &{} I_{k_1-2} &{} 0 \\ 1 &{} 0 &{}0 \\ \end{bmatrix}= \begin{bmatrix} 0 &{} 0 &{} R_{31}^{(1)} \\ 0&{} R_{22}^{(1)} &{} 0\\ R_{13}^{(1)} &{} 0 &{} 0\\ \end{bmatrix}, \end{aligned}$$

where W is a scalar, \(Z\in {\mathbb {R}}^{2(k_1-1)\times 1}\), and \(Y\in {\mathbb {R}}^{1\times 2(k_1-1)}\).

A direct computation shows that the vectors Y and Z can be computed by solving the following system of \(T\)-Sylvester equations

$$\begin{aligned} \left\{ \begin{array}{rll} R_{31}^{(1)}Y+Z^{T}R_{22}^{(1)}&{}=&{}-R_{32}^{(1)},\\ R_{13}^{(1)}Y+Z^{T}(R_{22}^{(1)})^{T}&{}=&{}-(R_{23}^{(1)})^{T}. \end{array}\right. \end{aligned}$$
(22)

The numerical solution of (22) can be carried out by, e.g., [12,   Algorithm 2]. In our numerical experiments, since the matrix variables are just vectors, we solve the linear system of equations arising by Kronecker transformations, namely

$$\begin{aligned} \begin{bmatrix} R_{31}^{(1)}\cdot I_{2(k_1-1)} &{} (R_{22}^{(1)})^{T}\\ R_{13}^{(1)}\cdot I_{2(k_1-1)} &{} R_{22}^{(1)}\\ \end{bmatrix} \begin{bmatrix} \text {vec}(Y)\\ \text {vec}(Z^{T})\\ \end{bmatrix} = -\begin{bmatrix} \text {vec}(R_{32}^{(1)})\\ \text {vec}((R_{23}^{(1)})^{T})\\ \end{bmatrix}. \end{aligned}$$

Once Y and Z are computed, we define

$$\begin{aligned} W= -(R_{33}^{(1)}+R_{32}^{(1)}Z+Z^{T}R_{23}^{(1)}+Z^{T}R_{22}^{(1)}Z)/(R_{31}^{(1)}+R_{13}^{(1)}), \end{aligned}$$

and perform a QR factorization

$$\begin{aligned} \begin{bmatrix} W &{} Y &{} 1 \\ Z &{} I_{2(k_1-1)} &{} 0 \\ 1 &{} 0 &{} 0 \\ \end{bmatrix}=P^{(1)}G. \end{aligned}$$

Then the first n columns of the matrix

$$\begin{aligned} U^{(1)}=\begin{bmatrix} U^{(1)}_{11} &{} U^{(1)}_{12} \\ U^{(1)}_{21} &{} U^{(1)}_{22} \\ \end{bmatrix}= U\begin{bmatrix} I_{n-k_1} &{} 0 &{}0 \\ 0&{} P^{(1)} &{} 0\\ 0&{}0 &{} I_{n-k_1} \\ \end{bmatrix}, \end{aligned}$$

span a deflating subspace related to the set of eigenvalues \(\{\lambda _i,\;i=1,\ldots ,n,\,i\ne n-k_1+1\}\cup \{\lambda _{k_1+n}\}\).

We proceed by considering

$$\begin{aligned} k_2=\max \{i\,:\,i=1,\ldots ,k_1+n-1,~|\lambda _i|<1\}-n, \end{aligned}$$

and we repeat the same exact steps as before by defining \(R=(U^{(1)})^{T}MU^{(1)}\).

This procedure is iterated until

$$\begin{aligned} k_j=\max \{i\,:\,i=1,\ldots , k_{j-1}+n-1,~|\lambda _i|<1\}-n. \end{aligned}$$
(23)

is equal to 0, for a certain \(j\ge 1\).

In conclusion, we construct the solution \(X= U^{(j)}_{21}(U_{11}^{(j)})^{-1}\) which is related to the desired set of eigenvalues.

The overall palindromic QZ procedure is summarized in Algorithm 3. The computational cost of Algorithm 3 is mainly driven by the number of flops needed to perform [22,   Algorithm 3.5]. After a standard QZ step, that requires \({\mathcal {O}}(n^3)\) flops, the latter routine employs the palindromic QR algorithm [25] to compute a unitary matrix related to the eigenvalues of \(\varphi (z)\) inside the annulus \({\varLambda }_\alpha =\{\lambda \in {\mathbb {C}},\; 1/\alpha \le |\lambda |\le \alpha \}\) where \(\alpha >1\) is a user-defined parameter. If m is the number of eigenvalues of \(\varphi (z)\) in \({\varLambda }_\alpha \), the palindromic QR step costs \({\mathcal {O}}(m^4)\) flops. To conclude, the computational cost of the reordering procedure we proposed above amounts to \({\mathcal {O}}(k_j^3)\) flops for any index \(k_j\) in (23), leading to a cost of \({\mathcal {O}}(n^4)\) flops in the worst case.

figure d

6 Numerical examples

In this section we illustrate the numerical behaviour of the proposed algorithms for nonsymmetric \(T\)-NAREs (1): the invariant subspace methods presented in the previous sections, namely the Doubling Algorithm, and the standard and palindromic QZ methods. We study the properties of the computed solutions and their relation to the spectrum of \(\varphi (z)\) as outlined in Sect. 3 and compare them to the solutions computed by Newton’s method for small-scale \(T\)-NAREs proposed in [3]. Unless stated otherwise, in all the following examples we always use the value \(\varepsilon =10^{-12}\) in the convergence checks of both Newton’s method and DA.

Results were obtained by running MATLAB R2017b on a laptop with an Intel Core i3 processor running at 2GHz using 3.5GB of RAM.

The implementation of QZ is based on the MATLAB routine ordqz, the implementation of DA follows the code enclosed to [5], while the implementation of PQZ is based on [22]. As already mentioned, [22,   Algorithm 3.5] needs an input parameter \(\alpha \). In all the examples reported in Sect. 6 we use \(\alpha =1.1\). From our numerical experience, the performance of the solver turned out to be quite robust under small changes of the parameter \(\alpha \) (see [22] for more details).

We point out that while the deflating subspace algorithms (DA, QZ and PQZ) can compute a solution associated with a reciprocal free set of eigenvalues, Newton’s method could in principle compute any solution. On the other hand, it appears to be difficult to find suited initial values for which Newton’s method converges to a sought solution, associated with a desired eigenvalue distribution. From this point of view, we can thus see the deflating subspace algorithms to be more flexible than Newton’s method.

Example 1

We consider the equation in Example 4.1 of [3], where the coefficient matrices defining the \(T\)-NARE (1) are

$$\begin{aligned} A=\begin{bmatrix} -1 &{} -1 &{} &{} \\ &{} -1 &{} -1 \\ &{} &{} \ddots &{}\ddots \\ &{} &{} -1 &{} -1 \\ &{} &{} &{} -1 \\ \end{bmatrix},\; D=\begin{bmatrix} 4 &{} -1 &{} &{} \\ &{} 4 &{} -1 \\ &{} &{} \ddots &{}\ddots \\ &{} &{} 4 &{} -1 \\ &{} &{} &{} 4 \\ \end{bmatrix},\; E=\begin{bmatrix} -1 &{} -1 &{} &{} \\ &{} -1 &{} -1 \\ &{} &{} \ddots &{}\ddots \\ &{} &{} -1 &{} -1 \\ &{} &{} &{} -0.9 \\ \end{bmatrix}, \end{aligned}$$

together with \(B=-A/\Vert A\Vert _F\), and \(C=E/\Vert E\Vert _F\). Empty entries in the matrices represent zero entries.

As shown in [3], there exists a nonnegative minimal solution \(X_{\min }\) to this \(T\)-NARE and Newton’s method with \(X_0=0\) converges to \(X_{\min }\).

In Table 1, we report the relative residual norm

$$\begin{aligned} \Vert R\Vert _F=\frac{\Vert DX+X^{T}A-X^{T}BX+C\Vert _F}{\Vert X\Vert _F}, \end{aligned}$$

achieved by the numerical solution X computed by DA, QZ, PQZ and Newton’s scheme along with the relative distance between solution obtained by Newtons’ method \(X_{Newt}\) and the solution X computed by the invariant subspace methods, namely \(\Vert X_{Newt}-X\Vert _F/ \Vert X_{Newt}\Vert _F\), for different values of n.

Table 1 Example 1. “Rel. Res.” denotes the relative residual norm achieved by PQZ, QZ, DA and Newton’s scheme from [3]; “Rel. Dist.” the relative distance between the solutions computed by the invariant subspace methods and the one obtained by Newton’s scheme

From the results in Table 1 we can notice that the solutions computed by the methods we tested are very closed to each other. This means that for this example, also the invariant subspace methods are able to compute a very accurate approximation to the actual minimal nonnegative solution.

Fig. 1
figure 1

Example 1. Eigenvalue distribution of the pencil \(\alpha (z)=A-BX+z(D^T-B^TX)\) where X is the solution computed by the PQZ method for \(n=100\). The black solid line indicates (a portion of) the boundary of the unit disk

In Fig. 1 we report the eigenvalue distribution of the matrix pencil \(\alpha (z)=A-BX+z(D^T-B^TX)\) for \(n=100\), where X is the solution computed by the PQZ method, and we can see that the spectrum of \(\alpha (z)\) is outside the unit circle. This happens for all the values of n we tested. Therefore, for this example, the solution we compute can be characterized in two different ways: on one hand, it can be viewed as the unique minimal nonnegative solution as shown in [3]; on the other hand, by Theorem 2, it is also the unique solution such that the eigenvalues of \(\alpha (z)\) are all outside the unit circle.

To conclude, in Table 2 we report the running times of the PQZ method, QZ, DA, and Newton’s procedure. We notice that the DA algorithm turns out to be the fastest method we tested. Even though this scheme needs more iterations than Newton’s method to converge, each of these iterations is quite cheap as it involves only inversions and linear combinations of matrices of size n. On the other hand, the solution of a \(T\)-Sylvester equation needed at each step of Newton’s method is rather expensive increasing the computational cost of the overall scheme. The most demanding step of the PQZ and QZ methods is the computation of the unitary matrices Q and Z for the pencil \(\varphi (z)\). However, for this example, both the latter algorithms are slightly faster than Newton’s scheme.

Table 2 Example 1. Computational time in seconds achieved by PQZ, QZ, DA, and Newton’s scheme from [3]

Example 2

We consider Example 4.2 in [3] where the matrices \(A,D\in {\mathbb {R}}^{n\times n}\) come from the finite difference discretization on the unit square of 2-dimensional differential operators equipped with homogeneous Dirichlet boundary conditions, while \(B,C\in {\mathbb {R}}^{n\times n}\) are full random matrices.

As before, we solve the related \(T\)-NARE by means of the PQZ method, QZ, DA, and Newton’s method and in Table 3 we report the results.

We wish to point out that, for this example, the properties of the coefficient matrices do not guarantee the existence of a unique minimal nonnegative solution. Nevertheless, in [3] it is shown that Newton’s method is able to compute an accurate numerical solution in terms of relative residual norm.

Table 3 Example 2. “Rel. Res.” denotes the relative residual norm achieved by PQZ, QZ, DA, and Newton’s scheme from [3]; “Rel. Dist.” the relative distance between the solutions computed by the invariant subspace methods and the one obtained by Newton’s scheme

From the results in Table 3 we can notice that also for this example the invariant subspace methods and Newton’s scheme compute the same numerical solution. In particular, for both the values of n we tested, this solution is the unique solution such that the spectrum of \(\alpha (z)\) is outside the unit circle. Therefore, even though we cannot characterize the computed solution in terms of minimality, its uniqueness is guaranteed by Theorem 2.

We compare the PQZ method, QZ, DA, and Newton’s procedure also from a computational perspective and in Table 4 we report the results. Conclusions similar to the ones illustrated in Example 1 can be drawn. The DA algorithm is still the fastest method we tested while Newton’s method suffers whenever a sizable number of iterations is needed to converge. The PQZ and QZ methods perform better than Newton’s method but are one order of magnitude slower than DA.

Table 4 Example 2. Computational time in seconds achieved by PQZ, QZ, DA, and Newton’s scheme from [3]

Example 3

In this example we compare only the results achieved by the PQZ method and Newton’s scheme. We consider the following \(2\times 2\) problem

$$\begin{aligned} D=\begin{bmatrix} 1 &{} 0\\ -0.1 &{} 2\\ \end{bmatrix},\quad A=\begin{bmatrix} 1 &{} -0.2\\ -0.1 &{} 2\\ \end{bmatrix},\quad B=\begin{bmatrix} 0.2 &{} 0.1\\ 0.3 &{} 0.4\\ \end{bmatrix},\quad C=\begin{bmatrix} -0.1 &{} -0.1\\ -0.1 &{} -0.1\\ \end{bmatrix}. \end{aligned}$$

PQZ with no reordering computes the following solution

$$\begin{aligned} X_{out}\approx \begin{bmatrix} 20.1028 &{} -25.4499 \\ -11.5037 &{} 14.6980\\ \end{bmatrix}, \end{aligned}$$

which is the unique solution such that the spectrum of

$$\begin{aligned} \alpha _{out}(z)=A-BX_{out}+z(D^T-B^TX_{out}), \end{aligned}$$

is given approximately by \(\{-1.09484, -1.05880\}\) and lies outside the unit circle. Thanks to the strategy presented at the end of Sect. 5.3, we are also able to construct the matrix

$$\begin{aligned} X_{in}\approx \begin{bmatrix} 2.6923 &{} 3.6756 \\ 1.9569 &{} 2.6749 \\ \end{bmatrix}, \end{aligned}$$

which approximates the unique solution such that the eigenvalues of \(\alpha _{in}(z)=A-BX_{in}+z(D^T-B^TX_{in})\) are inside the unit circle. The spectrum of \(\alpha _{in}\) is approximately given by \(\{-0.91338, -0.94447\}\). Both \(X_{out}\) and \(X_{in}\) achieve a relative residual norm of the order of \(10^{-12}\).

It is interesting to notice that Newton’s method applied to this example computes neither \(X_{out}\) nor \(X_{in}\). The solution

$$\begin{aligned} X_{Newt}\approx \begin{bmatrix} 0.0490 &{} 0.1541\\ -0.0220 &{} 0.0385\\ \end{bmatrix}, \end{aligned}$$

computed by Newton’s method with zero initial guess is such that the spectrum of \(\alpha _{Newt}(z)\) is approximately given by \(\{-0.94447,-1.09484\}\). The latter is a reciprocal-free set but does not lie inside/outside the unit circle. This example shows that the zero initial value does not implies the convergence of Newton’s method to the unique solution X related to a pencil \(\alpha (z)\) whose eigenvalues are all inside/outside the unit circle.

Example 4

In the last example we compare the accuracy in terms of forward error achieved by PQZ, QZ and DA with respect to a reference solution computed with high precision arithmetic.

Even though the numerical results reported in the previous examples show that the DA algorithm is very competitive in terms of running time, this method does not exploit the palindromic structure of the problem with a possible loss of accuracy. Also the (plain) QZ method shares this drawback.

For a given n, we start by defining the matrix \(\widetilde{M}\in {\mathbb {R}}^{2n\times 2n}\) entry-wise as follows

$$\begin{aligned} \widetilde{M}\;:\;\left\{ \begin{array}{llll} \widetilde{M}_{i,2n-i+1}&{}=&{}i+1,&{} i=1,\ldots ,n-1,\\ \widetilde{M}_{2n-i+1,i}&{}=&{}1/(i+1),&{} i=1,\ldots ,n-1,\\ \widetilde{M}_{n+1,n}&{}=&{}\sigma +1,&{}\\ \widetilde{M}_{n,n+1}&{}=&{}1/(\sigma +1),&{}\\ \widetilde{M}_{i,j}&{}=&{}0,&{}i<j,\\ \widetilde{M}_{i,j}&{}=&{}1/5,&{} i>j,\\ \end{array}\right. \end{aligned}$$

where \(\sigma >0\) is given.

Then the matrix M in (4) is defined as \(M = N\widetilde{M}N^{T}\) where

$$\begin{aligned} N=\begin{bmatrix} 1 &{} 1 &{} \cdots &{} 1\\ -1 &{} 1 &{}\cdots &{} 1\\ \vdots &{} \ddots &{} \ddots &{} \vdots \\ -1 &{} \cdots &{} -1&{} 1\\ \end{bmatrix}. \end{aligned}$$

Finally, we partition M as in (4) and choose the coefficient matrices A, B, C, and D defining Eq. (1) accordingly.

Observe that the eigenvalues of the pencil \(\varphi (z)\) are \(\lambda _i,\lambda _i^{-1}\), \(i=1,\ldots ,n\), where \(\lambda _1=1/(1+\sigma )^2\), and \(\lambda _i=1/i^2\) for \(i=2,\ldots ,n\). Therefore, the smaller \(\sigma \), the narrower the separation of the eigenvalues with respect to the unit circle.

We choose \(\sigma =10^{-10}\) and we construct the matrix M by making use of MATLAB’s variable precision arithmetic (vpa). In particular, we employ 100 decimal digit accuracy.

We first solve the equation by DA equipped with vpa. The computed solution rounded to double precision is denoted by \(X_{Exact}\) and is considered as reference solution. Notice that the DA algorithm is very well-suited for the use of vpa as it only involves linear combinations and inversions of matrices.

We then solve the same equation by PQZ, QZ, and DA, all equipped with double precision arithmetic.

In Table 5, we report the relative forward error achieved by the aforementioned schemes, namely \(\Vert X_{Exact}-X\Vert _F/ \Vert X_{Exact}\Vert _F\).

Table 5 Example 4. Relative forward error achieved by PQZ, QZ, and DA

We can notice that, for this example, the PQZ method is able to achieve a very small relative forward error by relying on the full exploitation of the palindromic structure of the problem. On the other hand, QZ and DA completely neglect this property and they end up constructing less accurate solutions.

7 Conclusions

The main result of this paper relates the solution of \(T\)-NAREs to deflating subspaces of a specific matrix pencil. Such a novel relation allowed us to design methods to solve \(T\)-NAREs based on invariant subspace algorithms. In particular, the PQZ, QZ and DA schemes have been proposed and tested.

We showed that DA is the fastest algorithm. Indeed, DA has a quadratic convergence, like Newton’s method proposed in [3], but it has lower computational cost per step and does not require the choice of an initial approximation. In the application of DA we have not exploited the palindromic structure of the pencil \(\varphi (z)\). The exploitation of such structure might be useful for large scale problems, as in [8].

The PQZ scheme is the most accurate algorithm, in terms of forward error, thanks to its fully exploitation of the palindromic structure of the underlying eigenvalue problem. Concerning accuracy, we have not exploited possible nonnegative properties of the coefficients, to design an accurate implementation of DA, as for instance in [23] and [21] for NAREs. This investigation might be the subject of a future research.

As an alternative to the inexact Newton method proposed in [3], we envision the design of projection methods for the solution of large-scale \(T\)-NAREs, e.g., by adapting the approach proposed in [13] for \(T\)-Sylvester equations. The numerical routines analyzed in this paper can then successfully serve as inner solver for the reduced equations stemming from the adopted projection technique.