Numer Algor (2006) 42: 137–164 DOI 10.1007/s11075-006-9034-6
Efficient spectral-Galerkin algorithms for direct solution for second-order differential equations using Jacobi polynomials E. H. Doha · A. H. Bhrawy
Received: 8 May 2005 / Accepted: 10 April 2006 / Published online: 17 August 2006 © Springer Science+Business Media B.V. 2006
Abstract It is well known that spectral methods (tau, Galerkin, collocation) have a condition number of O(N 4 ) (N is the number of retained modes of polynomial approximations). This paper presents some efficient spectral algorithms, which have a condition number of O(N 2 ), based on the Jacobi–Galerkin methods of secondorder elliptic equations in one and two space variables. The key to the efficiency of these algorithms is to construct appropriate base functions, which lead to systems with specially structured matrices that can be efficiently inverted. The complexities of the algorithms are a small multiple of N d+1 operations for a d-dimensional domain with (N − 1)d unknowns, while the convergence rates of the algorithms are exponentials with smooth solutions. Keywords Spectral-Galerkin method · Jacobi polynomials · Poisson and Helmholtz equations AMS subject classifications 65N35 · 65N22 · 65F05 · 35J05
1. Introduction The problem of approximating solutions of differential equations by spectral methods, known as Galerkin approximations, involves the projection onto the span of some appropriate set of basis functions. The member of the basis may satisfy automatically the auxiliary conditions imposed on the problem, such as initial, boundary
E. H. Doha (B) Department of Mathematics, Faculty of Science, Cairo University, Giza, Egypt e-mail:
[email protected] A. H. Bhrawy Department of Mathematics, Faculty of Science, Beni-Suef University, Beni-Suef, Egypt e-mail:
[email protected]
138
Numer Algor (2006) 42: 137–164
or more general conditions. Alternatively, these conditions may be imposed as constraints on the expansions coefficients, as in the Lanczos tau-method [23]. It is of fundamental importance to know that the choice of the basis functions is responsible for the superior approximation properties of spectral methods when compared with the finite difference and finite element methods. The choice of different basis functions lead to different spectral approximations; for instance, trigonometric polynomials for periodic problems, Chebyshev, Legendre, ultraspherical and Jacobi polynomials for non-periodic problems, Laguerre polynomials for problems on half line, and Hermite polynomials for problems on the whole line. Spectral methods provide a computational approach which has achieved substantial popularity over the last four decades. They have gained new popularity in automatic computations for a wide class of physical problems in fluid and heat flow. The principal advantage of spectral methods lies in their ability to achieve accurate results with substantially fewer degrees of freedom. This paper aims to develop some efficient spectral algorithms based on the Jacobi–Galerkin methods (JGM) for elliptic second-order differential equations in one and two space variables. Spectral methods (see, for instance [6, 8, 11–13, 18, 29]) involve representing the solution to a problem in terms of truncated series of smooth global functions. They give very accurate approximations for a smooth solution with relatively few degrees of freedom. For Dirichlet problems, Heinrichs [20] uses the Chebyshev polynomials as basis functions. It turns out that for the well-known standard spectral methods (tau, Galerkin, collocation) the condition number is very large and grows as O(N 4 ) (N is the number of retained modes of approximation; see [25]). Some new approaches have been adopted in the solution of the Dirichlet problem for Poisson and Helmholtz operators over rectangular in the two-dimensions [1, 3, 9, 17, 27, 28] and in the three dimensions [2]. Heinrichs [21] proposes a spectral method based on a subclass of orthogonal ultraspherical polynomials (α = 32 ) for solving the Helmholtz equation in two-dimensions subject to Dirichlet homogeneous boundary conditions with a symmetric and sparse matrix, whose condition number grows only as O(N 2 ); and he shows in [22] that certain algebraic spectral multigrid methods can be efficiently used for solving the resulting system. Doha and Abd-Elhameed [17] use ultraspherical-Galerkin approximations to develop a generalization of [20] and [27, 28]. Ben-Yu [4] used the Jacobi polynomials Pn(1,0) (x) to fit the solution of the reformed Burgers equation. Unfortunately, this method is available only when the genuine solution tends to zero as y → ∞, whereas, in many practical cases, the solutions may not tend to zero as y → ∞, and in [5] he used the Jacobi polynomials Pn(2,0) (x) for numerical solutions of differential equations on half line, with rough asymptotic behaviors at infinity. (α,β) The Jacobi polynomials Pn (x) play an important role in mathematical analysis and its applications, see [30]. It is proven that the Jacobi polynomials are precisely the only polynomials arising as eigenfunctions of a singular Sturm–Liouville problem, (cf. [8], Section 9.2). This class of polynomials comprises all the polynomial solution to singular Sturm-Liouville problems on [−1, 1]. Chebyshev, Legendre and ultraspherical polynomials are particular cases of the Jacobi polynomials. These polynomials have been used in both the solution of boundary value problems [18] and in computational fluid dynamics [8]. In most of these applications use is made of formulae relating the expansion coefficients of derivatives appearing in the differential equation to those of the function itself. This process results in an algebraic
Numer Algor (2006) 42: 137–164
139
system or a system of differential equations for the expansion coefficients of the solution which then must be solved. In this paper we are concerned with the direct solution techniques for secondorder elliptic equations, using the Jacobi–Galerkin approximations. We present two appropriate bases for the JGM applied to the Helmholtz elliptic equations with various boundary conditions. This leads to discrete systems with specially structured matrices that can be efficiently inverted. We note that the improved techniques of Heinrichs [20], the two efficient Legendre–Galerkin and Chebyshev–Galerkin approximations developed by Shen [27, 28], respectively, the ultraspherical-Galerkin approximations developed by Doha and Abd-Elhameed [17], and some other very interesting cases, can be obtained directly as special cases from our proposed Jacobi–Galerkin approximations. The remainder of this paper is organized as follows. In Section 2 we give some properties of Jacobi polynomials, and in Section 3 we discuss two algorithms for solving the Helmholtz equations in one- and two-dimensions. In Section 4 we consider the general second-order elliptic differential equations with various boundary conditions. In Section 5 we present some numerical results. Finally, some concluding remarks are given in Section 6.
2. Some properties of Jacobi polynomials The Jacobi polynomials associated with the real parameters (α > −1, β > −1) (see (α,β) [30] and [24]), are a sequence of polynomials Pn (x)(n = 0, 1, 2, ...), each, respectively, of degree n, satisfying the orthogonality relation ( Z 1 0, m 6 = n, α β (α,β) (α,β) (1 − x) (1 + x) Pm (x)Pn (x) dx = (2.1) hn , m = n, −1 where hn =
2α+β+1 0(n + α + 1)0(n + β + 1) . (2n + α + β + 1)n! 0(n + α + β + 1)
These polynomials are eigenfunctions of the following singular Sturm–Liouville equation: (1 − x2 ) φ 00 (x) + [ β − α − (α + β + 2) x] φ 0 (x) + n(n + α + β + 1) φ(x) = 0. A consequence of this is that spectral accuracy can be achieved for expansions in Jacobi polynomials. For our present purposes it is convenient to standardize the Jacobi polynomials so that Pn(α,β) (1) =
0(n + α + 1) , n!0(α + 1)
Pn(α,β) (−1) =
(−1)n 0(n + β + 1) . n!0(β + 1)
In this form the polynomials may be generated using the standard recurrence (α,β) (α,β) relation of Jacobi polynomials starting from P0 (x) = 1 and P1 (x) = 12 [α − β + (λ + 1)x], or obtained from Rodrigue’s formula (−1)n Pn(α,β) (x) = n (1 − x)−α (1 + x)−β D n (1 − x)α+n (1 + x)β+n , 2 n!
140
Numer Algor (2006) 42: 137–164
where λ = α + β + 1,
D≡
d . dx
The ultraspherical polynomials are Jacobi polynomials with α = β and are thus a subclass of the Jacobi polynomials. It is convenient to weigh the ultraspherical polynomials so that n! 0 α + 12 (α− 1 ,α− 1 ) Pn 2 2 (x), Cn(α) (x) = (2.2) 1 0 n+α+ 2 which gives Cn(α) (1) = 1, (n = 0, 1, 2, · · · ); this is not the usual standardization, but has (1)
the desirable properties that Cn(0) (x) = Tn (x), Cn2 (x) = L n (x), and Cn(1) (x) = (1/(n + 1))U n (x), where Tn (x), U n (x) and L n (x) are Chebyshev polynomials of the first and second kinds and Legendre polynomials, respectively. The special values q−1 Y 0(n + α + 1) (n + λ + i), q 2 (n − q)! 0(q + α + 1) i=0
D q Pn(α,β) (1) =
D q Pn(α,β) (−1) = (−1)n+q D q Pn(β,α) (1),
(2.3)
will be of important use later. Let f (x) be an infinitely differentiable function defined on [−1, 1], then we can write f (x) =
∞ X
an Pn(α,β) (x),
(2.4)
n=0
and for the qth derivative of f (x), f (q) (x) =
∞ X
(α,β) a(q) (x), n Pn
a(0) n = an .
(2.5)
n=0
Now −q a(q) n =2
∞ X (n + i + q + λ − 1)q Cn+i,n (α + q, β + q, α, β) an+i+q
∀ n ≥ 0, q ≥ 1,
i=0
(2.6) where Cn+i,n (α + q, β + q, α, β) =
(n + i + 2q + λ − 1)n (n + α + q + 1)i 0(n + λ) i!0(2n + λ) −i, 2n + i + 2q + λ, n + α + 1 ×3 F2 ;1 , n + q + α + 1, 2n + λ + 1
and D q Pn(α,β) (x) = 2−q (n + λ)q
n−q X i=0
(α,β)
Cn−q,i (α + q, β + q, α, β) Pi
(x),
(2.7)
Numer Algor (2006) 42: 137–164
141
where Cn−q,i (α + q, β + q, α, β) =
(n + q + λ)i (i + q + α + 1)n−i−q 0(i + λ) (n − i − q)!0(2i + λ) −n + q + i, n + i + q + λ, i + α + 1 ;1, ×3 F2 i + q + α + 1, 2i + λ + 1
with (a)k = 0(a + k)/ 0(a).(For the proof, see [15].) Another interesting formula is (α,β)
xm P j
(x) =
2m X
(α,β)
am n ( j) P j+m−n (x) ∀ m, j ≥ 0,
(2.8)
n=0 (α,β)
with P−r (x) = 0, r ≥ 1, where am n ( j) =
(−1)n 2 j+m−n m!(2 j + 2m − 2n + λ)0( j + m − n + λ)0( j + α + 1)0( j + β + 1) 0( j + m − n + α + 1)0( j + m − n + β + 1)0( j + λ) min( j+m−n, j) X 0( j + k + λ) j+m−n × k k 2 (n + k − j)!0(3 j + 2m − 2n − k + λ + 1) k=max(0, j−n)
×
j−k X (−1)` 0(2 j + m − n − k − ` + α + 1) 0( j + m + ` − n + β + 1)
`!( j − k − `)!0( j − ` + α + 1) 0(k + ` + β + 1)
`=0
× 2 F1 ( j − k − n, j + m + ` − n + β + 1; 3 j + 2m − 2n − k + λ + 1; 2). (For the proof, see [16], and for the general definition of a generalized hypergeometric series j Fi , see [24]). For the ultraspherical coefficients of the moments of a general-order derivative of an infinitely differentiable function, see [14]. The following lemma will be of fundamental importance in what follows. Lemma 2.1. If we write DPn(α,β) (x) =
n−1 X
(α,β)
C1 (n, i, α, β)Pi
(x),
(2.9)
i=0
and D 2 Pn(α,β) (x) =
n−2 X
(α,β)
C2 (n, i, α, β)Pi
(x),
(2.10)
i=0
then C1 (n, i, α, β) =
(n + λ)(n + λ + 1)i (i + α + 2)n−i−1 0(i + λ) 2(n − i − 1)! 0(2i + λ) −n + i + 1, n + i + λ + 1, i + α + 1 ;1, × 3 F2 i + α + 2, 2i + λ + 1
(2.11)
142
Numer Algor (2006) 42: 137–164
and C2 (n, i, α, β) =
(n + λ)2 (n + λ + 2)i (i + α + 3)n−i−2 0(i + λ) 4(n − i − 2)! 0(2i + λ) −n + i + 2, n + i + λ + 2, i + α + 1 ;1. × 3 F2 i + α + 3, 2i + λ + 1
(2.12)
Proof. Immediately, if we set q = 1 in relation (2.7), we obtain n−1
DPn(α,β) (x) =
(n + λ) X (α,β) Cn−1,i (α + 1, β + 1, α, β)Pi (x), 2 i=0
finally, if we write DPn(α,β) (x) =
n−1 X
(α,β)
C1 (n, i, α, β)Pi
(x),
i=0
then C1 (n, i, α, β) = 2−1 (n + λ) Cn−1,i (α + 1, β + 1, α, β), and hence we have relation (2.11). Similarly, by setting q = 2 in relation (2.7), we get D 2 Pn(α,β) (x) = 2−2 (n + λ)2
n−2 X
(α,β)
Cn−2,i (α + 2, β + 2, α, β)Pi
(x),
i=0
and hence we have relations (2.10) and (2.12). Remark 2.2. In general, the 3 F2 in Lemma 2.1 cannot be summed in explicit form, but it can be summed by Watson’s identity [31], if α = β.
3. Helmholtz equations We are interested in using the JGM to solve the Helmholtz equation β1 u − 1u = f (x)
in = I d ,
u|∂ = 0,
(3.1)
where I = (−1, 1) and d = 1, 2. Let us first introduce some basic notation that will be used in the upcoming sections. We set n o (α,β) (α,β) (α,β) S N = span P0 (x), P1 (x), ..., P N (x) , V N = {ν ∈ S N : ν(±1) = 0}; d then the standard Jacobi–Galerkin approximation to (3.1) is to find u N ∈ V N such that d β1 (u N , ν)w − (1u N , ν)w = ( f, ν)w ∀ν ∈ V N , (3.2) R Qd where ω(x) = i=1 (1 − xi )α (1 + xi )β and (u, ν)w = uνω dx is the scaler product in 2 2 the weighted space Lω (). The norm in Lω () will be denoted by k . kω .
Numer Algor (2006) 42: 137–164
143
Let us denote Hωs () as the weighted Sobolev spaces with the norm k ν ks,ω . It is well known (see [8]) that for β1 ≥ 0, s ≥ 1, and u ∈ Hωs (), the following optimal error estimate holds: k u − u N kω +N k u − u N k1,ω ≤ C(s)N −s k u ks,ω .
(3.3)
Although approximation (3.2) achieves the optimal convergence rate, its practical d value depends on the choice of a basis for V N . It is essential for the sake of efficiency d to choose an appropriate basis for V N such that the resulting linear system is as simple as possible. However, to the best of our knowledge the only Chebyshev, Legendre and ultraspherical bases available in the literature are (1) V N = span{φ2 (x), φ3 (x), ..., φ N (x)} with φk (x) =
Tk (x) − T0 (x), Tk (x) − T1 (x),
k even, , k odd,
or φk (x) = (1 − x2 )Tk−2 (x),
φk (x) =
Lk (x) − L 0 (x), Lk (x) − L1 (x),
k even, k odd,
or φk (x) = (1 − x2 )Lk−2 (x),
(
Ck(α) (x) − C0(α) (x), Ck(α) (x) − C1(α) (x),
and φk (x) =
k even, k odd,
(α) or φk (x) = (1 − x2 )Ck−2 (x);
see [8, 17, 18, 20]. Unfortunately, all of these bases lead to linear systems with full matrices even in the simplest case β1 = 0. (2) V N = span {φ0 (x), φ1 (x), ..., φ N−2 (x)} with φk (x) = Tk (x) − Tk+2 (x) φk (x) = Lk (x) − Lk+2 (x) and (α) φk (x) = Ck(α) (x) − Ck+2 (x);
see [17, 27, 28] and [1–3]. These bases lead to discrete systems with either special matrices that can be efficiently inverted or sparse matrices for variational formulations. 3.1. One-dimensional Helmholtz equation It is of fundamental importance to note here that the crucial task in applying the Galerkin-spectral approximations is how to choose an appropriate basis for V N such that the linear systems resulting from (3.2) are as simple as possible. In this section, we consider two kinds of bases to numerically solve the onedimensional Helmholtz equation β1 u − u00 = f (x)
in I = (−1, 1),
u(±1) = 0.
(3.4)
144
Numer Algor (2006) 42: 137–164
(1) The first choice of basis. We choose the basis functions of expansion (α,β)
φk (x) = ξk (1 − x2 )Pk
(x),
k! 0(α + 1) , 0(k + α + 1)
ξk =
k = 0, 1, ..., N − 2,
(3.5)
which fulfills the boundary conditions of (3.4). Set m = 2 in relation (2.8) to get (α,β)
x2 Pk
(x) =
4 X
(α,β)
a2i (k) Pk−i+2 (x),
i=0
or (α,β)
ξk x2 Pk
(α,β)
(x) = ξk Pk
(x) −
4 X
(α,β)
e j+1 (k, α, β)Pk+ j−2 (x),
j=0
and hence we have (α,β)
ξk (1 − x2 )Pk
(x) =
4 X
(α,β)
e j+1 (k, α, β) Pk+ j−2 (x),
(3.6)
j=0
where e1 (k, α, β) =
−4(k + α − 1)2 (k + β − 1)2 k! 0(α + 1) , (2k + λ − 3)4 0(k + α + 1)
e2 (k, α, β) =
4(k + α)(k + β)(α + β)(α − β)k! 0(α + 1) , (2k + λ − 3)(2k + λ − 1)3 0(k + α + 1)
e3 (k, α, β) =
4k! 0(α + 1) (2k + λ − 2)2 (2k + λ + 1)2 0(k + α + 1) h × 2k 4 + 4k 3 λ + k 2 (4α 2 + 6α(β + 1) i +2β(2β + 3)) + 2kλ(α 2 + β 2 + αβ + λ − 2) + (α + 1)(β + 1)(λ − 2)2 ,
e4 (k, α, β) =
4(k + 1)(k + λ)(α + β)(α − β)k! 0(α + 1) , (2k + λ − 1)3 (2k + λ + 3)0(k + α + 1)
e5 (k, α, β) =
−4(k + 1)2 (k + λ)2 k! 0(α + 1) . (2k + λ)4 0(k + α + 1)
(3.7)
Lemma 3.1. We have, for arbitrary constants ak , N−2 X
(α,β)
ak ξk (1 − x2 )Pk
(x) =
N X
(α,β)
(x),
(3.8)
ei+1 (k − i + 2, α, β) ak−i+2 .
(3.9)
k=0
b k Pk
k=0
where bk =
4 X i=0
Moreover, if D2
h N−2 X k=0
(α,β)
ak ξk (1 − x2 )Pk
i N−2 X (α,β) (x) = ck Pk (x), k=0
(3.10)
Numer Algor (2006) 42: 137–164
145
then ck =
N X 4 X
C2 (i, k, α, β) e j+1 (i − j + 2, α, β) ai− j+2 ,
(3.11)
i=k+2 j=0
where C2 ( j, k, α, β) and e j(k, α, β) are as defined in (2.12) and (3.7), respectively. Proof. If we write N−2 X
(α,β)
ak ξk (1 − x2 )Pk
(x) =
k=0
N X
(α,β)
b k Pk
(x),
k=0
then it is not difficult to show, by using (3.6), that bk =
4 X
ei+1 (k − i + 2, α, β) ak−i+2 ,
i=0
where ak = 0 for k = −2, −1, N − 1, N, N + 1, N + 2. Since D2
h N−2 X
(α,β)
ak ξk (1 − x2 )Pk
N i X (α,β) (x) = b k D2 Pk (x),
k=0
k=0
then making use of Lemma 2.1 (formula 2.10) immediately yields D2
h N−2 X
(α,β)
ak ξk (1 − x2 )Pk
N k−2 i X X (α,β) (x) = bk C2 (k, i, α, β)Pi (x),
k=0
k=0
i=0
which may be written in the form D2
h N−2 X
(α,β)
ak ξk (1 − x2 )Pk
N i N−2 X X (α,β) (x) = b i C2 (i, k, α, β)Pk (x).
k=0
k=0 i=k+2
Finally, if we write D2
h N−2 X
(α,β)
ak ξk (1 − x2 )Pk
i N−2 X (α,β) (x) = ck Pk (x),
k=0
k=0
then it can be easily shown, by using (3.9), that ck =
N X 4 X
C2 (i, k, α, β)e j+1 (i − j + 2, α, β) ai− j+2 ,
i=k+2 j=0
and this completes the proof of Lemma 3.1. P N−2 (α,β) Theorem 3.2. If u N (x) = k=0 ak ξk (1 − x2 )Pk (x) is the Galerkin approximation to (3.4), then the expansion coefficients {ak , k = 0, 1, ..., N − 2} satisfy the matrix system (β1 B + C)a = f ∗ ,
(3.12)
146
Numer Algor (2006) 42: 137–164
where the nonzero elements of matrices B and C are given by ckk = (k + 1)(k + 2),
ckj = −
4 X
ei+1 ( j, α, β)C2 ( j + i − 2, k, α, β)/ξk ,
i=0
j = k + `, ` ≥ 1, b k,k−2 = e5 (k − 2, α, β)/ξk , b k,k−1 = e4 (k − 1, α, β)/ξk , b kk = e3 (k, α, β)/ξk , b k,k+1 = e2 (k + 1, α, β)/ξk , b k,k+2 = e1 (k + 2, α, β)/ξk , and a = a0 , a1 , ..., a N−2
T
∗ , f ∗ = f0∗ , f1∗ , ..., f N−2
T
, fk∗ =
1 (α,β) f, Pk (x) . w ξk hk
Proof. The application of Galerkin method to (3.4) gives β1 u N (x) − u00N (x), φk (x) = f (x), φk (x) . w
(3.13)
w
where φk (x) is given by (3.5). Substitution of formulae (3.8) and (3.10) into (3.13) yields X N N−2 X (α,β) (α,β) (α,β) β1 b j P j (x) − c j P j (x), ξk (1 − x2 )Pk (x) j=0
=
w
j=0
(α,β) f (x), ξk (1 − x2 )Pk (x) .
(3.14)
w
and if we substitute (3.6) into (3.14) and make use of the orthogonality relation (2.1), then we get β1 [e1 (k, α, β)b k−2 hk−2 + e2 (k, α, β)b k−1 hk−1 + e3 (k, α, β)b k hk + e4 (k, α, β)b k+1 hk+1 +e5 (k, α, β)b k+2 hk+2 ] − [e1 (k, α, β)ck−2 hk−2 + e2 (k, α, β)ck−1 hk−1 + e3 (k, α, β)ck hk +e4 (k, α, β)ck+1 hk+1 + e5 (k, α, β)ck+2 hk+2 ] = e1 (k, α, β) fk−2 + e2 (k, α, β) fk−1 +e3 (k, α, β) fk + e4 (k, α, β) fk+1 + e5 (k, α, β) fk+2 ,
k = 0, 1, ..., N − 2.
(3.15)
or β1
4 X
ei+1 (k, α, β)b k+i−2 hk+i−2 −
i=0
=
4 X
4 X
ei+1 (k, α, β)ck+i−2 hk+i−2
i=0
ei+1 (k, α, β) fk+i−2 .
i=0
Now, it is not difficult to show that (3.15) holds for fk = (β1 b k − ck )hk ;
(α,β)
fk = ( f, Pk
(x)),
k = 0, 1, ..., N − 2;
(3.16) this means that, instead of solving (3.15), we can solve the neater system (3.16), which is equivalent to (3.13). This linear system may be put in the form (β1 b k /ξk − ck /ξk ) = fk∗ ,
k = 0, 1, ..., N − 2,
(3.17)
Numer Algor (2006) 42: 137–164
147
which in turn may be written in the matrix form (β1 B + C)a = f ∗ ,
(3.18)
and this completes the proof of Theorem 3.2. Corollary 3.3. If α = β = 1 then the nonzero elements of B and C in system (3.18) are given by ckk = (k + 1)(k + 2), b kk =
2(k + 1)(k + 2) , (2k + 1)(2k + 5)
b k,k−2 = −
(k + 1)(k + 2) , (2k − 1)(2k + 1)
b k,k+2 = −
(k + 1)(k + 2) . (2k + 5)(2k + 7)
In particular, the most important case is for β1 = 0, α = β = 1. In this case system (3.18) becomes diagonal, and Z 1 2k + 3 ak = fk , k = 0, 1, ..., N − 2, fk = (1 − x2 ) f (x) Pk(1,1) (x) dx. 8(k + 1) −1 Moreover, for β1 6 = 0, α = β = 1, system (3.18) is a pentadiagonal system. Corollary 3.4. If α = β, and each is replaced by (α − 12 ), then the nonzero elements of B and C in system (3.18) are given by ckk = (k + 1)2 , b kk =
ckj =
2(3 − 2α)(k + α)0(k + 2α) j! , k! 0( j + 2α)
j = k + 2n, n ≥ 1,
k2 + 2kα + (α − 1)(2α + 1) (k + 1)2 (k + 2α − 2)2 , b k,k+2 = − , b k,k−2 = − . 2(k + α − 1)(k + α + 1) 4(k+α + 1)2 4(k + α − 2)2
This result is in complete agreement with that obtained in ([17], p. 557). In particular, the special cases for the Chebyshev polynomials of the first and second kinds and for the Legendre polynomial may be obtained directly by taking α = 0, 1, 12 , respectively. These results have been noted and given explicitly in [17] as well. In particular, if β1 = 0, α, β ∈ (−1, ∞), then the system in this case is C a = f ∗ , where matrix C is a special upper triangular matrix. Remark 3.5. If β1 6 = 0, and α, β ∈ (−1, ∞), then the system (3.18) can be solved by LU factorization. (2) The second choice of basis. Here, we choose φk (x), to be of the form n o (α,β) (α,β) (α,β) φk (x) = ξk Pk (x) + dk Pk+1 (x) + ek Pk+2 (x) ,
(3.19)
where dk and ek are the unique constants such that φk (±1) = 0, k = 0, 1, ..., N − 2. Therefore (α,β)
φk (x) = ξk Pk −
(x) +
(k + 1)(α − β)(2k + λ + 2) (α,β) P (x) (k + α + 1)(k + β + 1)(2k + λ + 3) k+1
(k + 1)(k + 2)(2k + λ + 1) (α,β) P (x) . (k + α + 1)(k + β + 1)(2k + λ + 3) k+2
(3.20)
148
Numer Algor (2006) 42: 137–164
This choice may be considered as a generalization of the bases used in [17, 27, 28] and [1–3]. It is now clear that the variational formulation of (3.4) is equivalent to β1 (u N , φk (x))w − (u00N , φk (x))w = ( f (x), φk (x))w ,
k = 0, 1, ..., N − 2.
(3.21)
Let us denote fk = ( f, φk (x))w ,
f = ( f0 , f1 , ......, f N−2 )T ,
u N (x) =
N−2 P
an φn (x),
n=0
a = (a0 , a1 , ..., a N−2 )T ,
A = (akj)0≤k, j≤N−2 ,
B = (b kj)0≤k, j≤N−2 ;
then (3.21) is equivalent to the matrix equation (A + β1 B)a = f,
(3.22)
where the nonzero elements of matrices A and B are given explicitly in the following theorem. Theorem 3.6. If we take φk (x) as defined in (3.19), and if we denote akj = − φ 00j (x), φk (x) w and b kj = φ j(x), φk (x) w , then V N = span {φ0 (x), φ1 (x), ..., φ N−2 (x)} , and the nonzero elements (akj), (b kj), 0 ≤ k, j ≤ N − 2, are given by 2λ−2 (k + 1)2 (2k + λ + 1)2 (2k + λ + 2)(k + 2)! 0(k + β + 1)(0(α + 1))2 , (k + α + 1)3 (k + β + 1)0(k + α + 1)0(k + λ + 2) h akj = −ξk ξ j C2 ( j, k, α, β) + d j C2 ( j + 1, k, α, β) + e jC2 ( j + 2, k, α, β) hk
akk =
+ C2 ( j, k + 1, α, β) + d j C2 ( j + 1, k + 1, α, β) +e j C2 ( j + 2, k + 1, α, β) dk hk+1 + C2 ( j, k + 2, α, β) + d j C2 ( j + 1, k + 2, α, β) i +e j C2 ( j + 2, k + 2, α, β) ek hk+2 , b kk =
2λ (1 + k)(2k + λ + 1)2 (k + 1)! 0(1 + α)2 0(1 + k + β) (1 + k + α)3 (1 + k + β)(2k + λ)(2k + λ + 3)2 0(1 + k + α)0(k + λ + 2) h × 2k 4 + (λ)2 (2 + α)(2 + β) + 4k 3 (λ + 2) + k2 (26 + 4α 2 + 4β(5 + β) i +α(20 + 6β)) + 2k(λ + 2)(α 2 + (2 + β)2 + α(4 + β)) ,
b k,k+1 = b k+1,k =
2λ (k + 1)(α − β)(λ + 1)(k + 1)! 0(k + β + 1)(0(α + 1))2 , (k + α + 1)2 (2k + λ + 5)0(k + α + 1)0(k + λ + 2)
b k,k+2 = b k+2,k = −
2λ (k + 1)(k + β +2)(2k + λ + 1)(k + 2)! 0(k + β + 1)(0(α + 1))2 . (k + α + 1)2 (2k + λ + 3)2 0(k + α + 1)0(k + λ + 2)
Proof. The proof of this theorem is not difficult, but it is rather lengthy, and it can be accomplished by following the same procedure used in proving Theorem 3.2.
Numer Algor (2006) 42: 137–164
149
Remark 3.7. For k + j odd, α = β, akj = b kj = 0. Hence system (3.22) of order N − 1 can be decoupled into two separate systems of order N2 and ( N2 − 1), respectively. In this way one needs to solve two systems of order n instead of one of order 2n, which leads to substantial savings. Corollary 3.8. If α = β = 0, then the nonzero elements (akj), (b kj) for 0 ≤ k, j ≤ N − 2, are given as follows: akk = 2(2k + 3),
b kk =
4(2k + 3) , (2k + 1)(2k + 5)
b k+2,k = b k,k+2 =
−2 . (2k + 5)
This result is also in complete agreement with the known result [27]. If β1 = 0, α = β = 0, then system (3.22) is reduced to a diagonal system A a = f, whose diagonal elements are akk = 2(2k + 3). Corollary 3.9. If α = β, and each is replaced by (α − 12 ), then the nonzero elements (akj), (b kj) for 0 ≤ k, j ≤ N − 2, are given as follows: akk
22α+1 (k + α + 1)(k + 2)! 0 α + = 0(2α + k + 2)
1 2
2 ,
4(1 − 2α)(k + α + 1)( j + α + 1)0 12 0 α + 12 j! akj = , j = k + 2n, n ≥ 1, 0(α + 1)(2α + 1) j+1 2 4α (k + α + 1) k2 + 2(α + 1)k + 2α 2 + 3α k! 0 α + 12 b kk = , (k + α)(k + α + 2)0(k + 2α + 2) 2 22α−1 (k + 2)! 0 α + 12 b k+2,k = b k,k+2 = − . (k + α + 2)0(k + 2α + 2) This result is in complete agreement with the known result [17]. If α = 0, then the nonzero elements (akj), (b kj) for 0 ≤ k, j ≤ N − 2, are in complete agreement with the known result [28]. Remark 3.10. If β1 6 = 0,α, β ∈ (−1, ∞), we explicitly form the LU factorization A + β1 B = LU. Consequently, the system can be solved with essentially the same number of operations needed for solving a pentadiagonal system. 3.2. Two-dimensional Helmholtz equation In this case, the Helmholtz equation (3.1) with d = 2 reads β1 u(x, y) −
∂ 2u ∂ 2u + 2 ∂ x2 ∂y
= f (x, y) in = (−1, 1)2 , u|∂ = 0.
It is clear that if we take φk (x) as defined in (3.19), then V N2 = span φk (x)φ j(y) : k, j = 0, 1, ..., N − 2 .
(3.23)
150
Numer Algor (2006) 42: 137–164
Let us denote uN =
N−2 X
ukj φk (x)φ j(y),
fkj = f, φk (x)φ j(y)
w
,
k, j=0
U = (ukj)k, j=0,1,...,N−2 ,
F = ( fkj)k, j=0,1,...,N−2 ;
then applying the Galerkin method to (3.23) we obtain the matrix equation β1 BU B + AU B + BU AT = F,
(3.24)
where A and B are the matrices defined in Theorem 3.6. This equation can be solved by the matrix decomposition method described in [7] and [19]. Now, let D be the diagonal matrix whose diagonal elements are the eigenvalues of A−1 B, and let E be the matrix formed by the eigenvectors of A−1 B. Then A−1 BE = ED. Applying A−1 to (3.24), we obtain β1 A−1 BU B + U B + A−1 BU AT = A−1 F. Setting U = EV, the above equation becomes β1 EDV B + EV B + EDV AT = A−1 F. Now applying E−1 to the above equation and setting G = E−1 A−1 F, we find β1 DV B + V B + DV AT = G.
(3.25)
Let v p = (v p0 , v p1 , ..., v pN−2 )T , g p = (g p0 , g p1 , ..., g pN−2 )T f or p = 0, 1, ..., N−2. Then the p th row of (3.25) becomes (β1 d p + 1)B v p + d p Av p = g p ,
p = 0, 1, ..., N − 2,
(3.26)
which is equivalent to (N − 1) one-dimensional equations of the form (3.22). In summary, the solution of (3.24) consists of the following four steps: (1) (2) (3) (4)
Compute the eigenpairs D, E for A−1 B and compute E−1 . Compute G = E−1 A−1 F. Obtain V by solving (3.26). Set U = EV.
We have to remark at this stage that A−1 B can be decoupled into two submatrices of upper Hessenburg form onto which the QR transformation can be directly applied. Hence the roundoff errors of the preprocessing stage are significantly reduced compared to those of the Chebyshev-tau method (See, Section 5 below). Steps (3) and A−1 F takes O(N 2 ) operations. Note also that matrices E and E−1 have alternating zero elements, and hence Steps (2) and (4) can be performed in about N 3 arithmetic operations. It is worth mentioning here that the previous procedure can be applied to (3.23), but with φk (x) as defined in (3.5). In this case we get the matrix equation β1 BU B + CU B + BUC T = F,
(3.27)
where B and C are the matrices defined in Theorem 3.2. This system has the same method of solution as that of (3.25).
Numer Algor (2006) 42: 137–164
151
Remark 3.11. If α = β = 1, then matrix C in (3.18) becomes diagonal, and if α = β = 0, then matrix A in (3.22) becomes diagonal as well. This greatly simplifies the steps for obtaining the solutions to these two systems.
4. Extensions to more general problems in one-dimension The JGM can be applied to more general problems. In this section, we describe several extensions in one-dimension. 4.1. Mixed-type boundary conditions When other boundary conditions are prescribed, it is necessary to construct a basis incorporating the boundary conditions. Now consider the equation β1 u + β2 u0 − u00 = f (x) in
I = (−1, 1),
(4.1)
with the mixed homogeneous boundary conditions α1 u(1) + λ1 u0 (1) = 0,
α2 u(−1) + λ2 u0 (−1) = 0.
(4.2)
Let W N = ν ∈ S N : αi ν(±1) + λi ν 0 (±1) = 0, i = 1, 2 ; then the standard Jacobi–Galerkin approximation to (4.1) is to find u N ∈ W N such that β1 (u N , ν)w + β2 u0N , ν w − u00N , ν w = ( f (x), ν)w ∀ ν ∈ W N . (4.3) We can find an appropriate basis for W N by setting n o (α,β) (α,β) (α,β) φk (x) = ξk Pk (x) + ζk Pk+1 (x) + ηk Pk+2 (x) ,
(4.4)
where ζk and ηk are the unique constants such that φk (x) ∈ W N , k = 0, 1, ..., N − 2. Therefore W N = span {φ0 (x), φ1 (x), ..., φ N−2 (x)} , where h ζk = (k + 1)(2k + λ + 2) λ1 2(β + 1) −(k + 2)(α + 2)(k + α + 1) + (k)2 β + kβ 2 ×α2 + k(k + 2)(α − β)(k + λ + 2)λ2 + 2α1 (α + 1) × 2(β + 1)(β − α)α2 − (4 − k(α − 2)(k + α + 3) i +6β + k(k + 5)β + (k + 2)β 2 )λ2 /Den(k), (4.5) ηk = −(k + 1)2 (2k + λ + 1) λ1 − 2(β + 1) (1 + α + k(k + λ + 1)) α2 + (k)2 (k + λ)2 λ2 +2α1 (α + 1) − 2α2 (β + 1) + (1 + β + k(k + λ + 1)) λ2 /Den(k),
(4.6)
152
Numer Algor (2006) 42: 137–164
where h Den(k) = (k + α + 1)(k + β + 1)(2k + λ + 3) λ1 − 2(β + 1)(4 + 2α + β +k(k + λ + 3))α2 + (k + 1)2 (k + λ + 1)2 λ2 i +2α1 (α + 1) − 2α2 (β + 1) + (4 + α + 2β + k(k + λ + 3))λ2 , and u N (x) =
N−2 X
ak φk (x).
k=0
Now (4.3) is equivalent to the matrix equation A + β1 B + β2 C a = f,
(4.7)
where the nonzero elements of matrices A = (akj), B = (b kj), and C = (ckj), 0 ≤ k, j ≤ N − 2, are given explicitly in the following theorem. Theorem 4.1. If we take φk (x) as defined in (4.4), and if we denote akj = − φ 00j (x), φk (x) w b kj = φ j(x), φk (x) w , ckj = φ 0j(x), φk (x) w . Then the nonzero elements of the matrices A, B and C in system (4.7) are given as follows: h akj = −ξk ξ j C2 ( j, k, α, β) + ζ jC2 ( j + 1, k, α, β) + η jC2 ( j + 2, k, α, β) hk + C2 ( j, k + 1, α, β) + ζ jC2 ( j + 1, k + 1, α, β) +η jC2 ( j + 2, k + 1, α, β) ζk hk+1 + C2 ( j, k + 2, α, β) + ζ jC2 ( j + 1, k + 2, α, β) i +η jC2 ( j + 2, k + 2, α, β) ηk hk+2 , b kk = ξk2 (hk + ζk2 hk+1 + ηk2 hk+2 ), b k,k+1 = b k+1,k = ξk ξk+1 (ζk hk+1 + ηk ζk+1 hk+2 ), b k,k+2 = b k+2,k = ξk ξk+2 ηk hk+2 , h ckj = ξk ξ j C1 ( j, k, α, β) + ζ jC1 ( j + 1, k, α, β) + η jC1 ( j + 2, k, α, β) hk + C1 ( j, k + 1, α, β) + ζ jC1 ( j + 1, k + 1, α, β) +η jC1 ( j + 2, k + 1, α, β) ζk hk+1 + C1 ( j, k + 2, α, β) + ζ jC1 ( j + 1, k + 2, α, β) i +η jC1 ( j + 2, k + 2, α, β) ηk hk+2 . where C1 ( j, k, α, β), C2 ( j, k, α, β), ζk and ηk are given by (2.11), (2.12), (4.5), and (4.6), respectively, while hk is defined by (2.1). Proof. The proof of this theorem is rather lengthy but not difficult, and it can be accomplished by following the same procedures used in proving Theorem 3.2.
Numer Algor (2006) 42: 137–164
153
4.1.1. Dirichlet problem In the special case, where α1 = α2 = 1, λ1 = λ2 = 0 (i.e., the homogeneous Dirichlet boundary condition), we have, in particular, ζk = dk , ηk = ek , and accordingly the basis functions φk (x), k = 0, 1, ..., N − 2, take the form given in (3.19). It is of fundamental importance to note here that all the results of Theorem 3.6 can be obtained immediately as a special case from Theorem 4.1.
4.1.2. Neumann problem In this case, where α1 = α2 = 0, λ1 = λ2 = 1, we have
ζk =
k(α − β)(k + λ)(2k + λ + 2) , (k + α + 1)(k + β + 1)(k + λ + 1)(2k + λ + 3)
k(k + 1)(k + λ)(2k + λ + 1) , (k + α + 1)(k + β + 1)(k + λ + 2)(2k + λ + 3) n o (α,β) (α,β) (α,β) φk (x) = ξk Pk (x) + ζk Pk+1 (x) + ηk Pk+2 (x) . ηk = −
(4.8)
In summary, all the results of such a case are given in the following theorem and its corollaries. Theorem 4.2. Let φk (x) be defined as in (4.8); then the nonzero elements of matrices A, B and C in system (4.7) are given as follows: 2λ−2 k(k + λ)(2k + λ + 1)2 (2k + λ + 2)(k + 1)!0(k + β + 1)(0(α + 1))2 , (k + β + 1)0(k + α + 2)0(k + λ + 3) h akj = −ξk ξ j C2 ( j, k, α, β) + ζ jC2 ( j + 1, k, α, β) + η jC2 ( j + 2, k, α, β) hk
akk =
+ C2 ( j, k + 1, α, β) + ζ jC2 ( j + 1, k + 1, α, β) +η jC2 ( j + 2, k + 1, α, β) ζk hk+1 + C2 ( j, k + 2, α, β) + ζ jC2 ( j + 1, k + 2, α, β) i +η jC2 ( j + 2, k + 2, α, β) ηk hk+2 , b kk = ξk2 (hk + ζk2 hk+1 + ηk2 hk+2 ), b k,k+1 = b k+1,k =
2λ k(α − β)k!0(k + β + 1) (0(α + 1))2 (k + 2)(k + λ + 1)(k + λ + 2)2 (2k + λ + 5)0(k + α + 2)0(k + λ) × k2 (λ + 5) + k(λ + 3)(λ + 5) + 16λ + 11 + 2(λ − 1)2 ,
154
Numer Algor (2006) 42: 137–164
b k,k+2 = b k+2,k = − ck+1,k = − ck,k+1 =
2λ k(k + 1)(k + β + 2)(2k + λ + 1)k!0(k + β + 1)(0(α + 1))2 , (k + α + 1)(2k + λ + 1)2 (2k + λ + 3)2 0(k + α + 1)0(k + λ)
2λ−1 k(2k + λ + 1)(k + 1)!(0(α + 1))2 0(k + β + 1) , (k + λ + 1)2 0(k + α + 2)0(k + λ)
2λ−1 (2k + λ + 1)(k + 1)!(0(α + 1))2 0(k + β + 1) (k + β + 2)(k + λ + 2)0(k + α + 3)0(k + λ + 4) h × k6 + k5 (5λ + 7) + k 4 (αβ + 7 + (2λ + 6)(5λ + 3)) +k 3 ((λ + 1)(λ + 3)(10λ + 22) + 5λ + 4αβ(λ + 5) − 13) + k2 (34 +(λ + 2)3 (5λ + 1) + 2λ(13λ + 42) + αβ((2λ + 18)(3λ − 2) + 127))
+k(λ + 3)(38αβλ + (λ + 2)(λ + 2)3 + (2λ − 2)2 (1 + αβ) + 44(αβ − 1)) i +(αβ + λ)(λ + 2)3 (λ + 3) , h ckj = ξk ξ j C1 ( j, k, α, β) + ζ jC1 ( j + 1, k, α, β) + η jC1 ( j + 2, k, α, β) hk + C1 ( j, k + 1, α, β) + ζ jC1 ( j + 1, k + 1, α, β) +η jC1 ( j + 2, k + 1, α, β) ζk hk+1 + C1 ( j, k + 2, α, β) + ζ jC1 ( j + 1, k + 2, α, β) i +η jC1 ( j + 2, k + 2, α, β) ηk hk+2 ,
where ζk and ηk are given by (4.8).
Corollary 4.3. If α = β = 0, then the nonzero elements (akj), (b kj) and ckj for 0 ≤ k, j ≤ N − 2, are given as follows:
akk =
2k(k + 1)(2k + 3) , (k + 2)(k + 3)
b k,k+2 = b k+2,k = ck+1,k =
b kk =
4(2k + 3)(k 4 + 6k 3 + 23k2 + 42k + 30) , (k + 2)2 (k + 3)2 (2k + 1)(2k + 5)
−2(k)2 2(k + 2)(k2 + 4k + 15) , ck,k+1 = , (k + 2)2 (2k + 5) (k + 3)2 (k + 4)
−2(k)2 , (k + 2)2
ckj =
8(2k + 3)(2 j+ 3) , j = k + 2n + 1, n ≥ 1. (k + 2)2 ( j+ 2)2
Remark 4.4. If β2 = 0, α = β = 0, then the system in such a case is a pentadiagonal. In this particular case the system can be decoupled into two separate tridiagonal systems. Moreover, if β1 = β2 = 0, α = β = 0, then the system is reduced to a diagonal system A a = f, whose diagonal elements are akk = 2k(k+1)(2k+3) . (k+2)(k+3)
Numer Algor (2006) 42: 137–164
155
Corollary 4.5. If α = β, and each is replaced by (α − 12 ), then the nonzero elements of the matrices A, B and C in system (4.7) are given as follows: 20( 12 )0 α + 12 k(k + 1)!(k + 2α)(k + α + 1) akk = , 0(α + 1)(2α + 1)k+2 4 j0 12 0 α + 12 (1 − 2α)( j + α + 1)(k + α + 1)( j + 2α) j! akj = , (k + 2)(k + 2α + 2)0(α + 1)(2α + 1) j+1 j = k + 2n, n ≥ 1, b kk
b k,k+2 ck,k+1
ck+1,k
20 12 0 α + 12 k!(k + α + 1) = (k + 2)(k + α)(k + α + 2)(k + 2α + 1)(k + 2α + 2)2 0(α)(2α)k h × k 4 + 4k 3 (α + 1) + k 2 i × 6α 2 + 19α + 12 + k 4α 3 + 26α 2 + 38α + 16 + 8α 3 + 28α 2 + 28α + 8 , −0 12 0 α + 12 k(k + 1)!(k + 2α) = b k+2,k = , 2(k + α + 2)0(α + 1)(2α + 1)k+2 0 12 0(α + 12 )(k + 1)!(k + 2α + 1) h 3 = × k + k 2 (6α + 3) + k 12α 2 + 24α + 8 (k + 2α + 2)0(α + 1)(2α + 1)k+3 i +8α 3 + 28α 2 + 28α + 8 , 0 12 0(α + 12 )k(k + 1)!(k + 2α) =− , 0(α + 1)(2α + 1)k+2
ckj =
22α+3 j!( j + α + 1)(k + α + 1)(2α + 1)( j + 2α)(0(α + 12 ))2 , (k + 2)(k + 2α + 2)0(2α + j + 3) j = k + 2n + 1, n ≥ 1.
This result is in complete agreement with the known result [17]. 4.2. Nonhomogeneous boundary conditions In this case, the general second-order differential equation (4.1) is subject to the boundary conditions α1 u(1) + λ1 u0 (1) = ε1 ,
α2 u(−1) + λ2 u0 (−1) = ε2 .
(4.9)
In such a case we proceed as follows: Set V(x) = u(x) − Ex − F,
(4.10)
where α1 ε2 − α2 ε1 ε1 (λ2 − α2 ) − ε2 (α1 + λ1 ) , F= , W = α1 λ2 − α2 λ1 − 2α1 α2 6 = 0. W W The transformation (4.10) turns the nonhomogeneous boundary conditions (4.9) into the homogeneous boundary conditions E=
α1 V(1) + λ1 V 0 (1) = 0,
α2 V(−1) + λ2 V 0 (−1) = 0.
(4.11)
156
Numer Algor (2006) 42: 137–164
Hence it suffices to solve the following modified equation β1 V + β2 V 0 − V 00 = f ∗ (x) in I = (−1, 1),
(4.12)
subject to the homogeneous mixed boundary conditions (4.11), where V(x) is given by (4.10), and f ∗ (x) = f (x) − β1 (Ex + F) − β2 E. If we apply the Galerkin method to the modified equation (4.12), we get the equivalent system of equations A + β1 B + β2 C a = f ∗ , (4.13) where A, B, and C are the matrices defined in Theorem 4.1, and ∗ f ∗ = ( f0∗ , f1∗ , ..., f N−2 ),
where 2β1 E β1 E (α − β) f − ζ h + − (β F + β E) h0 , k = 0, 0 0 1 1 2 λ+1 λ+1 fk∗ = 2λ+1 β1 E 0(α + 1) 0(β + 2) f1 − , k = 1, 0(λ + 3) fk , k ≥ 2. Remark 4.6. In the case of W = 0, the previous treatment fails but we can take the approximate solution in the form u N (x) = 80 (x) +
N−2 X
ak φk (x),
k=0
where the basis is chosen such that 80 (x) satisfies the nonhomogeneous boundary conditions and such that every φk (x), k = 0, 1, ..., N − 2, satisfies the homogeneous parts of the boundary conditions.
5. Numerical results In this section we give some numerical results obtained by using the algorithms presented in the previous sections. It is worth mentioning that the pure spectral-Galerkin method is rarely used in practice, since for a general right-hand side function f one is unable to compute exactly its representation by Jacobi polynomials. In fact, the so-called pseudospectral method is used to treat the right-hand side; i.e., we replace f by its polynomial interpolation over the set of Gauss–Jacobi points (see, Ralston [26], pp. 97–100, and Davis and Rabinowitz [10], pp. 74–75). This should slightly improve roundoff error. If the two assigned abscissas +1 and −1 are necessary to use, then the set of Gauss–Lobatto points would be much suitable than those of Gauss–Jacobi points; and this in turn would introduce an extra error of order C(σ )N −σ k f kσ,w for f ∈ H σ () (see [8]) in the estimate (3.3). Hence, the spectral accuracy still is retained.
Numer Algor (2006) 42: 137–164
157
We consider the following examples. Example 1. Consider the one-dimensional nonhomogeneous Helmholtz equation − u00 + b 2 u = eax ,
x ∈ [−1, 1],
(5.1)
u(±1) = 0,
with an exact smooth solution u(x) =
eax + e−b x sinh(a − b )cosech(2b ) − eb x sinh(a + b )cosech(2b ) . b 2 − a2
We shall compare the Jacobi–Galerkin approximations obtained, using the first and second choices of bases (JG1) and (JG2), for some different values of the parameter α and β. P N−2 (α,β) (1) For JG1, u N = k=0 ak ξk (1 − x2 )Pk (x), where the vector of unknowns a is the solution of the system b 2 B + C a = f ∗, (5.2) where the nonzero elements of matrices B and C are those given in Theorem 3.2, and h i (2a)k e−a 0(k + λ)0(k + α + 1) fk∗ = 1 F1 k + β + 1, 2k + λ + 1, 2a , k = 0, 1, ..., N − 2. k!0(α + 1)0(2k + λ) (5.3) (2) For JG2, u N =
P N−2 k=0
(α,β)
(α,β) (α,β) (x) + dk Pk+1 (x) + ek Pk+2 (x) , b 2 B + A a = f,
ak ξk Pk
(5.4)
Table 1 Maximum pointwise error of u − uN for N = 4,8,16,20. N
a
b
α
β
JG1
JG2
a
b
JG1
JG2
4
1
0
0
1
1
0
2
1
20
1
0
1.465.10−3 1.057.10−3 7.961.10−4 2.286.10−3 1.424.10−3 3.977.10−8 2.223.10−8 1.577.10−8 4.345.10−8 2.497.10−8 7.632.10−16 6.383.10−16 7.137.10−16 8.118.10−16 7.910.10−16 7.632.10−16 6.383.10−16 7.137.10−16 8.118.10−16 7.910.10−16
2
16
7.961.10−4 1.424.10−3 2.458.10−3 4.753.10−3 4.209.10−3 1.577.10−8 2.497.10−8 3.934.10−8 5.105.10−8 6.544.10−8 7.335.10−16 6.730.10−16 7.640.10−16 6.557.10−16 7.216.10−16 7.335.10−16 6.730.10−16 7.640.10−16 6.557.10−16 7.216.10−16
1
1
1 0.5 0 0.5 −0.5 1 0.5 0 0.5 −0.5 1 0.5 0 0.5 −0.5 1 0.5 0 0.5 −0.5
2
8
1 0.5 0 −0.5 −0.5 1 0.5 0 −0.5 −0.5 1 0.5 0 −0.5 −0.5 1 0.5 0 −0.5 −0.5
2
1
8.455.10−3 1.460.10−2 2.635.10−2 5.016.10−2 4.764.10−2 2.816.10−6 4.473.10−6 7.141.10−6 9.484.10−6 1.119.10−5 2.844.10−15 4.274.10−15 6.411.10−15 6.050.10−15 1.066.10−14 8.257.10−16 5.204.10−16 8.424.10−16 9.992.10−16 9.714.10−16
1.722.10−2 1.247.10−2 8.455.10−3 2.510.10−2 1.512.10−2 7.486.10−6 4.271.10−6 2.816.10−6 7.937.10−6 4.473.10−6 9.398.10−15 4.173.10−15 2.938.10−15 5.107.10−15 4.482.10−15 1.564.10−15 1.609.10−15 4.907.10−16 1.873.10−15 1.970.10−15
158
Numer Algor (2006) 42: 137–164
Table 2 Cond(C) for any α, β.
N
αmin
4 8 16 32 64
2
αmax 12 56 240 992 4,032
Cond (C)
Cond (C)/N 2
6 28 120 496 2,016
3.750.10−1 4.375.10−1 4.687.10−1 4.843.10−1 4.921.10−1
and the nonzero elements of matrices A and B are those given in Theorem 3.6, and ∗ ∗ fk = ξk ξk hk fk∗ + dk ξk+1 hk+1 fk+1 + ek ξk+2 hk+2 fk+2 , k = 0, 1, ..., N − 2. (5.5) Table 1 lists the maximum pointwise error of u − u N using the JGM with various choices of α, β, a, b , and N. The main source of roundoff errors comes from the matrix decomposition. For JG1, the system resulted from −u00 = f (x) is Ca = f ∗ , where C is an upper triangular matrix whose diagonal elements are ckk = (k + 1)(k + 2), Table 3 Cond(A) for some different values of α, β. N
α
β
αmin
4 8 16 32 64 4 8 16 32 64 4 8 16 32 64 4 8 16 32 64 4 8 16 32 64
1
1
0.5
0.5
2.400 1.511 0.862 0.463 0.240 4.1887
0
0
6
−0.5
0.5
12.566
−0.5
−0.5
12.566
αmax 3.333
5.026 5.585 5.913 6.092 6.186 14 30 62 126 254 1.3309.102 6.1575.102 2.8274.103 1.2076.104 4.9875.104 7.5398.101 3.5185.102 1.5079.103 6.2329.103 2.5333.104
Cond (A)
Cond (A)/N |1−2α|
1.388.100 2.205.100 3.863.100 7.192.100 1.385.101 1.200.100 1.333.100 1.411.100 1.454.100 1.476.100 2.333.100 5.000.100 1.033.101 2.100.101 4.233.101 9.000.100 4.900.101 2.250.102 9.610.102 3.969.103 6.000.100 2.800.101 1.200.102 4.960.102 2.016.103
3.472.10 −1 2.757.10 −1 2.414.10 −1 2.247.10 −1 2.16510 −1 1.200.10 0 1.333.10 0 1.411.10 0 1.454.10 0 1.476.100 5.833.10−1 6.250.10−1 6.458.10−1 6.562.10−1 6.614.10−1 5.625.10−1 7.656.10−1 8.789.10−1 9.384.10−1 9.889.10−1 3.750.10−1 4.375.10−1 4.687.10−1 4.843.10−1 4.921.10−1
Numer Algor (2006) 42: 137–164
159
Table 4 The condition number for the matrix E = A + b2 B. α
N 4 8 16 32 64 4 8 16 32 64 4 8 16 32 64 4 8 16 32 64 4 8 16 32 64
β
1
1
0.5
0.5
0
0
αmin 2.502 1.506 0.862 0.462 0.2405 5.203 4.836 4.834 4.834 4.834
8.374
−0.5
0.5
−0.5
−0.5
17.546 17.548 17.548 17.548 17.548 17.562 17.563 17.563 17.563 17.563
αmax 11.108
11.652 11.653 11.653 11.653 11.653 14.647 30.274 62.130 126.06 245.032 1.1767.102 6.2039.102 2.8321.103 1.2081.104 4.9880.104 7.8256.101 3.5441.102 1.5104.103 6.2353.103 2.5336.104
Cond (E)
Cond,(E)/N |1−2α|
4.439.100 7.375.100 1.288.101 2.396.101 4.617.101 2.239.100 2.409.100 2.410.100 2.410.100 2.410.100 1.749.100 3.615.100 7.419.100 1.505.101 3.033.101 6.706.100 3.535.101 1.613.102 6.884.102 2.842.103 4.456.100 2.017.101 8.599.101 3.550.102 1.442.103
1.109.10 0 9.219.10 −1 8.050.10 −1 7.490.10 −1 7.215.10 −1 2.239.10 0 2.409.10 0 2.410.10 0 2.410.10 0 2.410.10 0 4.372.10−1 4.518.10−1 4.636.10−1 4.704.10−1 4.739.10−1 4.191.10−1 5.524.10−1 6.304.10−1 6.723.10−1 6.939.10−1 2.785.10−1 3.152.10−1 3.359.10−1 3.466.10−1 3.521.10−1
Thus we note that the condition number for C behaves like O(k 2 ) for every value of α, β. For JG2, the resulting system is A a = f, where A is also an upper triangular matrix with akk =
2λ−2 (k + 1)2 (2k + λ + 1)2 (2k + λ + 2)(k + 2)! 0(k + β + 1)(0(α + 1))2 , (k + α + 1)3 (k + β + 1)0(k + α + 1)0(k + λ + 2)
and accordingly, its condition number behaves like O(k|1−2α| ) for large values of k and α, β > −1. Tables 2 and 3 illustrate the condition numbers for matrix C in (5.2) and matrix A in (5.4), respectively. Remark 5.1. If we add b 2 B to matrix C of system (5.2) and add b 2 B to matrix A of system (5.4), then we find that the eigenvalues of matrices D = C + b 2 B and E = A + b 2 B are all real positive. Moreover, the effect of these additions does not significantly change the values of the condition numbers for the two systems. This means that matrices C and A, which resulted from the highest derivatives of the differential equations under investigation, play the most important role in the propagation of the roundoff errors. The numerical results of table 4 illustrates this remark.
160
Numer Algor (2006) 42: 137–164
Table 5 Maximum pointwise error of u − uN for N = 16,32,36,40. N
α
β
k
JG1
JG2
k
JG1
JG2
16
1 0.5 0 −0.5 −0.5 1 0.5 0 −0.5 −0.5 1 0.5 0 −0.5 −0.5 1 0.5 0 0.5 −0.5 −0.5
1 0.5 0 0.5 −0.5 1 0.5 0 0.5 −0.5 1 0.5 0 0.5 −0.5 1 0.5 0 −0.5 0.5 −0.5
1
2.556.10−12 3.485.10−12 5.331.10−12 4.937.10−12 7.760.10−12 1.110.10−16 1.804.10−16 1.110.10−16 3.081.10−16 1.665.10−16 1.110.10−16 1.110.10−16 1.110.10−16 2.914.10−16 1.110.10−16 1.110.10−16 1.110.10−16 1.249.10−16 2.636.10−16 2.636.10−16 1.110.10−16
3.523.10−12 2.670.10−12 2.055.10−12 3.353.10−12 3.423.10−12 1.387.10−16 1.249.10−16 2.081.10−16 2.498.10−16 1.249.10−16 1.110.10−16 1.249.10−16 1.249.10−16 2.081.10−16 1.110.10−16 1.110.10−16 1.110.10−16 1.110.10−16 2.636.10−16 2.636.10−16 1.110.10−16
4
5.288.10−3 7.088.10−3 9.561.10−3 8.218.10−3 1.327.10−2 4.266.10−12 5.915.10−12 8.380.10−12 9.208.10−12 1.189.10−11 1.731.10−14 7.049.10−15 1.905.10−14 1.061.10−14 3.113.10−14 1.626.10−14 3.053.10−16 1.817.10−14 5.481.10−16 5.551.10−16 1.210.10−14
3.469.10−3 3.974.10−3 5.288.10−3 4.137.10−3 7.088.10−3 4.810.10−12 3.043.10−12 4.267.10−12 4.605.10−12 5.973.10−12 3.311.10−14 2.677.10−14 1.582.10−14 2.449.10−14 1.471.10−14 2.381.10−14 2.495.10−14 1.509.10−14 1.433.10−14 2.339.10−14 2.498.10−16
32
36
40
1
1
1
4
4
4
Example 2. Consider the two-dimensional Poisson equation −1u = 2k 2 sin(kπ x) sin(kπ y),
in = I × I,
u|∂ = 0.
We shall compare the Jacobi–Galerkin approximations obtained, using JG1 and JG2, for some different values of the parameters α and β. P N−2 (α,β) (α,β) 2 2 (1) For JG1, u N = k, (x) P j (y), and the maj=0 ukj ξk ξ j (1 − x ) (1 − y ) Pk trix of unknowns U = (ukj)k, j=0,1,...,N−2 is the solution of the system CU B + BUC T = F,
(5.6)
where the nonzero elements of matrices B and C are those given in Theorem 3.2. (2) For JG2, if we consider the set of bases {φk (x)φ j(y) : 0 ≤ k, j ≤ N − 2}, φk P N−2 (α,β) (α,β) (α,β) (x) = ξk Pk (x) + dk Pk+1 (x) + ek Pk+2 (x) , then u N = k, j=0 ukj φk (x)φ j (y) and the matrix of unknowns U is the solution of the system AU B + BU AT = F, where the nonzero elements of matrices A and B are those given in Theorem 3.6. Table 5 lists the maximum pointwise error of u − u N using the JGM with various choices of α, β, k, and N. The maximum pointwise errors of the proposed Jacobi–Galerkin algorithms (with parameters α = β = 0.5) are compared in table 6 with the results provided by Chebyshev-tau (CT [19]), Chebyshev–Galerkin (CG [28]), Legendre–Galerkin (LG
Numer Algor (2006) 42: 137–164
161
Table 6 Maximum pointwise error of u − uN . N 16 32 40 64
α
β
0.5
0.5
JG1
JG2
CT [19]
CG [28]
LG [27]
LG [1]
7.08.10−3 5.91.10−12 3.05.10−16 2.51.10−16
3.97.10−3 3.04.10−12 2.49.10−14 2.39.10−14
3.33.10−2 4.77.10−11 – 8.67.10−13
5.22.10−3 2.17.10−12 – 6.11.10−15
2.93.10−3 3.44.10−13 – 5.55.10−15
2.82.10−2 2.55.10−11 – 4.10.10−15
[27]) and the Legendre–Galerkin (LG [1]) methods. The displayed results show that the JG1 is in general more accurate than CT [19] and LG [1], especially for large values of N. Example 3. Consider the two-dimensional Helmholtz equation 3 3 2 u − 1u = + 2k sin(kπ x) sin(kπ y), in = I × I, 2 2π 2
u|∂ = 0,
Table 7 lists the maximum pointwise error of u − u N using the JGM with various choices of α, β, k, and N. Example 4. The algorithm for the one-dimensional Neumann problem is tested to solve problem (4.1) with β1 = 1.5, β2 = 0 and with analytical solution u(x) = sin(x). In this case u N (x) = 80 (x) +
N−2 X
ak φk (x),
k=0
Table 7 Maximum pointwise error of u − uN for N = 16,32,40. N
α
β
16
1 0.5 0 −0.5 −0.5 1 0.5 0 −0.5 −0.5 1 0.5 0 0.5 −0.5 −0.5
1 0.5 0 0.5 −0.5 1 0.5 0 0.5 −0.5 1 0.5 0 −0.5 0.5 −0.5
32
40
k
1
1
1
JG1
JG2
k
JG1
JG2
2.879.10−12 4.013.10−12 5.551.10−12 6.286.10−12 7.742.10−12 1.110.10−16 1.110.10−16 1.110.10−16 2.498.10−16 1.110.10−16 1.110.10−16 1.110.10−16 1.110.10−16 2.636.10−16 2.636.10−16 1.110.10−16
5.324.10−12 2.589.10−12 2.879.10−12 4.822.10−12 4.013.10−12 1.110.10−16 1.110.10−16 1.249.10−16 2.636.10−16 1.110.10−16 1.110.10−16 1.110.10−16 1.249.10−16 2.636.10−16 2.636.10−16 1.110.10−16
4
5.302.10−3 7.138.10−3 9.691.10−3 1.030.10−2 1.326.10−2 4.265.10−12 5.954.10−12 8.365.10−12 9.205.10−12 1.183.10−11 1.626.10−14 3.053.10−16 1.930.10−14 5.481.10−16 5.551.10−16 1.210.10−14
9.279.10−3 4.266.10−3 5.302.10−3 7.679.10−3 7.138.10−3 4.766.10−12 3.074.10−12 4.265.10−12 5.584.10−12 5.954.10−12 2.381.10−14 2.495.10−14 1.458.10−14 1.433.10−14 2.339.10−14 2.636.10−16
4
4
162 Table 8 Maximum pointwise error of u − uN for N − 2 = 4,8,16.
Numer Algor (2006) 42: 137–164 N−2 4
8
16
α
β
1 0.5 0 −0.5 0.5 −0.5 1 0.5 0 −0.5 0.5 −0.5 1 0.5 0 −0.5 0.5 −0.5
1 0.5 0 0.5 −0.5 −0.5 1 0.5 0 0.5 −0.5 −0.5 1 0.5 0 0.5 −0.5 −0.5
JGM
LG[3]
7.873.10−5 4.146.10−5 6.139.10−6 3.739.10−5 2.987.10−5 1.079.10−4 1.621.10−9 6.578.10−10 3.788.10−11 4.139.10−10 5.102.10−10 1.678.10−9 8.548.10−15 3.330.10−16 3.330.10−16 2.221.10−16 6.661.10−16 2.221.10−16
5.47.10−6
3.26.10−11
8.88.10−16
cos(1) (α,β) (α,β) (β − α)P0 (x) + 2P1 (x) satisfies the nonhomogeneous λ+1 boundary conditions , φk (x), k = 0, 1, ..., N − 2, defined as in (4.8) and the vector of unknowns a is the solution of system where 80 (x) =
(A + β1 B)a = f ∗ , where the nonzero elements of matrices A and B are those given in Theorem 4.2, and 2λ−1 3 cos(1) (α − β)0(α + 1)0(β + 1) f + , k = 0, 0 0(λ + 2) ∗ λ 2 3cos(1)0(α + 1)0(β + 2) fk = f1 − , k = 1, 0(λ + 3) fk , k ≥ 2. The maximum pointwise errors of the proposed Jacobi–Galerkin algorithm are compared in table 8 with the results provided by Legendre–Galerkin method [3].
6. Concluding remarks We have presented a systematics way to construct appropriate bases for the JGM applied to general second-order differential equations in one-dimension and, in particular, Helmholtz equations in one- and two-dimensions. We have also developed efficient direct solvers, whose complexities are a small multiple of N d+1 operations in a d-dimensional domain, with (N − 1)d unknowns. We have demonstrated more than once that the two parameters α and β play an important role in making diagonal the systems of equations to be solved for particular second-order differential equations. The algorithms, namely, ultraspherical-Galerkin method developed by Doha and Abd-Elhameed [17] can be obtained as special case from our JGM by taking α = β,
Numer Algor (2006) 42: 137–164
163
and each is replaced by α − 12 ; Legendre and Chebyshev Galerkin methods developed by Shen [27, 28], can be obtained as special cases from our JGM by taking α = β = 0 and α = β = − 12 ; , respectively. In particular, for the second choice of basis, although we concentrated on applying our algorithms to solve constant coefficients differential equations, we do claim that such algorithms can be applied to solve not only differential equations with polynomial varying coefficients of any order but also evolution equations. Acknowledgment The authors would like to thank the two anonymous referees for their valuable comments and suggestions.
References [1] Auteri, F., Quartapelle, L.: Galerkin spectral method for the vorticity and stream function equations. J. Comput. Phys. 149, 306–332 (1999) [2] Auteri, F., Quartapelle, L.: Galerkin–Legendre spectral method for the 3D Helmholtz equation. J. Comput. Phys. 161, 454–483 (2000) [3] Auteri, F., Parolini, N., Quartapelle, L.: Essential imposition of Neumann Galerkin–Legendre elliptic solvers. J. Comput. Phys. 185, 427–444 (2003) [4] Ben-Yu, G.: Jacobi spectral approximations to differential equations on the half line. J. Comput. Math. 18, 95–112 (2000) [5] Ben-Yu, G.: Jacobi spectral method for differential equations with rough asymptotic behaviors at infinity. Comput. Math. Appl. 46, 95–104 (2003) [6] Boyd, J.P.: Chebyshev and Fourier Spectral Methods, 2nd ed. Dover, Mineola (2001) [7] Buzbee, B.L., Golub, G.H., Neilson, C.W.: On direct methods for solving Poisson’s equations. SIAM J. Numer. Anal. 7, 627–656 (1970) [8] Canuto, C., Hussaini, M.Y., Quarteroni, A., Zang, T.A.: Spectral Methods in Fluid Dynamics. Springer, New York (1988) [9] Dang-Vu, H., Delcarte, C.: An accurate solution of the Poisson equation by the Chebyshev collocation method. J. Comput. Phys. 104, 211–220 (1993) [10] Davis, P.J., Rabinowitz, P.: Methods of Numerical Integration. Academic, New York (1975) [11] Doha, E.H.: An accurate double Chebyshev spectral approximation for Poisson’s equation. Ann. Univ. Sci. Budapest Sect. Comp. 10, 243–276 (1990) [12] Doha, E.H.: An accurate solution of parabolic equations by expansion in ultraspherical polynomials. J. Comput. Math. Appl. 19, 75–88 (1990) [13] Doha, E.H.: The coefficients of differentiated expansions and derivatives of ultraspherical polynomials. J. Comput. Math. Appl. 21, 115–122 (1991) [14] Doha, E.H.: The ultraspherical coefficients of the moments of a general-order derivative of an infinitely differentiable function. J. Comput. Appl. Math. 89, 53–72 (1998) [15] Doha, E.H.: On the coefficients of differentiated expansions and derivatives of Jacobi polynomials. J. Phys. A: Math. Gen. 35, 3467–3478 (2002) [16] Doha, E.H.: On the construction of recurrence relations for the expansion and connection coefficients in series of Jacobi polynomials. J. Phys. A: Math. Gen. 37, 657–675 (2004) [17] Doha, E.H., Abd-Elhameed, W.M.: Efficient spectral-Galerkin algorithms for direct solution of second-order equations using ultraspherical polynomials. SIAM J. Sci. Comput. 24, 548–571 (2002) [18] Gottlieb, D., Orszag, S.A.: Numerical Analysis of Spectral Methods: Theory and Applications, SIAM, Philadelphia, Pennsylvania (1977) [19] Haidvogel, D.B., Zang, T.: The accurate solution of Poisson’s equation by expansion in Chebyshev polynomials. J. Comput. Phys. 30, 167–180 (1979) [20] Heinrichs, W.: Improved condition number of spectral methods. Math. Comp. 53, 103–119 (1989) [21] Heinrichs, W.: Spectral methods with sparse matrices. Numer. Math. 56, 25–41 (1989) [22] Heinrichs, W.: Algebraic spectral multigrid methods. Comput. Methods Appl. Mech. Eng. 80, 281–286 (1990) [23] Lanczos, C.: Applied Analysis. Pitman, London (1957)
164
Numer Algor (2006) 42: 137–164
[24] Luke, Y.: The Special Functions and Their Approximations, vol. 1. Academic, New York (1969) [25] Orszag, S.A.: Spectral methods for problems in complex geometrics. J. Comput. Phys. 37, 70–92 (1980) [26] Ralston, A.: A First Course in Numerical Analysis. McGraw-Hill, New York (1965) [27] Shen, J.: Efficient spectral-Galerkin method. I. Direct solvers of second- and fourth-order equations using Legendre polynomials. SIAM J. Sci. Comput. 15, 1489–1505 (1994) [28] Shen, J.: Efficient spectral-Galerkin method. II. Direct solvers of second- and fourth-order equations using Chebyshev polynomials. SIAM J. Sci. Comput. 16, 74–87 (1995) [29] Siyyam, H.I., Syam, M.I.: An accurate solution of Poisson equation by the Chebyshev–Tau method. J. Comput. Appl. Math. 85, 1–10 (1997) [30] Szegö, G.: Orthogonal Polynomials. Am. Math. Soc. Colloq. Pub. 23 (1985) [31] Watson, G.N.: A note on generalized hypergeometric series. Proc. Lond. Math. Soc. 23(2), xiii–xv (1925) (Records for 8 Nov. 1923)