04 March 2022 02:45:27 PM BERNSTEIN_POLYNOMIAL_TEST 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. Bernstein matrix A of order 5: Col: 0 1 2 3 4 Row 0: 1 -4 6 -4 1 1: 0 4 -12 12 -4 2: 0 0 6 -12 6 3: 0 0 0 4 -4 4: 0 0 0 0 1 BERNSTEIN_MATRIX_DETERMINANT_TEST BERNSTEIN_MATRIX_DETERMINANT computes the determinant of the Bernstein matrix. 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.25 1 1 1 0 0.25 0.75 0.75 1 1 0.25 0.25 0.25 2 0 0.25 0.5625 0.5625 2 1 0.25 0.375 0.375 2 2 0.25 0.0625 0.0625 3 0 0.25 0.421875 0.421875 3 1 0.25 0.421875 0.421875 3 2 0.25 0.140625 0.140625 3 3 0.25 0.015625 0.015625 4 0 0.25 0.316406 0.316406 4 1 0.25 0.421875 0.421875 4 2 0.25 0.210938 0.210938 4 3 0.25 0.046875 0.046875 4 4 0.25 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.0661187 1 6 0.257578 1 7 0.109957 1 8 0.043829 1 9 0.633966 1 10 0.0617272 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 0 1: 0.75 0.25 2: 0.5 0.5 3: 0.25 0.75 4: 0 1 B(5,4+1): Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0.316406 0.421875 0.210938 0.046875 0.00390625 2: 0.0625 0.25 0.375 0.25 0.0625 3: 0.00390625 0.046875 0.210938 0.421875 0.316406 4: 0 0 0 0 1 B(10,4+1): Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0.624295 0.312148 0.0585277 0.00487731 0.000152416 2: 0.36595 0.418229 0.179241 0.0341411 0.00243865 3: 0.197531 0.395062 0.296296 0.0987654 0.0123457 4: 0.0952599 0.304832 0.365798 0.195092 0.0390184 5: 0.0390184 0.195092 0.365798 0.304832 0.0952599 6: 0.0123457 0.0987654 0.296296 0.395062 0.197531 7: 0.00243865 0.0341411 0.179241 0.418229 0.36595 8: 0.000152416 0.00487731 0.0585277 0.312148 0.624295 9: 0 0 0 0 1 B(3,5+1): Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0.03125 0.15625 0.3125 0.3125 0.15625 2: 0 0 0 0 0 Col: 5 Row 0: 0 1: 0.03125 2: 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) = 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 1 0.3 0.0282475 10 1 0 1 0.3 0.121061 10 2 0 1 0.3 0.233474 10 3 0 1 0.3 0.266828 10 4 0 1 0.3 0.200121 10 5 0 1 0.3 0.102919 10 6 0 1 0.3 0.0367569 10 7 0 1 0.3 0.00900169 10 8 0 1 0.3 0.0014467 10 9 0 1 0.3 0.000137781 10 10 0 1 0.3 5.9049e-06 N K A B X BPAB(N,K,A,B)(X) 10 0 1 2 1.3 0.0282475 10 1 1 2 1.3 0.121061 10 2 1 2 1.3 0.233474 10 3 1 2 1.3 0.266828 10 4 1 2 1.3 0.200121 10 5 1 2 1.3 0.102919 10 6 1 2 1.3 0.0367569 10 7 1 2 1.3 0.00900169 10 8 1 2 1.3 0.0014467 10 9 1 2 1.3 0.000137781 10 10 1 2 1.3 5.9049e-06 N K A B X BPAB(N,K,A,B)(X) 10 0 2 4 2.6 0.0282475 10 1 2 4 2.6 0.121061 10 2 2 4 2.6 0.233474 10 3 2 4 2.6 0.266828 10 4 2 4 2.6 0.200121 10 5 2 4 2.6 0.102919 10 6 2 4 2.6 0.0367569 10 7 2 4 2.6 0.00900169 10 8 2 4 2.6 0.0014467 10 9 2 4 2.6 0.000137781 10 10 2 4 2.6 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.0714286 0.0714286 0.214286 2: 0.297619 -0.0595238 -0.238095 -0.238095 -0.0595238 3: -0.138889 0.194444 0.111111 -0.111111 -0.194444 4: 0.0357143 -0.107143 0.0714286 0.0714286 -0.107143 5: -0.00396825 0.0198413 -0.0396825 0.0396825 -0.0198413 Col: 5 Row 0: 0.166667 1: 0.357143 2: 0.297619 3: 0.138889 4: 0.0357143 5: 0.00396825 B = legendre_to_bernstein(5): Col: 0 1 2 3 4 Row 0: 1 -1 1 -1 1 1: 1 -0.6 -0.2 1.4 -3 2: 1 -0.2 -0.8 0.8 2 3: 1 0.2 -0.8 -0.8 2 4: 1 0.6 -0.2 -1.4 -3 5: 1 1 1 1 1 Col: 5 Row 0: -1 1: 5 2: -10 3: 10 4: -5 5: 1 ||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 -5 10 -10 5 1: 0 0.2 -0.8 1.2 -0.8 2: 0 0 0.1 -0.3 0.3 3: 0 0 0 0.1 -0.2 4: 0 0 0 0 0.2 5: 0 0 0 0 0 Col: 5 Row 0: -1 1: 0.2 2: -0.1 3: 0.1 4: -0.2 5: 1 B = power_to_bernstein(5): Col: 0 1 2 3 4 Row 0: 0 0 0 0 0 1: 0 0 0 0 0 2: 0 0 0 0 0 3: 0 0 0 0 0 4: 1 0.2 0.1 0.1 0.2 5: 0 0 0 0 0 Col: 5 Row 0: 0 1: 0 2: 0 3: 0 4: 1 5: 0 ||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 0 0 0 0 1: 0.339917 0.396569 0.198285 0.0550791 0.00917985 2: 0.0948645 0.265621 0.318745 0.212496 0.0849986 3: 0.0198945 0.104446 0.235004 0.293755 0.220316 4: 0.0026556 0.0247856 0.0991424 0.220316 0.293755 5: 0.000155426 0.00271996 0.0203997 0.0849986 0.212496 6: 1.21427e-06 5.09992e-05 0.000917985 0.00917985 0.0550791 7: 0 0 0 0 0 Col: 5 6 7 Row 0: 0 0 0 1: 0.000917985 5.09992e-05 1.21427e-06 2: 0.0203997 0.00271996 0.000155426 3: 0.0991424 0.0247856 0.0026556 4: 0.235004 0.104446 0.0198945 5: 0.318745 0.265621 0.0948645 6: 0.198285 0.396569 0.339917 7: 0 0 1 BERNSTEIN_POLYNOMIAL_TEST Normal end of execution. 04 March 2022 02:45:27 PM