The matrix

 1 Re x > 0,  sign(x) = −1 Re x < 0,  undefined Re x = 0. Suppose the Jordan form of A is reblocked as " # h i J1 h i−1 A = V1 V2 V1 V2 , J2

where J1 contains all eigenvalues in the LHP (left half-plane) and J2 in the RHP. Then, " # h i −I h i−1 sign(A) = V V V V . 1 2 I 1 2

sign(A) is always diagonalizable with eigenvalues ±1. sign(A) ± I gives the projections on the span of the eigenvectors in the RHP/LHP (unstable/stable invariant subspace).

Sign and Useful formula: sign(A) = A(A2)−1/2, where A1/2 is the principal square root of A (all eigenvalues in the right half-plane), and A−1/2 is its inverse. Proof: consider eigenvalues, sign(x) = x . (Care with signs.) (x 2)1/2 Theorem

If AB has no eigenvalues on R≤0 (hence neither does BA), then " # " # 0 A 0 C sign = , C = A(BA)−1/2. B 0 C −1 0

Proof (sketch) Use sign(A) = A(A2)−1/2 (and then sign(A)2 = I). For instance, " # " # 0 A 0 A1/2 sign = . I 0 A−1/2 0

Conditioning From the theorems on the Fréchet , for a diagonalizable A 2 κabs (sign(A)) ≤ κ2(V ) minRe λi <0, Re λj >0|λi − λj |

Tells only part of the truth: computing sign(A) is “better” than a full diagonalization: it is not sensitive to close eigenvalues that are far from the imaginary axis. Condition number

Theorem

T −1 T κabs (sign, A) = k(I ⊗ N + N ⊗ I) (I − S ⊗ S)k, where N = (A2)1/2.

Proof (sketch): let L = Lsign,A(E). Then, up to second-order factors, (A + E)(S + L) = (S + L)(A + E) and (S + L)2 = I. Some manipulations give NA + AN = E − SES.

In particular, sep(N, −N) plays a role.

Remark: if all eigenvalues of A are in the RHP, then the formula gives κabs (sign, A) = 0. Makes sense, since sign(A) = sign(A + E) = I for all E for which eigenvalues do not cross the imaginary axis. . .

Schur-Parlett method We can compute sign(A) with a Schur decomposition. Simplest case: the decomposition is ordered so that eigenvalues in the LHP come first: Λ(T11) ⊆ LHP, Λ(T22) ⊆ RHP. " # " # T T −IX Q∗AQ = 11 12 , Q∗f (A)Q = 0 T22 0 I

where X solves T11X − XT22 = −f (T11)T12 + T12f (T22) = 2T12. Condition number of this Sylvester equation: depends on sep(T11, T22). Schur-Parlett for the sign

1. Compute A = QTQT . 2. Reorder Schur decomposition so that eigenvalues in the LHP come first. 3. Solve Sylvester equation for X. h −IX i T 4. sign(A) = Q 0 I Q . Newton for the matrix sign Most popular algorithm: Newton for the matrix sign

sign(A) = limk→∞ Xk , where 1 X = (X + X −1), X = A. k+1 2 k k 0

Suppose A diagonalizable: then we may consider the scalar version of the iteration on each eigenvalue λ:

  2 1 1 xk + 1 xk+1 = xk + = , x0 = λ. 2 xk 2xk Fixed points: ±1 (with local quadratic convergence). Eigenvalues in the RHP stay in the RHP (and same for LHP). (It’s Newton’s method on f (x) = x 2 − 1, which justifies the name).

Convergence analysis of the scalar iteration Trick: change of variables (Cayley transform)

1 + x y − 1 y = , with inverse x = . 1 − x y + 1

If x ∈ RHP, then |x + 1| > |x − 1| =⇒ y outside the unit disk. If x ∈ LHP, then |x − 1| > |x + 1| =⇒ y inside the unit disk. (“Poor man’s exponential”)

1  1  2 xk+1 = xk + corresponds to yk+1 = y (check it!). 2 xk k

If we start from x0 ∈ LHP, then |y0| < 1, then lim yk = 0 (i.e., lim xk = −1).

