Dymore User’s Manual Chebyshev polynomials Contents 1 Definition 1.1 Zeros and extrema . . . . . . . . . . . 1.2 Orthogonality relationships . . . . . . 1.3 Derivatives of Chebyshev polynomials 1.4 Integral of Chebyshev polynomials . . 1.5 Products of Chebyshev polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2 4 4 4 2 Chebyshev approximation of functions of a single variable 2.1 Expansion of a function in Chebyshev polynomials . . . . . . 2.2 Evaluation of Chebyshev expansions: Clenshaw’s recurrence . 2.3 Derivatives and integrals of Chebyshev expansions . . . . . . 2.4 Products of Chebyshev expansions . . . . . . . . . . . . . . . 2.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6 Clenshaw-Curtis quadrature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4 5 6 6 7 8 3 Chebyshev approximation of functions of two variables 3.1 Expansion of a function in Chebyshev polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Evaluation of Chebyshev expansions: Clenshaw’s recurrence . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Derivatives of Chebyshev expansions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 10 10 4 Chebychev polynomials 4.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 12 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Definition Chebyshev polynomials [1, 2] form a series of orthogonal polynomials, which play an important role in the theory of approximation. The lowest polynomials are T0 (x) = 1, T1 (x) = x, T2 (x) = 2x2 − 1, T3 (x) = 4x3 − 3x, T4 (x) = 8x4 − 8x2 + 1, . . . (1) and are depicted in fig. 1. The polynomials can be generated from the following recurrence relationship Tn+1 = 2xTn − Tn−1 , n ≥ 1. (2) It is possible to give an explicit expression of Chebyshev polynomials as Tn (x) = cos(n arccos x). (3) This equation can be verified by using elementary trigonometric identities. For instance, it is clear, that T2 = cos [2 arccos x] = 2 cos2 (arccos x) − 1 = 2x2 − 1, as expected from eq. (1). 1.1 Zeros and extrema It is now easy to verify that Tn (x) possesses n zeros within the interval x ∈ [−1, +1]: Tn (x) = cos(n arccos x) = 0 implies n arccos x = (2k − 1)π/2. Hence, the zeros of Chebyshev polynomial Tn (x) are x̄k = cos π(2k − 1) , 2n 1 k = 1, 2, 3, . . . , n. (4) 1 0.8 CHEBYSHEV POLYNOMIALS 0.6 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 XX Figure 1: The seven lowest order Chebyshev polynomials √ √ √ For instance, since T3 = x(4x2 √ − 3), its zeros are 3/2, 0, and − 3/2, which can be written as cos π/6 = 3/2, cos 3π/6 = 0, and cos 5π/6 = − 3/2. The value of Chebyshev polynomial Ti (x) at the zeros of Tn (x) is easily found from eq. (3) as i(2k − 1)π , i < n. (5) Ti (x̄k ) = cos 2n It is also easy to find the extrema√of a Chebyshev polynomial by imposing the vanishing of its derivative, dTn /dx = 0. This leads to [n sin(n arccos x)] / 1 − x2 = 0, or sin [n arccos x] = 0. The extrema of Chebyshev polynomial Tn (x) are kπ , k = 0, 1, 2, 3, . . . , n. (6) x̂k = cos n √ √ For instance, dT4 /dx = x(2x2 − 1) = 0 leads to extrema cos π/4 = 2/2, cos π/2 = 0, and cos 3π/4 = − 2/2. The additional extrema, cos 0 = 1 and cos π = −1, occur at the ends of the interval. The value of Chebyshev polynomial Ti (x) at the extrema of Tn (x) is easily found from eq. (3) as Ti (x̂k ) = cos 1.2 ikπ , n i < n. (7) Orthogonality relationships Chebyshev polynomials are orthogonal within the interval x ∈ [−1, +1] with a weight of (1 − x2 )−1/2 , i.e. Z +1 i 6= j 0 Ti (x)Tj (x) √ π/2 i = j 6= 0 . dx = 1 − x2 −1 π i=j=0 In addition to the orthogonality property defined by eq. (8), discrete orthogonality relationship n 0 X n/2 Ti (x̄k )Tj (x̄k ) = n k=1 2 (8) Chebyshev polynomials also enjoy the following i 6= j i=j= 6 0 . i=j=0 (9) where x̄k , k = 1, 2, 3, . . . , n are the zeros of Tn as given by eq. (4), and i, j < n. To prove this orthogonality relationship, trigonometric identities are used n X Ti (x̄k )Tj (x̄k ) = n X cos k=1 n−1 X k=1 i(2k − 1)π j(2k − 1)π cos 2n 2n (i − j)(2k + 1)π (i + j)(2k + 1)π , + cos cos 2n 2n k=0 i i h h (i+j)π (i−j)π (i+j)π (i−j)π n (i+j)π n (i−j)π sin cos + (n − 1) cos + (n − 1) sin 2 n 2n 2n 2 n 2n 2n 1 = + (i+j)π (i−j)π 2 sin 2n sin 2n " # (i+j)π (i+j)π (i−j)π cos sin (i−j)π 1 sin 2 cos 2 2 2 = + = 0. 2 sin (i+j)π sin (i−j)π 1 = 2 2n 2n The trigonometric identity, eq. (12) was used to eliminate the summation; the last equality results from the fact that cos(i + j)π/2 = cos(i − j)π/2 = 0. If i = j 6= 0, or i = j = 0, similar developments yield the discrete orthogonality given by eq. (9). Chebyshev polynomials also enjoy an additional discrete orthogonality relationship n i 6= j 0 X ′′ Ti (x̂k )Tj (x̂k ) = n/2 i = j 6= 0 . (10) n i=j=0 k=0 where x̂k , k = 0, 1, 2, · · · , n are the extrema of Tn as given by eq. (6), and i, j < n. The double prime after the summation sign indicates that the first and last terms of the summation must be halved. To prove this orthogonality relationship, trigonometric identities are used n X Ti (x̂k )Tj (x̂k ) = k=0 n X cos k=0 n X 1 = 2 k=0 jkπ ikπ cos , n n (i − j)π (i + j)π + cos k cos k n n " # (i+j)π (i−j)π cos n2 (i+j)π cos n2 (i−j)π sin n+1 1 sin n+1 2 n n 2 n n = + 2 sin (i+j)π sin (i−j)π 2n 2n # " (i+j)π (i−j)π 2n+1 (i−j)π 2n+1 (i+j)π sin + sin + sin 1 sin 2 n 2n 2 n 2n + = (i−j)π 4 sin (i+j)π sin 2n 2n i i h h (i+j)π (i−j)π sin (i + j)π + sin (i − j)π + 2n 2n 1 = 2 + + 4 sin (i+j)π sin (i−j)π 2n = 2n 1 1 [2 + cos(i + j)π + cos(i − j)π] = [1 + cos iπ cos jπ] . 4 2 The first term in the last bracket is the term of the sum corresponding to k = 0, whereas the second term in the last bracket is that corresponding to k = n. Bringing these two terms to the left hand side is identical to replacing the P P summation sign, , by ′′ . Here again, the trigonometric identity, eq. (12) was used to eliminate the summation. If i = j 6= 0, or i = j = 0, similar developments yield the discrete orthogonality given by eq. (10). The following trigonometric identities were used in the derivation of the above discrete orthogonality relationships sin(a) + sin(a + b) + . . . + sin(a + nb) = n X sin sin(a + kb) = k=0 cos(a) + cos(a + b) + . . . + cos(a + nb) = n X k=0 3 sin cos(a + kb) = nb (n + 1)b sin(a + ) 2 2 , b sin 2 (11) nb (n + 1)b cos(a + ) 2 2 . b sin 2 (12) 1.3 Derivatives of Chebyshev polynomials The following expression for the derivatives of Chebyshev polynomials 2n [Tn−1 + Tn−3 + . . . + T1 ] ′ Tn = 2n [Tn−1 + Tn−3 + . . . + T2 ] + nT0 n even, n odd, (13) where the notation (·)′ indicates a derivative with respect to x, can be proved by mathematical induction. Indeed, they are verified for the lowest polynomials, T1′ = T0 , T2′ = 2 × 2 T1 , T3′ = 2 × 3 T2 + 3T0 , T4′ = 2 × 4 (T3 + T1 ), etc. It then remains to prove that if it is correct for n it is still correct for n + 1. Taking a derivative of the basic recurrence ′ ′ = 2xTn′ + 2Tn − Tn−1 . Introducing eq. (13) into this recurrence, it for Chebyshev polynomials, eq. (2), leads to Tn+1 is then easy to show that eq. (13) is true for n + 1. 1.4 Integral of Chebyshev polynomials The following recurrence relationship is easy to prove ′ T′ Tn+1 − n−1 , n+1 n−1 2Tn (x) = with the help of eq. (13). It then follows that Z +1 2 Tn (x) dx = 2 n+1 0 −1 These two equations are easily combined to yield Z +1 −1 1.5 − T2n (x) dx = − 2 n−1 (14) n even, n odd 2 . −1 (15) (16) 4n2 Products of Chebyshev polynomials The product of two Chebyshev polynomials satisfies the following relationship 2Tn (x)Tm (x) = Tn+m (x) + Tn−m (x), n ≥ m. (17) This relationship is an identity for m = 0; indeed, since T0 = 1, it then follows that 2Tn T0 = Tn +Tn . Multiplying both sides of this equation by 2x yields 2Tn (2xT0 ) = 2(2xTn ). Applying the basic recurrence relationship for Chebyshev polynomials, eq. (2), to the two terms in parenthesis then yields 2Tn (2T1 ) = 2(Tn+1 + Tn−1), or 2Tn T1 = Tn+1 + Tn−1 , which proves eq. (17) for m = 1. Since eq. (17) is true for m = 0 and 1, suffice now to prove that if it holds for m, it is also true for m + 1. Multiplying both sides of this equation by 2x yields 2Tn (2xTm ) = (2xTn+m ) + (2xTn−m ). Applying the basic recurrence relationship for Chebyshev polynomials, eq. (2), to the three terms in parenthesis then yields 2Tn (Tm+1 + Tm−1 ) = (Tn+m+1 + Tn+m−1 ) + (Tn−m+1 + Tn−m−1 ), and finally, 2Tn Tm+1 = (Tn+m+1 + Tn+m−1 ) + (Tn−m+1 + Tn−m−1 ) − 2Tn Tm−1 = (Tn+m+1 + Tn+m−1 ) + (Tn−m+1 + Tn−m−1 ) − (Tn+m−1 + Tn−m+1 ) = Tn+m+1 + Tn−m−1 . 2 2.1 Chebyshev approximation of functions of a single variable Expansion of a function in Chebyshev polynomials A function f (x) can be approximated in terms of Chebyshev polynomials as f (x) ≈ N −1 X ci Ti (x), (18) i=0 where ci are the coefficients of the expansion. N is the number of coefficients in the expansion, whereas N − 1 is the order of the expansion, i.e. the highest order polynomial in the expansion. To find these coefficients given function f (x), the above relationship is expressed at the x = x̄k , where x̄k are the zeros of TN (x), as given by eq. (4). This PN −1 yields f (x̄k ) = i=0 ci Ti (x̄k ). Multiplying both sides of this equation by Tj (x̄k ) and summing the resulting equations expressed at all zeros of TN (x) leads to "N # N N −1 X X X Ti (x̄k )Tj (x̄k ) . (19) ci f (xk )Tj (x̄k ) = k=1 i=0 4 k=1 In view of the discrete orthogonality relationship of Chebyshev polynomials, eq. (9), it then follows that c0 = N 1 X f (x̄k ), N (20a) k=1 ci = N 2 X f (x̄k )Ti (x̄k ), N (20b) k=1 where Ti (x̄k ) is given by eq. (5). The coefficients of the Chebyshev expansion can be obtained in an alternative manner. Relationship (18) is PN −1 expressed at the x = x̂k , where x̂k are the extrema of TN (x), as given by eq. (6). This yields f (x̂k ) = i=0 ci Ti (x̂k ). Multiplying both sides of this equation by Tj (x̂k ) and summing the resulting equations expressed at all extrema of TN (x) leads to "N # N −1 N X X X ′′ ′′ Ti (x̂k )Tj (x̂k ) . (21) ci f (x̂k )Tj (x̂k ) = i=0 k=0 k=0 In view of the discrete orthogonality relationship of Chebyshev polynomials, eq. (10), it then follows that N 1 X c0 = N ′′ f (x̂k ), (22a) ′′ f (x̂k )Ti (x̂k ), (22b) k=0 ci = N 2 X N k=0 where Ti (x̂k ) is given by eq. (7). Note that as required by the discrete orthogonality relationship of Chebyshev polynomials, eq. (10), the double prime after the summation sign indicates that the first and last terms of the summation must be halved. 2.2 Evaluation of Chebyshev expansions: Clenshaw’s recurrence On the other hand, if the coefficients of the Chebyshev expansion are known, the function can then be computed using eq. (18). However, rather than computing the polynomials then summing all contributions, it is preferable to use the recurrence relation, eq. (2), to find f (x) = c0 T0 + c1 T1 + . . . + cN −2 TN −2 + cN −1 TN −1 , = c0 T0 + c1 T1 + . . . + cN −2 TN −2 + yN −1 TN −1 , = c0 T0 + c1 T1 + . . . + (cN −3 − yN −1 )TN −3 + (cN −2 + 2x yN −1 )TN −2 , = c0 T0 + c1 T1 + . . . + (cN −3 − yN −1 )TN −3 + yN −2 TN −2 , = c0 T0 + c1 T1 + . . . + (cN −4 − yN −2 )TN −4 + (cN −3 − yN −1 + 2x yN −2 )TN −3 , = c0 T0 + c1 T1 + . . . + (cN −4 − yN −2 )TN −4 + yN −3 TN −3 , = (c0 − y2 )T0 + y1 T1 . The following quantities have been defined yN +1 = 0, yN = 0, (23a) (23b) yN −1 = cN −1 − yN +1 + 2x yN , .. . y1 = c1 − y3 + 2x y2 , (23c) y0 = c0 − y2 + 2x y1 . (23d) (23e) The value of the function now simply becomes f (x) = (c0 − y2 ) + y1 x = y0 − x y1 . (24) This approach to the evaluation of functions expressed in Chebyshev series is known as Clenshaw’s recurrence. It provides a numerically stable approach to the evaluation of Chebyshev series. 5 2.3 Derivatives and integrals of Chebyshev expansions Consider now a function and its derivative, both expanded in Chebyshev series f (x) = N −1 X and f ′ (x) = ci Ti (x), N −2 X c′i Ti (x), (25) i=0 i=0 where the notation (·)′ indicates a derivative with respect to x. What is the relationship between the coefficients of the two expansions, ci and c′i ? Using the formula for the derivatives of Chebyshev polynomials, eq. (13), the following recurrence is found c′N ′ cN −1 c′N −2 = 0, (26a) = 0, = 2 × (N − 1) cN −1 + c′N , (26b) (26c) .. . c′1 = 2 × 2 c2 + c′3 , c′0 = (2 × 1 c1 + c′2 )/2. (26d) (26e) Consider finally a function and its integral, both expanded in Chebyshev series f ′ (x) = N −1 X c′i Ti (x), and f (x) = N X ci Ti (x). (27) i=0 i=0 What is the relationship between the coefficients of the two expansions, c′i and ci ? In view of the relationship established above, it is clear that 2c′0 − c′2 , 2 c′ − c′i+1 ci = i−1 , 2i (28a) c1 = i = 2, 3, . . . , N. (28b) Of course, c0 is the integration constant that can be selected arbitrarily. 2.4 Products of Chebyshev expansions Let function h(x) be the product of two functions, f (x) and g(x), such that h(x) = f (x)g(x). It is assumed that the Chebyshev expansions of functions f (x) and g(x) are known and that function h(x) is to be expanded in Chebyshev series, i.e., # M−1 "N −1 N +M−1 X X X ai Ti (x) bj Tj (x) , ck Tk (x) = (29) i=0 k=0 j=0 where ai , i = 1, 2, . . . , N − 1 and bj , j = 1, 2, . . . , M − 1 are the known coefficients of the Chebyshev expansion of functions f (x) and g(x), respectively, and ck , k = 1, 2, . . . , N + N − 2 the unknown coefficients of the expansion of h(x). With the help of identity (17), eq. (29) becomes N +M−1 X 2ck Tk = N −1 M−1 X X ai bj 2Ti Tj = = N −1 M−1 X X ai bj [Ti+j + Ti−j ] i=0 j=0 i=0 j=0 k=0 N −1 M−1 X X ai bj Ti+j + N −1 X i X ai bj Ti−j + i=0 j=0 i=0 j=0 N −1 M−1 X X ai bj Tj−i . i=0 j=i+1 Identification of the coefficients of the Chebyshev polynomials of same order then yields the desired coefficients min[(N −1),(M−1)] 2c0 = a0 b0 + 2ck = u1 X p=ℓ1 X p=0 u2 X ap bk−p + p=k ap b p , ap bp−k + (30a) u3 X p=0 ap bp+k , k = 1, 2, . . . , M + N − 1. (30b) where the bound on the three summations are ℓ1 = max[0, k − (M − 1)], u1 = min[(N − 1), k], u2 = min[(N − 1), (M − 1) + k], and u3 = min[(N − 1), (M − 1) − k], respectively. 6 2.5 Examples To illustrate application of Chebyshev expansions, the following function will be approximated by Chebyshev polynomials f (x) = sin x, x ∈ [0, π/2]. (31) Using the algorithm presented in section 2.1 for N = 12, the coefficients of the Chebyshev approximation were found to be c0 = 6.0219 10−1 , c1 = 5.1363 10−1 , c2 = −1.0355 10−1 , c3 = −1.3732 10−2 , c4 = 1.3587 10−3 , c5 = 1.0726 10−4 , c6 = −7.0463 10−6 , c7 = −3.9639 10−7 , c8 = 1.9500 10−8 , c9 = 8.5229 10−10 , c10 = −3.3516 10−11 , c11 = −1.1990 10−12 . Note the rapid decay in the magnitudes of the coefficients. Figures 2 shows the exact sine function, its Chebyshev approximation, and the error incurred by the approximation. Note that the error is spread over the entire range of the approximation in a nearly uniform manner. This is due to the fact that the extrema of Chebyshev polynomials are distributed over the entire range of the approximation and have alternating values of plus or minus unity. These characteristics make Chebyshev polynomials an ideal basis for approximating functions. 0.01 ERROR SIN(X) 1 0.5 0 −0.01 0 0 0.5 1 1.5 0 0.5 1 1.5 0.5 1 1.5 1 1.5 −4 x 10 1 ERROR SIN(X) 1 0.5 0 −1 0 0 0.5 1 1.5 0 −12 x 10 1 ERROR SIN(X) 1 0.5 0 −1 0 0 0.5 1 1.5 0 x 0.5 x Figure 2: Chebyshev polynomial expansion of function f (x) = sin x, x ∈ [0, π]. Function f (x): solid line; Chebyshev expansion: circles. Figures on the left represent the function and its approximation; figures on the right show the error associated with the approximation. Top figures: N = 3; middle figures: N = 5, bottom figures: N = 12. Next, the sine function will be approximated using N = 3, only the terms c0 to c2 are retained in the expansion. Figure 2 also shows the results of this crude approximation. Note that the error is nearly evenly distributed over the approximation range and that its magnitude can be estimated by looking at the magnitude of the first neglected term of the expansion: |c3 | = 1.3732 10−2 . The results for an approximation including 5 terms, i.e. N = 5, are presented in fig. 2. Here again, the error is nearly evenly distributed over the approximation range and that its magnitude can be estimated by looking at the magnitude of the first neglected term of the expansion: |c5 | = 1.0726 10−4 . Finally, the algorithm presented in section 2.3 to evaluated the coefficients of the Chebyshev expansion of the derivative of the function was used to compute the coefficients of the expansion f ′ (x) = cos x. The following coefficients were found: c′0 = 6.0219 10−1 , c′1 = −5.1363 10−1 , c′2 = −1.0355 10−1 , c′3 = 1.3732 10−2 , c′4 = 1.3587 10−3 , c′5 = −1.0726 10−4 , c′6 = −7.0463 10−6 , c′7 = 3.9639 10−7 , c′8 = 1.9500 10−8 , c′9 = −8.5349 10−10 , c′10 = −3.3586 10−11 . Figure 3 shows the exact cosine function and its Chebyshev approximation, together with the error incurred by the 7 approximation for N = 10. Note that the error is closely estimated by the magnitude of the first neglected term of the expansion: |c′10 | = 3.3586 10−11 . −9 1 x 10 0.8 1 0.4 0.8 0.2 ERROR FUNCTION DERIVATIVE 0.6 0.6 0 −0.2 0.4 −0.4 −0.6 0.2 −0.8 0 0 0.5 1 −1 1.5 0 XX 0.5 1 1.5 XX Figure 3: Chebyshev polynomial expansion of the derivative of function f (x) = sin x, x ∈ [0, π]. Function f ′ (x): solid line; Chebyshev expansion for N = 12: circles. Figure on the left represents the function and its approximation; figure on the right shows the error associated with the approximation. 2.6 Clenshaw-Curtis quadrature Consider the problem of evaluating the following integral terms of Chebyshev polynomials, Z a b f (x) dx ≈ Z 2n bX a i=0 ci Ti (x) dx = 2n X i=0 Rb a ci Z f (x) dx. To that effect, the function is first expanded in b a 2n b−a X Ti (x) dx = ci 2 i=0 Z +1 Ti (x) dx, (32) −1 where the coefficients ci are found from eqs. (20a) and (20b) or eqs. (22a) and (22b). The integral of the Chebyshev polynomials are evaluated by eq. (16) to find Z b c2 c4 c2n f (x) dx ≈ (b − a) c0 − . (33) − − ··· − 2 3 15 4n − 1 a The error, e, in the evaluation of the integral can be estimated from the last term in the series, e ≈ (b − a) |c2n | . 4n2 − 1 (34) Assume that for a given value of n, the estimate of the integral given by eq. (33) does not satisfy a desired error criterion, say e < ǫ, where the error estimate, e, is given by eq. (34) and ǫ a small number. A larger number of Chebyshev polynomials must then be used to approximate the function, in an attempt to meet the accuracy criterion. If the Chebyshev expansion of the function is performed based on the zeros of Chebyshev polynomials using eqs. (20a) and (20b), the abscissa at which the function will be evaluated are shown in fig. 4 for n = 2k , k = 1, 2, 3, 4, 5. Note that for k = 2, the four abscissa all differ from those for k = 1. In fact, for two arbitrary but different values of k, all abscissa are different. On the other hand, if the Chebyshev expansion of the function is performed based on the extrema of Chebyshev polynomials using eqs. (22a) and (22b), the abscissa at which the function will be evaluated are shown in fig. 5 for n = 2k + 1, k = 1, 2, 3, 4, 5. When using the extrema, the abscissa for n = 2k are a subset of the abscissa for n = 2ℓ where ℓ > k. For instance, when k = 2, the n = 22 + 1 = 5 abscissa are a subset of the n = 23 + 1 = 9 abscissa corresponding to k = 3. Those five abscissa are represented by black circles in figure 5. The Clenshaw-Curtis quadrature scheme based on the extrema of Chebyshev polynomials is well suited for adaptive integration. At stage k of the procedure, the function to be integrated is evaluated at n = 2k + 1 abscissa, and its 8 5 4.5 4.5 4 4 3.5 3.5 POWER OF N POWER OF N 5 3 3 2.5 2.5 2 2 1.5 1.5 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 −1 1 −0.8 −0.6 −0.4 −0.2 x 0 0.2 0.4 0.6 0.8 1 x Figure 4: Abscissa of the Clenshaw-Curtis integration scheme using the zeros of Chebyshev polynomials, for n = 1, 2, 3, 4, 5. Figure 5: Abscissa of the Clenshaw-Curtis integration scheme using the extrema of Chebyshev polynomials, for n = 1, 2, 3, 4, 5. Chebyshev expansion is computed using eqs. (22a) and (22b). Equations (33) and (34) then yield an estimate of the integral and of the error, respectively. If the error satisfies the accuracy criterion, the process stops. If not, stage k + 1 starts and the function is evaluated at n = 2k+1 + 1 abscissa to evaluate its new Chebyshev expansion. Of these n = 2k+1 + 1 evaluations, however, n = 2k + 1 where already performed at stage k, leaving n = 2k new function evaluations to be performed for stage k + 1. At every stage of the computation, all function evaluations are used to obtain the new Chebyshev expansion of the function. The process stops when the accuracy criterion is met. 3 3.1 Chebyshev approximation of functions of two variables Expansion of a function in Chebyshev polynomials Section 2 describes the expansion of arbitrary functions of a single variable in series of Chebyshev polynomials. Clearly, functions of two variables can be similarly expanded in double series of Chebyshev polynomials f (x, y) = M−1 −1 X NX cij Ti (x)Tj (y). (35) i=0 j=0 To find these coefficients given function f (x, y), the above relationship is expressed at x = x̄k , y = ȳℓ , where x̄k and ȳℓ PM−1 PN −1 the zeros of TM (x) and TN (y), respectively, as given by eq. (4). This yields f (x̄k , ȳℓ ) ≈ i=0 j=0 cij Ti (x̄k )Tj (ȳℓ ). Multiplying both sides of this equation by Tp (x̄k )Tq (ȳℓ ) and summing the resulting equations expressed at all zeros of TM (x) and TN (y) leads to "M #" N # M X N M−1 −1 X X X X NX Ti (x̄k )Tp (x̄k ) cij Tj (ȳℓ )Tq (ȳℓ ) . (36) f (x̄k , ȳℓ )Tp (x̄k )Tq (ȳℓ ) = i=0 j=0 k=1 ℓ=1 k=1 ℓ=1 In view of the discrete orthogonality relationship of Chebyshev polynomials, eq. (9), it then follows that c00 M N 1 XX = f (x̄k , ȳℓ ), MN (37a) k=1 ℓ=1 ci0 = M N 2 XX f (x̄k , ȳℓ )Ti (x̄k ), MN (37b) k=1 ℓ=1 c0j = M N 2 XX f (x̄k , ȳℓ )Tj (ȳℓ ), MN (37c) k=1 ℓ=1 cij = M N 4 XX f (x̄k , ȳℓ )Ti (x̄k )Tj (ȳℓ ). MN k=1 ℓ=1 9 (37d) In some cases, function f (x, y) is partially expanded in Chebyshev series. For instance, the function dependency on the y variable is in the form of a Chebyshev expansion, whereas its dependency on the x variable is not, i.e. f (x, y) = N −1 X gj (x)Tj (y). (38) j=0 The coefficients of the complete Chebyshev expansion are found by introducing the above expression into eqs. (37a) and (37d) to find c0j = M 1 X gj (xk ), M (39a) k=1 cij = M 2 X gj (xk )Ti (xk ). M (39b) k=1 3.2 Evaluation of Chebyshev expansions: Clenshaw’s recurrence If the coefficients of the two dimensional Chebyshev expansion are known, the function can be evaluated using eq. (35). However, here again, rather than computing the polynomials then summing all contributions, it is preferable to use Clenshaw’s recurrence defined by eq. (24). To that effect, eq. (35) is rewritten as M−1 −1 M−1 X X NX di (y)Ti (x). (40) cij Tj (y) Ti (x) = f (x, y) = i=0 i=0 j=0 Clenshaw’s recurrence, eq. (24), is first used M times to compute the coefficients di , i = 0, 1, . . . , M − 1. Finally, one more application of Clenshaw’s recurrence yields the desired value of the function. Of course, it is also possible to recast eq. (35) as # " N −1 N −1 M−1 X X X gj (x)Tj (y). (41) cij Ti (x) Tj (y) = f (x, y) = j=0 j=0 i=0 At first, N applications of Clenshaw’s recurrence yield the coefficients gj , j = 0, 1, . . . , N − 1, and one additional step yields the desired function value. Using this second option, Clenshaw’s recurrence, characterized by eqs. (23a) to (23e), is rewritten as yM+1,j = 0, yM,j = 0, (42a) (42b) yM−1,j = cM−1,j − yM+1,j + 2x yM,j , .. . (42c) y1,j = c1,j − y3,j + 2x y2,j , y0,j = c0,j − y2,j + 2x y1,j . (42d) (42e) The coefficients, gj (x), now simply become gj (x) = (c0,j − y2,j ) + y1,j x = y0,j − x y1,j . (43) Clenshaw’s recurrence applied to the coefficients gj (x) then yields the desired function value. 3.3 Derivatives of Chebyshev expansions Consider now a function of two variables and its derivative with respect to x, both expanded in Chebyshev series f (x, y) = M−1 −1 X NX cij Ti (x)Tj (y), and f ′ (x, y) = M−2 −1 X NX c′ij Ti (x)Tj (y), (44) i=0 j=0 i=0 j=0 where the notation (·)′ indicates a derivative with respect to x. What is the relationship between the coefficients of the two expansions, cij and c′ij ? Using the formula for the derivatives of Chebyshev polynomials, eq. (13), the 10 following recurrence is found c′M,j = 0, c′M−1,j c′M−2,j (45a) = 0, .. . (45b) = 2 × (M − 1) cM−1,j + c′M,j , (45c) c′1,j = 2 × 2 c2,j + c′3,j , c′0,j = (2 × 1 c1,j + (45d) c′2,j )/2. (45e) Consider next a function of two variables and its derivative with respect to y, both expanded in Chebyshev series f (x, y) = M−1 −1 X NX cij Ti (x)Tj (y), and f + (x, y) = M−1 −2 X NX c+ ij Ti (x)Tj (y). (46) i=0 j=0 i=0 j=0 where the notation (·)+ indicates a derivative with respect to y. What is the relationship between the coefficients of the two expansions, cij and c+ ij ? Using the formula for the derivatives of Chebyshev polynomials, eq. (13), the following recurrence is found c+ i,N = 0, c+ i,N −1 + ci,N −2 (47a) = 0, .. . (47b) = 2 × (N − 1) ci,N −1 + c+ i,N , + c+ i,1 = 2 × 2 ci,2 + ci,3 , c+ i,0 4 = (2 × 1 ci,1 + c+ i,2 )/2. (47c) (47d) (47e) Chebychev polynomials Chebychev polynomials [1, 2] are defined in the following manner T0 (x) = 1 T1 (x) = x T2 (x) = 2x2 − 1 T3 (x) = 4x3 − 3x T4 (x) = 8x4 − 8x2 + 1 ... Tn+1 (x) = 2xTn (x) − Tn−1 (x). (48) The variable x ∈ [−1, 1]. An explicit formula in terms of transcendental functions is also available: Tn (x) = cos(n arccos x). These polynomials are orthogonal polynomials that form an ideal basis for the approximation of functions. An arbitrary function F (s) can be approximated as F (s) = N X ci Ti−1 (x), (49) i=1 where Ti are the Chebychev polynomials, ci the coefficients of the expansion, N the number of terms in the expansion, and x a non dimensional variable defined as x= 2s − (shi + slo ) . shi − slo (50) slo and shi are the lower and upper bounds defining the range over which the approximation is valid. The physical characteristics of dampers and springs are accurately and efficiently approximated by Chebychev polynomials. For linear springs or dampers, the elastic or viscous force, respectively, is approximated in terms of the stretch or stretch rate, respectively. For torsional springs and dampers, the elastic or viscous moment, respectively, is approximated in terms of the rotational stretch or rotational stretch rate, respectively. 11 4.1 Examples 1. Example 1. Consider the simple example of a linear spring of stiffness constant k, i.e. defined as F = ks. At first, the approximation range is assumed to be between slo = −1 and shi = 1. It then follows from eq. (50) that x = s, and F = ks = kx = 0 × 1 + k × x = 0 × T0 (x) + k × T1 (x). (51) Hence, the representation of this spring is slo = −1, shi = 1, c1 = 0, and c2 = k. The input sequence given below defines a torsional damper for k = 1.2e + 04. The moment-rotational stretch rate is depicted in fig. 6. @DAMPER DEFINITION { @DAMPER NAME { damperRvjTeeter } { @DAMPER TYPE { TORSIONAL } @DAMPER DEFINITION TYPE { CHEBYCHEV } @APPROXIMATION RANGE { -1.0, 1.0 } @CHEBYCHEV COEFFICIENTS { 0.0, 1.2e+04 } } } damperRvjTeeter 4 1.5 x 10 MOMENT [N.m] 1 0.5 0 −0.5 −1 −1.5 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 ANGULAR VELOCITY [rad/sec] Figure 6: Torsional damper with linear moment versus angular velocity characteristics. 2. Example 2. Suppose now that the approximation range of the same spring is defined as slo = −10 and shi = 10. It then follows from eq. (50) that x = s/10 and F = ks = 10kx = 0 × 1 + 10k × x = 0 × T0 (x) + 10k × T1 (x). (52) Hence, the representation of this spring is slo = −10, shi = 10, c1 = 0, and c2 = 10k. The spring constant is k in both cases, but the Chebychev coefficients are different due to the different approximation range. The input sequence given below defines a torsional damper for k = 1.2e + 04. The resulting viscous moment versus angular velocity is depicted in fig. 7. @DAMPER DEFINITION { @DAMPER NAME { damperRvjTeeter } { @DAMPER TYPE { TORSIONAL } @DAMPER DEFINITION TYPE { CHEBYCHEV } @APPROXIMATION RANGE { -10.0, 10.0 } @CHEBYCHEV COEFFICIENTS { 0.0, 1.2e+05 } } } 12 damperRvjTeeter 5 1.5 x 10 MOMENT [N.m] 1 0.5 0 −0.5 −1 −1.5 −10 −8 −6 −4 −2 0 2 4 6 8 10 ANGULAR VELOCITY [rad/sec] Figure 7: Torsional damper with linear moment versus angular velocity characteristics. 3. Example 3. As a more elaborated example, consider a nonlinear spring defined as F (s) = k1 s + k3 s3 with an approximation range slo = −5 and shi = 5. It then follows from eq. (50) that x = s/5, and 1 F = k1 s + k3 s3 = 5k1 x + 125k3 x3 = 5k1 T1 (x) + 125k3 [T3 (x) + 3T1 (x)] . 4 Collecting the coefficients of the various polynomials then yields 3 × 125 125 F = 5k1 + k3 T1 (x) + k3 T3 (x). 4 4 (53) (54) Hence, the representation of this spring is slo = −5, shi = 5, c1 = 0, c2 = 5 k1 + 375/4 k3 , c3 = 0, and c4 = 125/4 k3 . The resulting force versus stretch is depicted in fig. 8 for k1 = 1000 and k3 = 80. @SPRING DEFINITION { @SPRING NAME { SpringTest } { @SPRING TYPE { LINEAR } @SPRING DEFINITION TYPE { CHEBYCHEV } @APPROXIMATION RANGE { -5.0, 5.0 } @CHEBYCHEV COEFFICIENTS { 0.0, 4.25e+04, 0.0, 1.25e+04 } } } 4. Example 4. Consider now a spring whose force-stretch relationship is defined by data points, typically experimental measurements. The data points as shown by symbols in fig. 9. An expansion in terms of 4 Chebychev polynomials [1] is then performed and the resulting approximation is shown in fig. 9. It is important to appropriately chose the number of Chebychev polynomials to be used in the expansion: fig. 10 shows the result of the Chebychev approximation using 48 terms in the expansion. Since the spring characteristics are linearly interpolated between the data points, the expansion produces a set of nearly linear segments between the data points. @SPRING DEFINITION { @SPRING NAME { SpringNew } { @SPRING TYPE { TORSIONAL } @SPRING DEFINITION TYPE { DATA POINTS } @TABLE ENTRIES { @VARIABLE { -4.0e-03 } @FUNCTION VALUE { -5.0 } @VARIABLE { -3.0e-03 } @FUNCTION VALUE { -3.5 } 13 SpringTest 15000 Force FORCES [N] 10000 5000 0 -5000 -10000 -15000 -5 -4 -3 -2 -1 0 1 2 STRETCH [m] 3 4 5 Figure 8: Linear spring with nonlinear force versus stretch characteristics. @VARIABLE @VARIABLE @VARIABLE @VARIABLE @VARIABLE @VARIABLE @VARIABLE } { { { { { { { -2.0e-03 } @FUNCTION VALUE { 0.0 } -1.0e-03 } @FUNCTION VALUE { 2.0 } 0.0e-03 } @FUNCTION VALUE { 2.5 } 1.0e-03 } @FUNCTION VALUE { 2.8 } 2.0e-03 } @FUNCTION VALUE { 2.0 } 3.0e-03 } @FUNCTION VALUE { 2.0 } 4.0e-03 } @FUNCTION VALUE { 2.5 } } @NUMBER OF CHEBYCHEV COEFFICIENTS { 4 } SpringNew SpringNew 3 3 2 2 1 0 MOMENTS [N.m] MOMENTS [N.m] 1 -1 -2 -3 0 -1 -2 -3 -4 -5 -6 -0.004 -4 Moment Data -0.003 -0.002 -0.001 0 0.001 0.002 0.003 -5 -0.004 0.004 ROTATION [rad] Moment Data -0.003 -0.002 -0.001 0 0.001 0.002 0.003 0.004 ROTATION [rad] Figure 9: Torsional spring with nonlinear moment versus rotation characteristics. The symbols indicate the data points, the solid line the Chebychev approximation using 4 Chebychev polynomials. Figure 10: Torsional spring with nonlinear moment versus rotation characteristics. The symbols indicate the data points, the solid line the Chebychev approximation using 48 Chebychev polynomials. 5. Example 5. Since Chebychev polynomials are continuous, they are not well suited for the approximation of functions presenting discontinuities, or very sharp gradients. Consider the data points as shown in fig. 11. An expansion in terms of 4 Chebychev polynomials shows poor correlation with the data points, whereas an expansion with 16 terms, see fig. 12, exhibits the Gibbs phenomenon, violent oscillations of the approximation in the vicinity of the region of the discontinuity. @SPRING DEFINITION { 14 @SPRING NAME { SpringDiscontinuity } { @SPRING TYPE { LINEAR } @SPRING DEFINITION TYPE { DATA POINTS } @TABLE ENTRIES { @VARIABLE { -5.0 } @FUNCTION VALUE { -5.0 } @VARIABLE { -0.25 } @FUNCTION VALUE { -4.0 } @VARIABLE { 0.25 } @FUNCTION VALUE { 4.0 } @VARIABLE { 5.0 } @FUNCTION VALUE { 5.0 } } @NUMBER OF CHEBYCHEV COEFFICIENTS { 4 } } SpringDiscontinuity 6 4 4 2 2 FORCES [N] FORCES [N] SpringDiscontinuity 6 0 -2 -4 -6 -4 -2 0 2 STRETCH [m] -2 -4 Force Data -6 0 Force Data -6 4 6 -6 Figure 11: Linear spring with nonlinear force versus stretch characteristics. The symbols indicate the data points, the solid line the Chebychev approximation using 4 Chebychev polynomials. -4 -2 0 2 STRETCH [m] 4 6 Figure 12: Linear spring with nonlinear force versus stretch characteristics. The symbols indicate the data points, the solid line the Chebychev approximation using 16 Chebychev polynomials. References [1] W.H. Press, B.P. Flannery, S.A. Teutolsky, and W.T. Vetterling. Numerical Recipes. The Art of Scientific Computing. Cambridge University Press, Cambridge, 1990. [2] M. Abramowitz and I.A. Stegun. Handbook of Mathematical Functions. Dover Publications, Inc., New York, 1964. 15