15 March 2016 10:16:28.119 PM BERNSTEIN_POLYNOMIAL_PRB FORTRAN90 version Test the BERNSTEIN_POLYNOMIAL library. BERNSTEIN_MATRIX_TEST BERNSTEIN_MATRIX returns a matrix A which transforms a polynomial coefficient vector from the power basis to the Bernstein basis. The Bernstein matrix A of order 5x5: Col 1 2 3 4 5 Row 1: 1. -4. 6. -4. 1. 2: 0. 4. -12. 12. -4. 3: 0. 0. 6. -12. 6. 4: 0. 0. 0. 4. -4. 5: 0. 0. 0. 0. 1. BERNSTEIN_MATRIX_TEST2 BERNSTEIN_MATRIX returns a matrix A which transforms a polynomial coefficient vector from the the Bernstein basis to the power basis. We can use this to get explicit values of the 4-th degree Bernstein polynomial coefficients as b(4,K)(X) = C4 * x^4 + C3 * x^3 + C2 * x^2 + C1 * x + C0 * 1 K C4 C3 C2 C1 C0 1 1.00000 0.00000 0.00000 0.00000 0.00000 2 -4.00000 4.00000 0.00000 0.00000 0.00000 3 6.00000 -12.0000 6.00000 0.00000 0.00000 4 -4.00000 12.0000 -12.0000 4.00000 0.00000 5 1.00000 -4.00000 6.00000 -4.00000 1.00000 BERNSTEIN_MATRIX_DETERMINANT_TEST BERNSTEIN_MATRIX_DETERMINANT computes the determinant of the Bernstein matrix A. N ||A|| det(A) computed 5 25.2784 96.0000 6 68.2129 2500.00 7 187.534 162000. 8 522.336 0.264710E+08 9 1468.93 0.110146E+11 10 4161.71 0.117595E+14 11 11860.4 0.324061E+17 12 33962.7 0.231628E+21 13 97640.4 0.431150E+25 14 281650. 0.209706E+30 15 814761. 0.267298E+35 BERNSTEIN_MATRIX_INVERSE_TEST BERNSTEIN_MATRIX_INVERSE computes the inverse of the Bernstein matrix A. N ||A|| ||inv(A)|| ||I-A*inv(A)|| 5 25.2784 3.19613 0.00000 6 68.2129 3.58748 0.00000 7 187.534 3.95127 0.00000 8 522.336 4.29298 0.00000 9 1468.93 4.61646 0.00000 10 4161.71 4.92456 0.00000 11 11860.4 5.21942 0.461511E-14 12 33962.7 5.50273 0.456662E-12 13 97640.4 5.77585 0.148328E-12 14 281650. 6.03988 0.190921E-11 15 814761. 6.29574 0.114347E-11 BERNSTEIN_POLY_01_TEST: BERNSTEIN_POLY_01 evaluates the Bernstein polynomials based on the interval [0,1]. N K X Exact BP01(N,K)(X) 0 0 0.2500 1.00000 1.00000 1 0 0.2500 0.750000 0.750000 1 1 0.2500 0.250000 0.250000 2 0 0.2500 0.562500 0.562500 2 1 0.2500 0.375000 0.375000 2 2 0.2500 0.625000E-01 0.625000E-01 3 0 0.2500 0.421875 0.421875 3 1 0.2500 0.421875 0.421875 3 2 0.2500 0.140625 0.140625 3 3 0.2500 0.156250E-01 0.156250E-01 4 0 0.2500 0.316406 0.316406 4 1 0.2500 0.421875 0.421875 4 2 0.2500 0.210938 0.210938 4 3 0.2500 0.468750E-01 0.468750E-01 4 4 0.2500 0.390625E-02 0.390625E-02 BERNSTEIN_POLY_01_TEST2: BERNSTEIN_POLY_01 evaluates the Bernstein polynomials based on the interval [0,1]. Here we test the partition of unity property. N X Sum ( 0 <= K <= N ) BP01(N,K)(X) 0 0.2184 1.00000 1 0.9563 1.00000 2 0.8295 1.00000 3 0.5617 1.00000 4 0.4153 1.00000 5 0.0661 1.00000 6 0.2576 1.00000 7 0.1100 1.00000 8 0.0438 1.00000 9 0.6340 1.00000 10 0.0617 1.00000 BERNSTEIN_POLY_01_MATRIX_TEST BERNSTEIN_POLY_01_MATRIX is given M data values X, and a degree N, and returns an Mx(N+1) matrix B such that B(i,j) is the j-th Bernstein polynomial evaluated at the. i-th data value. B(5,1+1): Col 1 2 Row 1: 1. 0. 2: 0.750000 0.250000 3: 0.500000 0.500000 4: 0.250000 0.750000 5: 0. 1. B(5,4+1): Col 1 2 3 4 5 Row 1: 1. 0. 0. 0. 0. 2: 0.316406 0.421875 0.210938 0.468750E-01 0.390625E-02 3: 0.625000E-01 0.250000 0.375000 0.250000 0.625000E-01 4: 0.390625E-02 0.468750E-01 0.210938 0.421875 0.316406 5: 0. 0. 0. 0. 1. B(10,4+1): Col 1 2 3 4 5 Row 1: 1. 0. 0. 0. 0. 2: 0.624295 0.312148 0.585277E-01 0.487731E-02 0.152416E-03 3: 0.365950 0.418229 0.179241 0.341411E-01 0.243865E-02 4: 0.197531 0.395062 0.296296 0.987654E-01 0.123457E-01 5: 0.952599E-01 0.304832 0.365798 0.195092 0.390184E-01 6: 0.390184E-01 0.195092 0.365798 0.304832 0.952599E-01 7: 0.123457E-01 0.987654E-01 0.296296 0.395062 0.197531 8: 0.243865E-02 0.341411E-01 0.179241 0.418229 0.365950 9: 0.152416E-03 0.487731E-02 0.585277E-01 0.312148 0.624295 10: 0. 0. 0. 0. 1. B(3,5+1): Col 1 2 3 4 5 Row 1: 1. 0. 0. 0. 0. 2: 0.312500E-01 0.156250 0.312500 0.312500 0.156250 3: 0. 0. 0. 0. 0. Col 6 Row 1: 0. 2: 0.312500E-01 3: 1. BERNSTEIN_POLY_AB_TEST BERNSTEIN_POLY_AB evaluates Bernstein polynomials over an arbitrary interval [A,B]. Here, we demonstrate that BPAB(N,K,A1,B1)(X1) = BEpAB(N,K,A2,B2)(X2) provided only that (X1-A1)/(B1-A1) = (X2-A2)/(B2-A2). N K A B X BEPAB(N,K,A,B)(X) 10 0 0.0000 1.0000 0.3000 0.282475E-01 10 1 0.0000 1.0000 0.3000 0.121061 10 2 0.0000 1.0000 0.3000 0.233474 10 3 0.0000 1.0000 0.3000 0.266828 10 4 0.0000 1.0000 0.3000 0.200121 10 5 0.0000 1.0000 0.3000 0.102919 10 6 0.0000 1.0000 0.3000 0.367569E-01 10 7 0.0000 1.0000 0.3000 0.900169E-02 10 8 0.0000 1.0000 0.3000 0.144670E-02 10 9 0.0000 1.0000 0.3000 0.137781E-03 10 10 0.0000 1.0000 0.3000 0.590490E-05 N K A B X BPAB(N,K,A,B)(X) 10 0 1.0000 2.0000 1.3000 0.282475E-01 10 1 1.0000 2.0000 1.3000 0.121061 10 2 1.0000 2.0000 1.3000 0.233474 10 3 1.0000 2.0000 1.3000 0.266828 10 4 1.0000 2.0000 1.3000 0.200121 10 5 1.0000 2.0000 1.3000 0.102919 10 6 1.0000 2.0000 1.3000 0.367569E-01 10 7 1.0000 2.0000 1.3000 0.900169E-02 10 8 1.0000 2.0000 1.3000 0.144670E-02 10 9 1.0000 2.0000 1.3000 0.137781E-03 10 10 1.0000 2.0000 1.3000 0.590490E-05 N K A B X BPAB(N,K,A,B)(X) 10 0 2.0000 4.0000 2.6000 0.282475E-01 10 1 2.0000 4.0000 2.6000 0.121061 10 2 2.0000 4.0000 2.6000 0.233474 10 3 2.0000 4.0000 2.6000 0.266828 10 4 2.0000 4.0000 2.6000 0.200121 10 5 2.0000 4.0000 2.6000 0.102919 10 6 2.0000 4.0000 2.6000 0.367569E-01 10 7 2.0000 4.0000 2.6000 0.900169E-02 10 8 2.0000 4.0000 2.6000 0.144670E-02 10 9 2.0000 4.0000 2.6000 0.137781E-03 10 10 2.0000 4.0000 2.6000 0.590490E-05 BERNSTEIN_POLY_AB_APPROX_TEST BERNSTEIN_POLY_AB_APPROX evaluates the Bernstein polynomial approximant to a function F(X) over [A,B]. N Max Error 0 0.768177 1 0.420370 2 0.213285 3 0.145598 4 0.110847 5 0.895699E-01 6 0.751733E-01 7 0.647756E-01 8 0.569106E-01 9 0.507517E-01 10 0.457974E-01 11 0.417253E-01 12 0.383189E-01 13 0.354271E-01 14 0.329415E-01 15 0.307819E-01 16 0.288883E-01 17 0.272142E-01 18 0.257236E-01 19 0.243879E-01 20 0.231841E-01 BERNSTEIN_TO_LEGENDRE_TEST: BERNSTEIN_TO_LEGENDRE returns the matrix A which maps polynomial coefficients from Bernstein to Legendre form. A = bernstein_to_legendre(5): Col 1 2 3 4 5 Row 1: 0.166667 0.166667 0.166667 0.166667 0.166667 2: -0.357143 -0.214286 -0.714286E-01 0.714286E-01 0.214286 3: 0.297619 -0.595238E-01 -0.238095 -0.238095 -0.595238E-01 4: -0.138889 0.194444 0.111111 -0.111111 -0.194444 5: 0.357143E-01 -0.107143 0.714286E-01 0.714286E-01 -0.107143 6: -0.396825E-02 0.198413E-01 -0.396825E-01 0.396825E-01 -0.198413E-01 Col 6 Row 1: 0.166667 2: 0.357143 3: 0.297619 4: 0.138889 5: 0.357143E-01 6: 0.396825E-02 B = legendre_to_bernstein(5): Col 1 2 3 4 5 Row 1: 1. -1. 1. -1. 1. 2: 1. -0.600000 -0.200000 1.40000 -3. 3: 1. -0.200000 -0.800000 0.800000 2. 4: 1. 0.200000 -0.800000 -0.800000 2. 5: 1. 0.600000 -0.200000 -1.40000 -3. 6: 1. 1. 1. 1. 1. Col 6 Row 1: -1. 2: 5. 3: -10. 4: 10. 5: -5. 6: 1. ||A*B-I|| = 0.480148E-14 BERNSTEIN_TO_POWER_TEST: BERNSTEIN_TO_POWER returns the matrix A which maps polynomial coefficients from Bernstein to Power form. A = bernstein_to_power(5): Col 1 2 3 4 5 Row 1: 1. 0. 0. 0. 0. 2: -5. 5. 0. 0. 0. 3: 10. -20. 10. 0. 0. 4: -10. 30. -30. 10. 0. 5: 5. -20. 30. -20. 5. 6: -1. 5. -10. 10. -5. Col 6 Row 1: 0. 2: 0. 3: 0. 4: 0. 5: 0. 6: 1. B = power_to_bernstein(5): Col 1 2 3 4 5 Row 1: 1. 0. 0. 0. 0. 2: 1. 0.200000 0. 0. 0. 3: 1. 0.400000 0.100000 0. 0. 4: 1. 0.600000 0.300000 0.100000 0. 5: 1. 0.800000 0.600000 0.400000 0.200000 6: 1. 1. 1. 1. 1. Col 6 Row 1: 0. 2: 0. 3: 0. 4: 0. 5: 0. 6: 1. ||A*B-I|| = 0.00000 BERNSTEIN_VANDERMONDE_TEST BERNSTEIN_VANDERMONDE returns an NxN matrix whose (I,J) entry is the value of the J-th Bernstein polynomial of degree N-1 evaluated at the I-th equally spaced point in [0,1]. Bernstein Vandermonde ( 8 ): Col 1 2 3 4 5 Row 1: 1. 0. 0. 0. 0. 2: 0.339917 0.396569 0.198285 0.550791E-01 0.917985E-02 3: 0.948645E-01 0.265621 0.318745 0.212496 0.849986E-01 4: 0.198945E-01 0.104446 0.235004 0.293755 0.220316 5: 0.265560E-02 0.247856E-01 0.991424E-01 0.220316 0.293755 6: 0.155426E-03 0.271996E-02 0.203997E-01 0.849986E-01 0.212496 7: 0.121427E-05 0.509992E-04 0.917985E-03 0.917985E-02 0.550791E-01 8: 0. 0. 0. 0. 0. Col 6 7 8 Row 1: 0. 0. 0. 2: 0.917985E-03 0.509992E-04 0.121427E-05 3: 0.203997E-01 0.271996E-02 0.155426E-03 4: 0.991424E-01 0.247856E-01 0.265560E-02 5: 0.235004 0.104446 0.198945E-01 6: 0.318745 0.265621 0.948645E-01 7: 0.198285 0.396569 0.339917 8: 0. 0. 1. BERNSTEIN_POLYNOMIAL_PRB Normal end of execution. 15 March 2016 10:16:28.131 PM