# Subspace angles

This example considers the angles between neighbouring Laguerre polynomials with a perturbed measure:

$\cos\theta_n = \frac{\langle L_n, L_{n+k}\rangle}{\|L_n\|_2 \|L_{n+k}\|_2},\quad{\rm for}\quad 0\le n < N-k,$

where the inner product is defined by $\langle f, g\rangle = \int_0^\infty f(x) g(x) x^\beta e^{-x}{\rm\,d}x$.

We do so by connecting Laguerre polynomials to the normalized generalized Laguerre polynomials associated with the perturbed measure. It follows by the inner product of the connection coefficients that:

$\cos\theta_n = \frac{(V^\top V)_{n, n+k}}{\sqrt{(V^\top V)_{n, n}(V^\top V)_{n+k, n+k}}}.$
using FastTransforms, LinearAlgebra

The neighbouring index k and the maximum degree N-1:

k, N = 1, 11
(1, 11)

The Laguerre connection parameters:

α, β = 0.0, 0.125
(0.0, 0.125)

We precompute a Laguerre–Laguerre plan:

P = plan_lag2lag(Float64, N, α, β; norm2=true)
FastTransforms Laguerre--Laguerre plan for 11-element array of Float64

We apply the plan to the identity, followed by the adjoint plan:

VtV = parent(P*I)
lmul!(P', VtV)
11×11 Matrix{Float64}:
0.941743    -0.117718    -0.0515016  -0.0321885  -0.0231355  -0.01793    -0.0145681  -0.0122268  -0.0105074  -0.00919399  -0.00815966
-0.117718     1.07418     -0.125995   -0.0539157  -0.0333201  -0.0237861  -0.0183502  -0.0148608  -0.0124417  -0.0106716   -0.00932328
-0.0515016   -0.125995     1.14505    -0.131707   -0.0557687  -0.0342413  -0.024336   -0.0187146  -0.0151194  -0.0126345   -0.0108205
-0.0321885   -0.0539157   -0.131707    1.19444    -0.136106   -0.0572798  -0.0350206  -0.0248132  -0.0190369  -0.0153515   -0.0128093
-0.0231355   -0.0333201   -0.0557687  -0.136106    1.23272    -0.139703   -0.0585599  -0.0356975  -0.0252354  -0.0193261   -0.015562
-0.01793     -0.0237861   -0.0342413  -0.0572798  -0.139703    1.26415    -0.142756   -0.059673   -0.0362968  -0.0256145   -0.0195886
-0.0145681   -0.0183502   -0.024336   -0.0350206  -0.0585599  -0.142756    1.29092    -0.145414   -0.0606594  -0.0368352   -0.0259588
-0.0122268   -0.0148608   -0.0187146  -0.0248132  -0.0356975  -0.059673   -0.145414    1.31429    -0.147773   -0.0615464   -0.0373246
-0.0105074   -0.0124417   -0.0151194  -0.0190369  -0.0252354  -0.0362968  -0.0606594  -0.147773    1.33507    -0.149896    -0.062353
-0.00919399  -0.0106716   -0.0126345  -0.0153515  -0.0193261  -0.0256145  -0.0368352  -0.0615464  -0.149896    1.3538      -0.151829
-0.00815966  -0.00932328  -0.0108205  -0.0128093  -0.015562   -0.0195886  -0.0259588  -0.0373246  -0.062353   -0.151829     1.37089

From this matrix, the angles are recovered from:

θ = [acos(VtV[n, n+k]/sqrt(VtV[n, n]*VtV[n+k, n+k])) for n in 1:N-k]
10-element Vector{Float64}:
1.6881063520094897
1.6846487354051982
1.6836556387180577
1.6831998143073255
1.6829427202726823
1.68277949501306
1.682667534322365
1.6825864250312665
1.6825252245704025
1.682477567030148