If we start from x0 ∈ RHP, then |y0| > 1, the squares diverge, and lim yk = ∞ (i.e., lim xk = 1).

Convergence analysis of the matrix iteration The same proof works, as long as A does not have the eigenvalue 1 (invertibility). Small modification to fix this case, too: Change of variables:

−1 −1 Yk = (Xk −S)(Xk +S) , with inverse Xk = (I −Yk ) (I +Yk )S.

All the Xk are rational functions of A, so they commute with it and with S. Analyzing eigenvalues: the inverse exists and ρ(Yk ) < 1.

−1 2 2 −1 2 Yk+1 = (Xk (Xk + I − 2SXκ))Xk (Xk + I + 2SXk ) = Yk .

Yk → 0, hence Xk → S.

The algorithm

1. X0 = A. 1 −1 2. Repeat Xk+1 = 2 (Xk + Xk ), until convergence.

We really need to compute that matrix inverse (unusual in numerical linear algebra. . . ) Scaling

If xk  1, then 1  1  1 xk+1 = xk + ≈ xk , 2 xk 2

and “the iteration is an expensive way to divide by 2” [Higham]. Same if xk  1 — the iteration just multiplies by 2. Similarly, for matrices, convergence cannot occur until each eigenvalue has converged to ±1. Trick: replace A with µA for a scalar µ > 0 — they have the same sign. Choose this µ so that eigenvalues ≈ 1. (Once, or at each step.)

Scaling possibilities Possibility 1: (determinantal scaling): choose µ = (det A)−1/n, so that det A = 1. Reduces “mean distance” from 1. Cheap to compute, since we already need to invert A. Possibility 2: (spectral scaling): choose µ so that λmin(µA)λmax(µA) = 1. (We can use the power method to estimate them.) Possibility 3: (norm scaling): choose µ so that σmin(µA)σmax(µA) = 1. (Again via the power method for σmin.) Surprisingly, on a matrix with real eigenvalues Possibility 2 gives convergence in a finite number of iterations, if done at each step: the first iteration maps λmin(A) and λmax(A) to eigenvalues with the same modulus; then the second iteration adds a third eigenvalue with the same modulus. . .

Other iterations There is an elegant framework to determine other iterations locally convergent to sign(x) (in a neighbourhood of ±1): start from z sign(z) = , (z2)1/2

and replace the square root using a Padé approximant of (1 − x)1/2. In the end, they produce iteration functions of the form

(1 + z)r + (1 − z)r f (z) = . r (1 + z)r − (1 − z)r

Advantage of using the Newton-sign iteration: it has the correct basins of attraction (convergence is global and not only local).

Stability of the sign iterations The stability analysis is complicated (and not even done completely in articles). [Bai Demmel ’98 and Byers Mehrmann He ’97] While it works well in practice, the Newton iteration is not backward stable. The sign is not even stable under small perturbations: assuming h i (up to a change of basis) A = A11 A12 , then 0 A22

kEk ksign(A + E) − sign(A)k . 3 . sep(A11, A22) Nevertheless, the invariant subspaces it produces are: A + E has a  I  stable invariant subspace of the form X , with kEk kXk . . sep(A11, A22) (The invariant subspace stability bound from the first lectures.) Inversion-free sign Suppose that we are given M, N such that A = M−1N. Can we compute sign(A) without inverting M? Yes.

1 1 X = (A + A−1) = (M−1N + N−1M) 1 2 2 1 = M−1(N + MN−1M) 2 1 = M−1(N + Mˆ −1NMˆ ) 2 1 = M−1Mˆ −1(MNˆ + NMˆ ) 2 1 = (MMˆ ) (MNˆ + NMˆ ) =: M−1 N . 2 1 1

assuming we can find Mˆ , Nˆ such that MN−1 = Mˆ −1Nˆ .

Then the same computations produce M2, N2, M3, N3,...

Inversion-free sign How to find Mˆ , Nˆ such that MN−1 = Mˆ −1Nˆ ? " # h i M MMˆ = NNˆ , or Mˆ Nˆ = 0. We can obtain Mˆ , Nˆ from a −N kernel. Computing this kernel can be much more accurate than inverting M and/or N, e.g., 1 0 " #   M 0 ε =   . −N ε 0 0 1