Chapter 11 polar coordinate Speaker: Lung-Sheng Chien Book: Lloyd N. Trefethen, Spectral Methods in MATLAB Discretization on unit disk Consider eigen-value problem on unit disk u 2u with boundary condition u r 1, 0 x r cos , then y r sin We adopt polar coordinate 1 1 u urr ur 2 u 2u r r , on r 0,1 and 0, 2 Usually we take periodic Fourier grid in , and non-periodic Chebyshev grid in r 1 r 0,1 Chebyshev grid in x1,1 r x 1 2 Chebyshev grid in r 0,1 Observation: nodes are clustered near origin r 0 , for time evolution problem, we need smaller time-step to maintain numerical stability. 2 r 1,1 x r cos r cos y r sin r sin x, y 0,0 1 to 2 mapping r , Asymptotic behavior of spectrum of Chebyshev diff. matrix In chapter 10, we have showed that spectrum of Chebyshev differential matrix DN2 (second order) approximates uxx u, 1 x 1, B.C. u 1 0 1 2 with eigenmode k 2 4 Eigenvalue of DN2 is negative (real number) and max 0.048N 4 Large eigenmode of D 2 N does not approximate to k Since ppw is too small such that resolution is not enough Mode N is spurious and localized near boundaries x 1 2 4 k2 k2 Grid distribution 1 r 0,1 2 r 1,1 Preliminary: Chebyshev node and diff. matrix [1] j Consider N 1 Chebyshev node on 1,1 , x j cos for j 0,1, 2, , N N Uniform division in arc xN x3 x2 x1 x0 1 xN / 2 1 x Even case: N 6 1 x6 x5 x3 0 x4 x2 x1 x0 1 x x1 x0 1 x Odd case: N 5 1 x5 x4 x3 0 x2 Preliminary: Chebyshev node and diff. matrix [2] j Given N 1 Chebyshev nodes , x j cos and corresponding function value v j N N We can construct a unique polynomial of degree N , called p x v j S j x j 0 1 k j is a basis. S j xk 0 k j N p xi v j S j j 0 1 N xi DijN v j where differential matrix DN j 0 D is expressed as x j 2N 2 1 N 2N 2 1 N D , for j 1, 2, D , D , NN jj 2 6 2 1 x j 6 N 00 c 1 DijN i , for i j, i, j 0,1, 2, c j xi x j i j with identity D N ii ,N N j 0, j i DijN Second derivative matrix is DN2 DN DN N ij , N 1 2 i 0, N where ci 1 otherwise Preliminary: Chebyshev node and diff. matrix [3] Let p x be the unique polynomial of degree N with p 1 0 and p x j v j define w j p x j and z j p x j for 0 j N 2 We abbreviate w DN v , then impose B.C. p 1 0 ,that is, v0 vN 0 In order to keep solvability, we neglect w0 wN ,that is, DN2 DN2 1: N 1,1: N 1 neglect w0 w1 w2 wN 1 neglect wN DN2 v0 v1 v2 vN 1 vN zero zero Similarly, we also modify differential matrix as DN DN 1: N 1,1: N 1 Preliminary: DFT v1, v2 , Given a set of data point , vN R N [1] with N 2m is even, h 2 N Then DFT formula for v j 2 vˆk N 1 vj 2 N v j 1 j m k m 1 exp ikx j for k m, m 1, vˆk exp ikx j for j 1, 2, , m 1, m ,N Definition: band-limit interpolant of function, is periodic sinc function SN x m sin x / h h 1 sin mx P eikx 2 k m 2 / h tan x / 2 2m tan x / 2 SN x If we write v j N v k 1 k j k m N 1 ikx v , then p x P e vˆk vk S N x xk 2 k m k 1 v S x Also derivative is according to w j p x j N k 1 k 1 N j xk Preliminary: DFT [2] sin x / h , we have Direct computation of derivative of S N x 2 / h tan x / 2 0 j 0 mod N S N1 x j 1 j jh 1 cot , j 0 mod N 2 2 Example: D5 S5 x j xk 1 0 S51 h S51 2h S51 3h S51 4h 1 1 1 1 0 S5 h S5 2h S5 3h S5 h S51 2h S51 h 0 S51 h S51 2h 1 1 1 1 S 3 h S 2 h S h 0 S h 5 5 5 5 1 S 1 4h S 1 3h S 1 2h S h 0 5 5 5 5 is a Toeplitz matrix. 1 2 j 0 mod N 2 6 3 h 2 Second derivative is S N x j j 1 , j 0 mod N 2sin 2 jh / 2 Preliminary: DFT [3] 1 2 j 0 mod N 2 6 3h S N 2 x j j 1 , j 0 mod N 2sin 2 jh / 2 v S x For second derivative operation w j p x j N k 1 k N xk DN2 j , k vk N 2 j k 1 second diff. matrix is explicitly defined by using Toeplitz matrix (command in MATLAB) DN2 S N 2 x j xk csc 2 2h / 2 / 2 csc2 h / 2 / 2 1 2 2 6 3h 2 csc h / 2 / 2 csc 2 2h / 2 / 2 2:N 1 2 1 toeplitz 6 3h 2 , 2sin 2 1: N 1 h / 2 Fornberg’s idea : extend radius to negative image [1] r 1,1 and 0, 2 x, y unit disk 1 Nr 5 (odd): to avoid singularity of coordinate transformation r 0 2 N 6 (even): to keep symmetry condition u r , u r , mod 2 r r coordinate x y coordinate 1 r0 r1 r0 y 2 r2 r3 r4 1 rNr r5 1 3 0 1 2 3 4 5 6 0 N 2 6 4 5 x Fornberg’s idea : extend radius to negative image [2] In general Nr 2k 1 is odd, and N 2m is even, then r : non-unif and ri 1 ir : 1 i Nr 1 Active variable j j : 1 j N , total number is Nr 1 N r coordinate r x y coordinate 1 r0 r1 r2 r0 2 N y 2 1 rk rk 1 m rNr 1 1 rNr 0 1 2 0 m m1 N 1 N 2 N m1 N 1 x Redundancy in coordinate transformation [1] 2 to 1 mapping r , , r , mod 2 x, y x y coordinate r coordinate y r 2 redundant 1 r0 r1 r0 3 r2 r3 r4 1 rNr r5 1 4 6 x 6 x 5 y 2 0 1 2 3 4 5 6 0 N 2 1 3 4 5 Redundancy in coordinate transformation [2] 2 to 1 mapping r , , r , mod 2 x, y x y coordinate r coordinate y 2 r 1 r0 r1 r0 3 r2 r3 r4 1 rNr r5 1 x 6 x 5 4 y redundant 2 0 1 2 3 4 5 6 0 N 2 6 1 3 4 5 Redundancy in coordinate transformation [3] Nr 2k 1 5 is odd, then Chebyshev differential matrix DNr r0 r2 r3 r4 r1 DNr DNr is expressed as r5 8.5 -10.4721 2.8944 -1.5279 1.1056 -0.5 r0 2.6180 -1.1708 -2 0.8944 -0.618 0.2764 r1 -0.7236 2 -0.1708 -1.6180 0.8944 -0.382 r2 0.3820 -0.8944 1.618 0.1708 -2 0.7236 r3 -0.2764 0.6180 -0.8944 2 1.1708 -2.618 r4 0.5 -1.1056 1.5279 -2.8944 10.4721 -8.5 r5 -1.1708 -2 0.8944 -0.618 2 -0.1708 -1.6180 0.8944 -0.8944 1.618 0.1708 -2 0.6180 -0.8944 2 1.1708 neglect Redundancy in coordinate transformation [4] Symmetry property of Chebyshev differential matrix : DN i , j DN N i , N j DNr -1.1708 -2 0.8944 -0.618 2 -0.1708 -1.6180 0.8944 -0.8944 1.618 0.1708 -2 0.6180 -0.8944 2 1.1708 E1 E2 -1.1708 -2 is symmetric 2 -0.1708 -0.618 0.8944 is NOT symmetric 0.8944 -1.6180 Permute column by P 1, 2, 4,3 DNr P T -1.1708 -2 -0.618 0.8944 2 -0.1708 0.8944 -1.6180 -0.8944 1.618 -2 0.1708 0.6180 -0.8944 1.1708 2 E 1 u1 u E2 2 is faster ? u3 u4 Redundancy in coordinate transformation [5] 2 Nr 2k 1 5 is odd, then Chebyshev differential matrix DNr r0 r2 r3 r4 r1 DN2 r DNr DNr D 2 Nr is expressed as r5 41.6 -68.3607 40.8276 -23.6393 17.5724 -8 r0 21.2859 -31.5331 12.6833 -3.6944 2.2111 -0.9528 r1 -1.8472 7.3167 -10.0669 5.7889 -1.9056 0.7141 r2 0.7141 -1.9056 5.7889 -10.0669 7.3167 -1.8472 r3 -0.9528 2.2111 -3.6944 12.6833 -31.5331 21.2859 r4 -8 17.5724 -23.6393 40.8276 -68.3607 41.6 r5 -31.5331 12.6833 -3.6944 2.2111 7.3167 -10.0669 5.7889 -1.9056 -1.9056 5.7889 -10.0669 7.3167 2.2111 -3.6944 12.6833 -31.5331 neglect Redundancy in coordinate transformation [6] Symmetry property of Chebyshev differential matrix : D 2 Nr -31.5331 12.6833 -3.6944 2.2111 7.3167 -10.0669 5.7889 -1.9056 -1.9056 5.7889 -10.0669 7.3167 2.2111 -3.6944 12.6833 -31.5331 D1 D 2 N i, j DN2 -31.5331 N i , N j 12.6833 is NOT sym. 7.3167 -10.0669 2.2111 -3.6944 Permute column by P 1, 2, 4,3 D2 D P 2 Nr -31.5331 12.6833 2.2111 -3.6944 7.3167 -10.0669 -1.9056 5.7889 -1.9056 5.7889 7.3167 -10.0669 2.2111 -3.6944 -31.5331 12.6833 T is NOT sym. -1.9056 5.7889 Row-major indexing: remove redundancy Define active variable uij ui u i ,1 , ui ,2 , [1] u ri , j for 1 i Nr 1 and 1 j N , ui ,m , ui ,m1, ui ,m2 , T , ui , N total number of active variables is k N 2 6 12 NOT Nr 1 N 4 6 24 u1 r 1 r0 r1 Index order r0 r2 2 3 4 7 8 9 10 11 12 1 r3 r4 5 6 redundant 1 rNr r5 0 1 2 3 4 5 6 0 N 2 Index order u2 u11 u12 u 13 1 u14 u15 u 16 4 u21 u22 u 23 7 2 3 5 6 8 9 u24 10 u25 11 u 26 12 Row-major indexing: remove redundancy [2] i Nr 2k 1 is odd, and ri cos : 0 i Nr N r suppose 0 j k , then rk j rk 1 j 0 since rk j k j cos Nr k j 1 k j Nr 2 k 1 cos cos rk 1 j N N r r N 2m is even, and 2 , j j : 1 j N N m Hence for 1 j m, j m j and m j mod 2 j rNr 1 r1 0 rk j rk 1 j 0 rk rk 1 0 1 rNr rNr 1 rk 1 j rk 1 0 rk rk j r1 r0 1 r Row-major indexing: remove redundancy From symmetry condition, we have u rk 1i , j u rk 1i , j [3] mod 2 u rk 1i , j u rk i , m j for 0 i k and 0 j m , symmetry condition implies u rk 1i , m j u rk i , j Therefore, we have two important relationships 1 uk 1, j uk ,m j u u k 2, j k 1, m j u u Nr 1, j 1,m j 1 1 u1,m j 1 u2,m j u k ,m j 2 uk 1,m j uk , j u u k 2, m j k 1, j u u Nr 1,m j 1, j 1 1 u1, j 1 u2, j u k, j Kronecker product [1] r Define active variable uij u ri , j for 1 i 2 and 1 j 3 1 r0 r1 r2 1 r3 1 2 3 4 5 6 u11 u12 u 13 1 u21 u2 u22 u 23 4 u1 0 0 1 2 3 2 3 5 6 Separation of variable: assume matrix A acts on r-dir and matrix B acts on dir r1 , j a 11 Au r2 , j a21 a12 u1, j a22 u2, j ri , 1 b11 b12 Bu ri ,2 b21 b22 r , b i 3 31 b32 is independent of j b13 ui ,1 b23 ui ,2 is independent of i b33 ui ,3 u1 6 R be row-major u2 Let X index of active variable Kronecker product [2] a11B a12 B 66 R a21B a22 B Kronecker product is defined by A B a11B a12 B u1 a11Bu1 a12 Bu2 A B X a B a B 22 u2 21 a21Bu1 a22 Bu2 Case 1: A I Bu1 I B X Bu2 ri , 1 b11 b12 Bu ri ,2 b21 b22 r , b i 3 31 b32 b13 ui ,1 b23 ui ,2 b33 ui ,3 Case 2: B I u11 u21 a u a 11 12 12 u22 u a11u1 a12u2 u13 23 A I X a u a u u21 21 1 22 2 u11 a u a u 21 12 22 22 u u 23 13 r1 , j a 11 Au r1 , j a21 a12 u1, j a22 u2, j Kronecker product [3] Case 3: permutation, if permute 2 3 r r 1 r0 r1 r2 1 r3 1 2 3 4 5 6 1 r0 r1 r2 1 r3 u X 1 u21 u2 u22 u 23 P 1,3, 2 2 3 4 5 6 0 0 1 3 2 0 0 1 2 3 u11 u12 u 13 1 u X 1 u2 u11 u13 P u1 u 12 u21 u23 P u2 u 22 I P X Pu 1 X P u2 Kronecker product [4] Case 4: A diag a1, a2 a1Bu1 A B X a2 Bu2 r1 , 1 b11 b12 a1 Bu r1 , 2 a1 b21 b22 b r , 1 3 31 b32 b13 u1,1 b23 u1,2 i 1 b33 u1,3 r2 , 1 b11 b12 a2 Bu r2 , 2 a2 b21 b22 b r , 31 b32 2 3 b13 u2,1 b23 u2,2 i 2 b33 u2,3 1 1 urr ur 2 u 2u r r 1 1 diag 2 , 2 , r1 r2 , 1 D2, N 2 rk Non-active variable active variable [1] 1 1 urr ur 2 u 2u , on r 1,1 and 0, 2 r r Nr 2k 1 is odd, and N 2m is even, then Active variable is i ri cos : 1 i k Nr , that is ri 0, 0 j 2 j j : 1 j N Total number is kN , NOT Nr 1 N 1 1 DN2 r u DNr ur 2 DN u 2u r r Note that differential matrix DNr is of dimension Nr 1 ,acts on u0, j u 1, j u N r 1, j u Nr , j y 2 Neglect due to B.C. 1 u r 1 0 3 6 4 5 x Non-active variable active variable [2] u1, j u 2, j u k, j However DN2 r and DNr act on uk 1, j u k 2, j u N r 1, j NOT active variable, how to deal with? From previous discussion, we have following relationships which can solve this problem uk 1, j uk ,m j u1,m j u u u k 2, j k 1, m j 2, m j k : 1:1 u u u k ,m j Nr 1, j 1,m j where k : 1:1 is a permutation matrix and uk 1,m j uk , j u1, j u u u k 2, m j k 1, j 2, j k : 1:1 u u u k, j Nr 1,m j 1, j Non-active variable active variable uij Recall u ri , j for 1 i Nr 1 and 1 j N Consider Chebyshev differential matrix Dr , Nr acts on u D r , Nr [3] and evaluate at j r0 r , Nr i u ri , j i row of Dr , Nr u , j We write in matrix notation D r , u ri , j di ,1 di ,2 r0 di , k di ,k 1 di ,k 2 Question: How about if we arrange equations on di , Nr 1 r , i j u1, j u 2, j u k, j r0 uk 1, j u k 2, j u N r 1, j r0 i when fixed j Non-active variable active variable r0 r1 , j d12 d11 r2 , j d 22 d 21 r , d k ,2 k j d k ,1 DNr u rk 1 , j d k 1,1 d k 1,2 d rk 2 , j k 2,1 d k 2,2 r , d Nr 1,1 d Nr 1,2 Nr 1 j E1 E2 abbreviate DN r E3 E4 [4] u r , j r0 d1,k d1,k 1 d1,k 2 d 2,k d 2,k 1 d 2,k 2 d k ,k d k ,k 1 d k ,k 2 d k 1,k d k 1,k 1 d k 1,k 2 d Nr 1,k d Nr 1,k 1 d1, Nr 1 d 2, Nr 1 r 0 d k , N r 1 d k 1, Nr 1 r0 d Nr 1, Nr 1 We only keep operations on active variable u r 0, That is, only consider equation Later on, we use the same symbol DNr E1 D u r , Nr E2 i j for ri 0 u1, j u 2, j u k, j uk 1, j u k 2, j u N r 1, j uk , m j u k 1, m j u 1,m j Non-active variable active variable [5] I k 1 Define permutation matrix P 1: k , N r 1: 1: k 1 k 1 u1, j u1, j u u 2, j 2, j P u r , j u u k, j k, j Let u r , j u1,m j uk 1, j u u 2,m j k 2, j Active variable with the same indexing in r-direction uk ,m j u N r 1, j uk , m j u k 1,m j u 1,m j Non-active variable active variable [6] Moreover, we modify differential matrix according to permutation P by DNr u r , j DNr PT Pu r, j r0 r0 d11 d12 d 21 d22 T DNr P d k ,1 d k ,2 where d1,k d1, Nr 1 d1,k 2 d2,k d2, Nr 1 d2,k 2 d k ,k dk , Nr 1 d k ,k 2 d1,k 1 d2,k 1 E1 dk ,k 1 E2 such that for 1 j m u1, j u1,m j u u 2, j 2, m j Dr , Nr u r , j E1 E2 u u k, j k ,m j Evaluated at and u1,m j u1, j u u 2, m j 2, j Dr , Nr u r , m j E1 E2 u u k ,m j k, j r , , r , , , r , 1 j 2 j k j Non-active variable active variable D r , Nr D r , Nr u u u1,1 u1,2 u2,1 u2,2 , r , m E1 uk ,1 uk ,2 r , , r , , 1 2 m 1 u1,m u1,m 1 u1,m 2 u2, m u2, m 1 u2, m 2 E2 uk ,m uk ,m 1 uk ,m 2 u1,m 1 u1,m 2 u2,m 1 u2,m 2 , r , 2 m E1 uk ,m 1 uk ,m 2 r , , r , , m2 u1,2 m u1,1 u1,2 u2,2 m u2,1 u2,2 E2 uk ,2 m uk ,1 uk ,2 ui ,1 ui ,m 1 u u define U i ,2 , V i , m 2 and active variable X X 1 i i u u i ,m i ,2 m To sum up D r , Nr u r , , , r , E X 1 2m [7] 1 1 u1,2 m u2,2 m uk ,2 m u1, m u2, m uk ,m U1T V1T T T U V X 2 , X1 2 , X 2 2 T T U k Vk | X 2 E2 X 2 | X1 Non-active variable active variable [8] Note that under row-major indexing, memory storage of X X 1 is mem X U1T | V1T | U 2T | V2T | but mem X 2 | X1 V1T | U1T | V2T | U 2T | | U Tj | V jT | | U kT | VkT | V jT | U Tj | T | VkT | U kT D r , Nr u r , , 1 E 2 Im Im V1T V2T T Vk T If we adopt Kronecker products, then mem X 2 | X 1 I k Im Im , r , 2 m E1 U1T T U X2 2 T U k I m mem X I m mem X a11 B a12 B a12 B a22 B Definition: Kronecker product is defined by A B am1 B am 2 B a1n B a2 n B amn B Non-active variable active variable [9] The same reason holds for second derivative operator 2 r , Nr D D1 D3 then D2 D4 neglect equation on r0 Dr2, Nr u Dr2, Nr D1 D2 r , , , r, D 1 2m 1 1 1 T D u r , i row of matrix D P r , N i j r , N r r r ri Im 1 R E we have 1 r r where E 2 Im Im 1/ r1 1/ r2 R D 2 Im Im Im Dr2, Nr PT D1 D2 I m mem X collect equations on each ri :1 i k I m diag 1 , 1 , r1 r2 1/ rk 1 , rk Non-active variable active variable [10] We write second derivative operator on direction as D2,N S N 2 xk x j for 1 i k, 1 j 2m 1 2 j 0 mod N 2 6 3h where S N 2 x j j 1 , j 0 mod N 2sin 2 jh / 2 ri 0 D2, N u ri , j j row of D2, N so D2, N u ri , D2, N ui ,1 u i ,2 u i ,2 m ui ,1 u i ,2 D2 , N u i ,2 m j row of 2 D , N Ui Vi 1 2 Ui 1 2 D u r , D , N implies r 2 , N i 2 r i Vi Ui Vi Non-active variable active variable 1 2 U1 1 2 2 D , N 2 D , N V1 r1 r1 r1 , 1 2 U 2 D , N 1 2 r2 , 2 D u r V2 2 , N 2 r rk , 1 2 U k 2 D , N r Vk k 1 2 D , N r22 1 2 D , N rk2 If we adopt Kronecker products, then r1 , 1 2 r2 , R 2 D2, N mem X 2 D , N u r rk , [11] U1 V1 U 2 V2 U k Vk Non-active variable active variable [12] summary D 2 Im Im D 2 1 1 Dr , Nr u r ,1 , r r r 3 r1 , r , 1 2 2 R 2 D 2 mem X , N 2 D , N u r r , k u r , , Im , r , 2 m D1 1 2 r , Nr 1 Note that r , r , 1 2 Im , r , 2 m R E1 I m mem X E 2 Im Im I m mem X r1 , r1 ,1 r , r2 ,1 2 r , 2 m r , k rk ,1 r1 ,2 r2 ,2 rk ,2 so that all three system of equations are of the same order. r1 ,2 m r2 ,2 m r , k 2m Non-active variable active variable [13] 1 1 urr ur 2 u 2u , on r 1,1 and 0, 2 r r Discretization on mem X L mem X 2mem X then I L D1 m D 2 Im Im R 2 D2, N I D1 RE1 m where I m Im R E 1 D RE 2 2 Im Im 1/ r1 1/ r2 R E 2 Im Im Im 2 2 R D , N diag 1 , 1 , r1 r2 1/ rk , 1 rk I m Example: program 28 u 2u with boundary condition u r 1, 0 Nr 25 is odd and N 20 is even, let eigen-pair be Im sparse structure of L D1 RE1 k ,Vk D RE 2 2 Im Im Im 2 2 R D , N Nr 1 N 12 20 240 Dimension : 2 Example: program 28 (mash plot of eigenvector) 1 Eigenvalue is sorted, monotone increasing and normalized to first eigenvalue 1 2 n Vk 2 Eigenvector is normalized by supremum norm, Vk V k 1 5.7832 2 3 14.682 4 5 26.3746 6 30.4713 7 8 40.7065 9 10 42.2185 Example: program 28 (nodal set) Exercise 1 u 2u on annulus 1 r 2 Nr 25 is odd and N 20 with boundary condition u r 1, 2 0 is even, let eigen-pair be r 1 Chebyshev node on x1,1 k ,Vk x 1 2 Chebyshev node on L Dr2, Nr RDr , Nr I N R 2 D2, N 1 r 2 Exercise 1 (mash plot of eigenvector) 1 Eigenvalue is sorted, monotone increasing and normalized to first eigenvalue 1 2 n Vk V 2 Eigenvector is normalized by supremum norm, k Vk