24 June 2016 2:26:42.630 PM CHEBYSHEV_POLYNOMIAL_PRB FORTRAN77 version Test the CHEBYSHEV_POLYNOMIAL library. CHEBYSHEV_POLYNOMIAL_TEST01: T_PROJECT_COEFFICIENTS_DATA estimates the Chebyshev polynomial coefficients for a function given as data (x,fx). Here, we use fx = f(x) = x^2 for the data. Since T(0,x) = 1 and T(2,x) = 2*x^2 - 1, the correct expansion is f(x) = 1/2 T(0,x) + 0 T(1,x) + 1/2 T(2,x) if our polynomials are based in [-1,+1]. Data interval [A,B] = [ 0.00000 , 1.00000 ] Data ( X, D ): 1: 0.218418 0.477066E-01 2: 0.956318 0.914543 3: 0.829509 0.688086 4: 0.561695 0.315502 5: 0.415307 0.172480 6: 0.661187E-01 0.437169E-02 7: 0.257578 0.663463E-01 8: 0.109957 0.120905E-01 9: 0.438290E-01 0.192098E-02 10: 0.633966 0.401913 11: 0.617272E-01 0.381025E-02 12: 0.449539 0.202085 13: 0.401306 0.161047 14: 0.754673 0.569532 15: 0.797287 0.635666 16: 0.183837E-02 0.337961E-05 17: 0.897504 0.805514 18: 0.350752 0.123027 19: 0.945448E-01 0.893871E-02 20: 0.136169E-01 0.185420E-03 Coefficients of Chebyshev expansion of degree 4. 1: 0.37500000 2: 0.50000000 3: 0.12500000 4: 0.13877788E-15 I X(I) Data(I) Chebyshev(X(I)) 1 0.2184 0.4771E-01 0.4771E-01 2 0.9563 0.9145 0.9145 3 0.8295 0.6881 0.6881 4 0.5617 0.3155 0.3155 5 0.4153 0.1725 0.1725 6 0.6612E-01 0.4372E-02 0.4372E-02 7 0.2576 0.6635E-01 0.6635E-01 8 0.1100 0.1209E-01 0.1209E-01 9 0.4383E-01 0.1921E-02 0.1921E-02 10 0.6340 0.4019 0.4019 11 0.6173E-01 0.3810E-02 0.3810E-02 12 0.4495 0.2021 0.2021 13 0.4013 0.1610 0.1610 14 0.7547 0.5695 0.5695 15 0.7973 0.6357 0.6357 16 0.1838E-02 0.3380E-05 0.3380E-05 17 0.8975 0.8055 0.8055 18 0.3508 0.1230 0.1230 19 0.9454E-01 0.8939E-02 0.8939E-02 20 0.1362E-01 0.1854E-03 0.1854E-03 TEST02 T_POLYNOMIAL_COEFFICIENTS determines coefficients for Chebyshev polynomials T(n,x). T( 0,x) = 1.00000 T( 1,x) = 1.00000 * x T( 2,x) = 2.00000 * x ^ 2 -1.00000 T( 3,x) = 4.00000 * x ^ 3 -3.00000 * x T( 4,x) = 8.00000 * x ^ 4 -8.00000 * x ^ 2 1.00000 T( 5,x) = 16.0000 * x ^ 5 -20.0000 * x ^ 3 5.00000 * x TEST03: T_POLYNOMIAL evaluates Chebyshev polynomials T(n,x). Tabulated Computed N X T(n,x) T(n,x) 0 0.8000 1.00000 1.00000 1 0.8000 0.800000 0.800000 2 0.8000 0.280000 0.280000 3 0.8000 -0.352000 -0.352000 4 0.8000 -0.843200 -0.843200 5 0.8000 -0.997120 -0.997120 6 0.8000 -0.752192 -0.752192 7 0.8000 -0.206387 -0.206387 8 0.8000 0.421972 0.421972 9 0.8000 0.881543 0.881543 10 0.8000 0.988497 0.988497 11 0.8000 0.700051 0.700051 12 0.8000 0.131586 0.131586 TEST04: T_POLYNOMIAL_ZEROS returns zeroes of T(n,x). N X T(n,x) 1 0.0000 1.00000 2 0.7071 1.00000 2 -0.7071 0.800000 3 0.8660 -0.997120 3 0.0000 -0.752192 3 -0.8660 -0.206387 4 0.9239 0.988497 4 0.3827 0.700051 4 -0.3827 0.131586 4 -0.9239 0.00000 5 0.9511 -0.444089E-15 5 0.5878 0.00000 5 0.0000 0.306162E-15 5 -0.5878 -0.777156E-15 5 -0.9511 0.444089E-15 TEST05: T_QUADRATURE_RULE computes the quadrature rule associated with T(n,x); X W 1: -0.974928 0.448799 2: -0.781831 0.448799 3: -0.433884 0.448799 4: 0.219909E-15 0.448799 5: 0.433884 0.448799 6: 0.781831 0.448799 7: 0.974928 0.448799 Use the quadrature rule to estimate: Q = Integral ( -1 <= X <= +1 ) X^E / sqrt ( 1-x^2) dx E Q_Estimate Q_Exact 0 3.14159 3.14159 1 -0.111022E-15 0.00000 2 1.57080 1.57080 3 -0.111022E-15 0.00000 4 1.17810 1.17810 5 0.00000 0.00000 6 0.981748 0.981748 7 0.555112E-16 0.00000 8 0.859029 0.859029 9 0.111022E-15 0.00000 10 0.773126 0.773126 11 0.166533E-15 0.00000 12 0.708699 0.708699 13 0.277556E-15 0.00000 TEST06: As a sanity check, make sure that the projection of: T(i,x) onto T(j,x) is: 0 if i is not equal to j; pi if i = j = 0; pi/2 if i = j =/= 0. Chebyshev expansion coefficients for T( 0,x) 1: 3.1415927 2: 0.77715612E-15 3: -0.55511151E-15 4: -0.22204460E-15 Chebyshev expansion coefficients for T( 1,x) 1: 0.77715612E-15 2: 1.5707963 3: 0.33306691E-15 4: 0.33306691E-15 Chebyshev expansion coefficients for T( 2,x) 1: -0.55511151E-15 2: 0.11102230E-15 3: 1.5707963 4: 0.63837824E-15 Chebyshev expansion coefficients for T( 3,x) 1: -0.22204460E-15 2: 0.33306691E-15 3: 0.61062266E-15 4: 1.5707963 TEST07: T_PROJECT_COEFFICIENTS computes the Chebyshev coefficients of a function defined over [-1,+1]. T_PROJECT_COEFFICIENTS_AB works in [A,B]. Chebyshev coefficients for exp(x) in [-1,+1] 1: 1.2660657 2: 1.1303150 3: 0.27145036 4: 0.43793924E-01 Chebyshev coefficients for exp(x) in [-1,+1] 1: 1.2660659 2: 1.1303182 3: 0.27149534 4: 0.44336839E-01 5: 0.54740412E-02 6: 0.53972788E-03 Chebyshev coefficients for sin(x) in [-1,+1] 1: 0.18503717E-16 2: 0.88010117 3: 0.11102230E-15 4: -0.39126718E-01 5: 0.27755576E-15 6: 0.50252011E-03 Chebyshev coefficients for sin(x) in [-1,+1] 1: 0.27419192 2: 0.76218997 3: -0.21149415 4: -0.25905204E-15 5: -0.91264026E-02 6: -0.43519518E-03 Chebyshev coefficients for sqrt(x) in [0,+1] 1: 0.78192791 2: 0.29746637 3: -0.99045761E-01 4: 0.22521776E-01 5: -0.18175236E-01 6: 0.43465406E-02 TEST08: T_PROJECT_COEFFICIENTS_DATA computes the Chebyshev coefficients of a function defined by data. We are looking for an approximation that is good in [-1,+1]. Begin by using equally spaced points in [-1,+1]. Chebyshev coefficients for exp(x) on [-1,+1] 1: 1.2666688 2: 1.1305248 3: 0.27178537 4: 0.44393903E-01 Chebyshev coefficients for exp(x) on [-1,+1] 1: 1.2660784 2: 1.1303204 3: 0.27151495 4: 0.44338101E-01 5: 0.54759925E-02 6: 0.54239389E-03 Chebyshev coefficients for sin(x) on [-1,+1] 1: 0.14190540E-15 2: 0.88009912 3: 0.19538191E-15 4: -0.39127875E-01 5: 0.35752548E-16 6: 0.50001398E-03 Now sample equally spaced points in [0,+1]. The approximation still applies to the interval [-1,+1]. Chebyshev coefficients for sin(x) on [0,+1] 1: 0.44992630 2: 0.42522113 3: -0.29344840E-01 4: -0.44997777E-02 5: 0.15411011E-03 6: 0.14138949E-04 Chebyshev coefficients for sqrt(x) on [0,+1] 1: 0.62765450 2: 0.43908313 3: -0.99607426E-01 4: 0.46042692E-01 5: -0.26014620E-01 6: 0.14499032E-01 Now random points in [-1,+1]. Chebyshev coefficients for sin(x) on [-1,+1] 1: -0.23032705E-06 2: 0.88010579 3: -0.87670920E-06 4: -0.39122290E-01 5: 0.28707498E-08 6: 0.50329450E-03 TEST09: T_PROJECT_COEFFICIENTS computes the Chebyshev interpolant C(F)(N,X) of a function F(X) defined over [-1,+1]. T_PROJECT_VALUE evaluates that projection. Compute projections of order N to exp(x) over [-1,+1], N Max||F(X)-C(F)(N,X)|| 0 1.718 1 0.3722 2 0.5647E-01 3 0.6657E-02 4 0.6397E-03 5 0.5180E-04 6 0.3620E-05 7 0.2224E-06 8 0.1219E-07 9 0.6027E-09 10 0.2714E-10 TEST10: T_PROJECT_COEFFICIENTS_AB computes the Chebyshev interpolant C(F)(N,X) of a function F(X) defined over [A,B]. T_PROJECT_VALUE_AB evaluates that projection. Compute projections of order N to exp(x) over [ 0.0, 1.5] N Max||F(X)-C(F)(N,X)|| 0 2.365 1 2.598 2 1.966 3 1.556 4 1.241 5 1.032 6 0.8813 7 0.7731 8 0.6925 9 0.6263 10 0.5700 TEST11 U_POLYNOMIAL_COEFFICIENTS determines coefficients for Chebyshev polynomials U(n,x). T( 0,x) = 1.00000 T( 1,x) = 2.00000 * x T( 2,x) = 4.00000 * x ^ 2 -1.00000 T( 3,x) = 8.00000 * x ^ 3 -4.00000 * x T( 4,x) = 16.0000 * x ^ 4 -12.0000 * x ^ 2 1.00000 T( 5,x) = 32.0000 * x ^ 5 -32.0000 * x ^ 3 6.00000 * x TEST12: U_POLYNOMIAL evaluates the Chebyshev polynomials U(n,x). Tabulated Computed N X U(n,x) U(n,x) 0 0.8000 1.00000 1.00000 1 0.8000 1.60000 1.60000 2 0.8000 1.56000 1.56000 3 0.8000 0.896000 0.896000 4 0.8000 -0.126400 -0.126400 5 0.8000 -1.09824 -1.09824 6 0.8000 -1.63078 -1.63078 7 0.8000 -1.51101 -1.51101 8 0.8000 -0.786839 -0.786839 9 0.8000 0.252072 0.252072 10 0.8000 1.19015 1.19015 11 0.8000 1.65217 1.65217 12 0.8000 1.45333 1.45333 TEST13: U_POLYNOMIAL_ZEROS returns zeroes of U(n,x). N X U(n,x) 1 0.0000 2.00000 2 0.5000 1.00000 2 -0.5000 1.60000 3 0.7071 -1.09824 3 0.0000 -1.63078 3 -0.7071 -1.51101 4 0.8090 1.19015 4 0.3090 1.65217 4 -0.3090 1.45333 4 -0.8090 0.00000 5 0.8660 0.133227E-14 5 0.5000 -0.888178E-15 5 0.0000 0.367394E-15 5 -0.5000 -0.177636E-14 5 -0.8660 -0.133227E-14 TEST14: U_QUADRATURE_RULE computes the quadrature rule associated with U(n,x); X W 1: -0.923880 0.575094E-01 2: -0.707107 0.196350 3: -0.382683 0.335190 4: 0.790193E-17 0.392699 5: 0.382683 0.335190 6: 0.707107 0.196350 7: 0.923880 0.575094E-01 Use the quadrature rule to estimate: Q = Integral ( -1 <= X <= +1 ) X^E * sqrt ( 1-x^2) dx E Q_Estimate Q_Exact 0 1.57080 1.57080 1 0.832667E-16 0.00000 2 0.392699 0.392699 3 -0.555112E-16 0.00000 4 0.196350 0.196350 5 -0.138778E-15 0.00000 6 0.122718 0.122718 7 -0.166533E-15 0.00000 8 0.859029E-01 0.859029E-01 9 -0.173472E-15 0.00000 10 0.644272E-01 0.644272E-01 11 -0.173472E-15 0.00000 12 0.506214E-01 0.506214E-01 13 -0.173472E-15 0.00000 TEST15: V_POLYNOMIAL evaluates Chebyshev polynomials V(n,x). Tabulated Computed N X V(n,x) V(n,x) 0 0.8000 1.00000 1.00000 1 0.8000 0.600000 0.600000 2 0.8000 -0.400000E-01 -0.400000E-01 3 0.8000 -0.664000 -0.664000 4 0.8000 -1.02240 -1.02240 5 0.8000 -0.971840 -0.971840 6 0.8000 -0.532544 -0.532544 7 0.8000 0.119770 0.119770 8 0.8000 0.724175 0.724175 9 0.8000 1.03891 1.03891 10 0.8000 0.938082 0.938082 11 0.8000 0.462021 0.462021 12 0.8000 -0.198849 -0.198849 TEST16: W_POLYNOMIAL evaluates Chebyshev polynomials W(n,x). Tabulated Computed N X W(n,x) W(n,x) 0 0.8000 1.00000 1.00000 1 0.8000 2.60000 2.60000 2 0.8000 3.16000 3.16000 3 0.8000 2.45600 2.45600 4 0.8000 0.769600 0.769600 5 0.8000 -1.22464 -1.22464 6 0.8000 -2.72902 -2.72902 7 0.8000 -3.14180 -3.14180 8 0.8000 -2.29785 -2.29785 9 0.8000 -0.534767 -0.534767 10 0.8000 1.44223 1.44223 11 0.8000 2.84233 2.84233 12 0.8000 3.10550 3.10550 TEST17: T_TRIPLE_PRODUCT_INTEGRAL computes the triple integral Tijk = integral ( -1 <= x <= 1 ) T(i,x) T(j,x) T(k,x) / sqrt ( 1-x^2) dx I J K Tijk Tijk computed exact 3 3 4 0.00000 -0.627276E-14 4 2 0 0.00000 -0.460743E-14 3 1 0 0.00000 -0.424660E-14 5 1 2 0.00000 -0.555112E-14 4 3 3 0.00000 -0.627276E-14 2 3 1 0.785398 0.785398 2 1 4 0.00000 -0.391354E-14 6 1 0 0.00000 -0.668909E-14 3 3 0 1.57080 1.57080 3 3 1 0.00000 -0.274780E-14 5 2 4 0.00000 -0.438538E-14 4 3 2 0.00000 -0.321965E-14 2 3 1 0.785398 0.785398 2 2 1 0.00000 -0.177636E-14 5 2 1 0.00000 -0.555112E-14 5 1 1 0.00000 -0.566214E-14 6 3 0 0.00000 -0.402456E-14 5 1 3 0.00000 -0.366374E-14 5 1 4 0.785398 0.785398 5 3 2 0.785398 0.785398 CHEBYSHEV_POLYNOMIAL_PRB Normal end of execution. 24 June 2016 2:26:42.632 PM