17 March 2016 09:27:02 AM BERNSTEIN_POLYNOMIAL_PRB C 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: 0 1 2 3 4 Row 0: 1.000000 -4.000000 6.000000 -4.000000 1.000000 1: 0.000000 4.000000 -12.000000 12.000000 -4.000000 2: 0.000000 0.000000 6.000000 -12.000000 6.000000 3: 0.000000 0.000000 0.000000 4.000000 -4.000000 4: 0.000000 0.000000 0.000000 0.000000 1.000000 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 0 1 0 0 0 0 1 -4 4 0 0 0 2 6 -12 6 0 0 3 -4 12 -12 4 0 4 1 -4 6 -4 1 BERNSTEIN_MATRIX_DETERMINANT_TEST BERNSTEIN_MATRIX_DETERMINANT computes the determinant of the Bernstein matrix A. N ||A|| det(A) computed 5 25.2784 96 6 68.2129 2500 7 187.534 162000 8 522.336 2.6471e+07 9 1468.93 1.10146e+10 10 4161.71 1.17595e+13 11 11860.4 3.24061e+16 12 33962.7 2.31628e+20 13 97640.4 4.3115e+24 14 281650 2.09706e+29 15 814761 2.67298e+34 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 6 68.2129 3.58748 0 7 187.534 3.95127 0 8 522.336 4.29298 0 9 1468.93 4.61646 0 10 4161.71 4.92456 0 11 11860.4 5.21942 4.61511e-15 12 33962.7 5.50273 4.56662e-13 13 97640.4 5.77585 1.48328e-13 14 281650 6.03988 1.90921e-12 15 814761 6.29574 1.14347e-12 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.250000 1 1 1 0 0.250000 0.75 0.75 1 1 0.250000 0.25 0.25 2 0 0.250000 0.5625 0.5625 2 1 0.250000 0.375 0.375 2 2 0.250000 0.0625 0.0625 3 0 0.250000 0.421875 0.421875 3 1 0.250000 0.421875 0.421875 3 2 0.250000 0.140625 0.140625 3 3 0.250000 0.015625 0.015625 4 0 0.250000 0.316406 0.316406 4 1 0.250000 0.421875 0.421875 4 2 0.250000 0.210938 0.210938 4 3 0.250000 0.046875 0.046875 4 4 0.250000 0.00390625 0.00390625 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.218418 1 1 0.956318 1 2 0.829509 1 3 0.561695 1 4 0.415307 1 5 0.066119 1 6 0.257578 1 7 0.109957 1 8 0.043829 1 9 0.633966 1 10 0.061727 1 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: 0 1 Row 0: 1.000000 0.000000 1: 0.750000 0.250000 2: 0.500000 0.500000 3: 0.250000 0.750000 4: 0.000000 1.000000 B(5,4+1): Col: 0 1 2 3 4 Row 0: 1.000000 0.000000 0.000000 0.000000 0.000000 1: 0.316406 0.421875 0.210938 0.046875 0.003906 2: 0.062500 0.250000 0.375000 0.250000 0.062500 3: 0.003906 0.046875 0.210938 0.421875 0.316406 4: 0.000000 0.000000 0.000000 0.000000 1.000000 B(10,4+1): Col: 0 1 2 3 4 Row 0: 1.000000 0.000000 0.000000 0.000000 0.000000 1: 0.624295 0.312148 0.058528 0.004877 0.000152 2: 0.365950 0.418229 0.179241 0.034141 0.002439 3: 0.197531 0.395062 0.296296 0.098765 0.012346 4: 0.095260 0.304832 0.365798 0.195092 0.039018 5: 0.039018 0.195092 0.365798 0.304832 0.095260 6: 0.012346 0.098765 0.296296 0.395062 0.197531 7: 0.002439 0.034141 0.179241 0.418229 0.365950 8: 0.000152 0.004877 0.058528 0.312148 0.624295 9: 0.000000 0.000000 0.000000 0.000000 1.000000 B(3,5+1): Col: 0 1 2 3 4 Row 0: 1.000000 0.000000 0.000000 0.000000 0.000000 1: 0.031250 0.156250 0.312500 0.312500 0.156250 2: 0.000000 0.000000 0.000000 0.000000 0.000000 Col: 5 Row 0: 0.000000 1: 0.031250 2: 1.000000 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) = BPAB(N,K,A2,B2)(X2) provided only that (X1-A1)/(B1-A1) = (X2-A2)/(B2-A2). N K A B X BPAB(N,K,A,B)(X) 10 0 0.000000 1.000000 0.300000 0.0282475 10 1 0.000000 1.000000 0.300000 0.121061 10 2 0.000000 1.000000 0.300000 0.233474 10 3 0.000000 1.000000 0.300000 0.266828 10 4 0.000000 1.000000 0.300000 0.200121 10 5 0.000000 1.000000 0.300000 0.102919 10 6 0.000000 1.000000 0.300000 0.0367569 10 7 0.000000 1.000000 0.300000 0.00900169 10 8 0.000000 1.000000 0.300000 0.0014467 10 9 0.000000 1.000000 0.300000 0.000137781 10 10 0.000000 1.000000 0.300000 5.9049e-06 N K A B X BPAB(N,K,A,B)(X) 10 0 1.000000 2.000000 1.300000 0.0282475 10 1 1.000000 2.000000 1.300000 0.121061 10 2 1.000000 2.000000 1.300000 0.233474 10 3 1.000000 2.000000 1.300000 0.266828 10 4 1.000000 2.000000 1.300000 0.200121 10 5 1.000000 2.000000 1.300000 0.102919 10 6 1.000000 2.000000 1.300000 0.0367569 10 7 1.000000 2.000000 1.300000 0.00900169 10 8 1.000000 2.000000 1.300000 0.0014467 10 9 1.000000 2.000000 1.300000 0.000137781 10 10 1.000000 2.000000 1.300000 5.9049e-06 N K A B X BPAB(N,K,A,B)(X) 10 0 2.000000 4.000000 2.600000 0.0282475 10 1 2.000000 4.000000 2.600000 0.121061 10 2 2.000000 4.000000 2.600000 0.233474 10 3 2.000000 4.000000 2.600000 0.266828 10 4 2.000000 4.000000 2.600000 0.200121 10 5 2.000000 4.000000 2.600000 0.102919 10 6 2.000000 4.000000 2.600000 0.0367569 10 7 2.000000 4.000000 2.600000 0.00900169 10 8 2.000000 4.000000 2.600000 0.0014467 10 9 2.000000 4.000000 2.600000 0.000137781 10 10 2.000000 4.000000 2.600000 5.9049e-06 BERNSTEIN_POLY_AB_APPROX_TEST BERNSTEIN_POLY_AB_APPROX evaluates the Bernstein polynomial approximant to a function F(X). N Max Error 0 0.768177 1 0.42037 2 0.213285 3 0.145598 4 0.110847 5 0.0895699 6 0.0751733 7 0.0647756 8 0.0569106 9 0.0507517 10 0.0457974 11 0.0417253 12 0.0383189 13 0.0354271 14 0.0329415 15 0.0307819 16 0.0288883 17 0.0272142 18 0.0257236 19 0.0243879 20 0.0231841 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: 0 1 2 3 4 Row 0: 0.166667 0.166667 0.166667 0.166667 0.166667 1: -0.357143 -0.214286 -0.071429 0.071429 0.214286 2: 0.297619 -0.059524 -0.238095 -0.238095 -0.059524 3: -0.138889 0.194444 0.111111 -0.111111 -0.194444 4: 0.035714 -0.107143 0.071429 0.071429 -0.107143 5: -0.003968 0.019841 -0.039683 0.039683 -0.019841 Col: 5 Row 0: 0.166667 1: 0.357143 2: 0.297619 3: 0.138889 4: 0.035714 5: 0.003968 B = legendre_to_bernstein(5): Col: 0 1 2 3 4 Row 0: 1.000000 -1.000000 1.000000 -1.000000 1.000000 1: 1.000000 -0.600000 -0.200000 1.400000 -3.000000 2: 1.000000 -0.200000 -0.800000 0.800000 2.000000 3: 1.000000 0.200000 -0.800000 -0.800000 2.000000 4: 1.000000 0.600000 -0.200000 -1.400000 -3.000000 5: 1.000000 1.000000 1.000000 1.000000 1.000000 Col: 5 Row 0: -1.000000 1: 5.000000 2: -10.000000 3: 10.000000 4: -5.000000 5: 1.000000 ||A*B-I|| = 4.80148e-15 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: 0 1 2 3 4 Row 0: 1.000000 -5.000000 10.000000 -10.000000 5.000000 1: 0.000000 0.200000 -0.800000 1.200000 -0.800000 2: 0.000000 0.000000 0.100000 -0.300000 0.300000 3: 0.000000 0.000000 0.000000 0.100000 -0.200000 4: 0.000000 0.000000 0.000000 0.000000 0.200000 5: 0.000000 0.000000 0.000000 0.000000 0.000000 Col: 5 Row 0: -1.000000 1: 0.200000 2: -0.100000 3: 0.100000 4: -0.200000 5: 1.000000 B = legendre_to_power(5): Col: 0 1 2 3 4 Row 0: 0.000000 0.000000 0.000000 0.000000 0.000000 1: 0.000000 0.000000 0.000000 0.000000 0.000000 2: 0.000000 0.000000 0.000000 0.000000 0.000000 3: 0.000000 0.000000 0.000000 0.000000 0.000000 4: 1.000000 0.200000 0.100000 0.100000 0.200000 5: 0.000000 0.000000 0.000000 0.000000 0.000000 Col: 5 Row 0: 0.000000 1: 0.000000 2: 0.000000 3: 0.000000 4: 1.000000 5: 0.000000 ||A*B-I|| = 7.10077 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: 0 1 2 3 4 Row 0: 1.000000 0.000000 0.000000 0.000000 0.000000 1: 0.339917 0.396569 0.198285 0.055079 0.009180 2: 0.094865 0.265621 0.318745 0.212496 0.084999 3: 0.019895 0.104446 0.235004 0.293755 0.220316 4: 0.002656 0.024786 0.099142 0.220316 0.293755 5: 0.000155 0.002720 0.020400 0.084999 0.212496 6: 0.000001 0.000051 0.000918 0.009180 0.055079 7: 0.000000 0.000000 0.000000 0.000000 0.000000 Col: 5 6 7 Row 0: 0.000000 0.000000 0.000000 1: 0.000918 0.000051 0.000001 2: 0.020400 0.002720 0.000155 3: 0.099142 0.024786 0.002656 4: 0.235004 0.104446 0.019895 5: 0.318745 0.265621 0.094865 6: 0.198285 0.396569 0.339917 7: 0.000000 0.000000 1.000000 BERNSTEIN_POLYNOMIAL_PRB Normal end of execution. 17 March 2016 09:27:02 AM