Tue Oct 19 11:24:27 2021 bernstein_polynomial_test(): Python version: 3.6.9 Test bernstein_polynomial(). bernstein_matrix_test(): Python version: 3.6.9 bernstein_matrix() computes the Bernstein matrix. Bernstein matrix: 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_test(): Normal end of execution. bernstein_matrix_test2(): Python version: 3.6.9 bernstein_matrix() returns a matrix 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_test2(): Normal end of execution. bernstein_matrix_determinant_test(): Python version: 3.6.9 bernstein_matrix_determinant() computes the determinant of the Bernstein matrix. N ||A|| det(A) np.linalg.det(A) 5 25.2784 96 96 6 68.2129 2500 2500 7 187.534 162000 162000 8 522.336 2.6471e+07 2.6471e+07 9 1468.93 1.10146e+10 1.10146e+10 10 4161.71 1.17595e+13 1.17595e+13 11 11860.4 3.24061e+16 3.24061e+16 12 33962.7 2.31628e+20 2.31628e+20 13 97640.4 4.3115e+24 4.3115e+24 14 281650 2.09706e+29 2.09706e+29 15 814761 2.67298e+34 2.67298e+34 bernstein_matrix_determinant_test(): Normal end of execution. bernstein_matrix_inverse_test(): Python version: 3.6.9 bernstein_matrix returns a matrix A which transforms a polynomial coefficient vector from the power basis to the Bernstein basis. bernstein_matrix_inverse computes the inverse B. N ||A|| ||B|| ||I-A*B|| 5 25.2784 3.19613 1.24127e-16 6 68.2129 3.58748 9.64681e-16 7 187.534 3.95127 3.44913e-15 8 522.336 4.29298 6.06301e-15 9 1468.93 4.61646 5.92394e-15 10 4161.71 4.92456 7.32685e-14 11 11860.4 5.21942 3.25092e-13 12 33962.7 5.50273 7.09293e-13 13 97640.4 5.77585 2.96066e-12 14 281650 6.03988 4.95726e-12 15 814761 6.29574 2.01491e-11 bernstein_matrix_inverse_test(): Normal end of execution. bernstein_poly_01_test(): Python version: 3.6.9 bernstein_poly_01() evaluates Bernstein polynomials. N K X F F tabulated computed 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.31640625 0.31640625 4 1 0.250000 0.421875 0.421875 4 2 0.250000 0.2109375 0.2109375 4 3 0.250000 0.046875 0.046875 4 4 0.250000 0.00390625 0.00390625 bernstein_poly_01_test(): Normal end of execution. bernstein_poly_01_test2(): Python version: 3.6.9 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.8549 1 1 0.1240 1 2 0.3014 1 3 0.9621 1 4 0.7609 1 5 0.1304 1 6 0.5191 1 7 0.2758 1 8 0.5617 1 9 0.7941 1 10 0.3429 1 bernstein_poly_01_test2(): Normal end of execution. bernstein_poly_01_matrix_test(): Python version: 3.6.9 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_01_matrix_test(): Normal end of execution. bernstein_poly_01_values_test(): Python version: 3.6.9 bernstein_poly_01_values() stores values of Bernstein polynomials. N K X F 0 0 0.250000 1 1 0 0.250000 0.75 1 1 0.250000 0.25 2 0 0.250000 0.5625 2 1 0.250000 0.375 2 2 0.250000 0.0625 3 0 0.250000 0.421875 3 1 0.250000 0.421875 3 2 0.250000 0.140625 3 3 0.250000 0.015625 4 0 0.250000 0.31640625 4 1 0.250000 0.421875 4 2 0.250000 0.2109375 4 3 0.250000 0.046875 4 4 0.250000 0.00390625 bernstein_poly_01_values_test(): Normal end of execution. bernstein_poly_ab_test(): Python version: 3.6.9 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.0000 1.0000 0.3000 0.0282475 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.0367569 10 7 0.0000 1.0000 0.3000 0.00900169 10 8 0.0000 1.0000 0.3000 0.0014467 10 9 0.0000 1.0000 0.3000 0.000137781 10 10 0.0000 1.0000 0.3000 5.9049e-06 N K A B X BPAB(N,K,A,B)(X) 10 0 1.0000 2.0000 1.3000 0.0282475 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.0367569 10 7 1.0000 2.0000 1.3000 0.00900169 10 8 1.0000 2.0000 1.3000 0.0014467 10 9 1.0000 2.0000 1.3000 0.000137781 10 10 1.0000 2.0000 1.3000 5.9049e-06 N K A B X BPAB(N,K,A,B)(X) 10 0 2.0000 4.0000 2.6000 0.0282475 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.0367569 10 7 2.0000 4.0000 2.6000 0.00900169 10 8 2.0000 4.0000 2.6000 0.0014467 10 9 2.0000 4.0000 2.6000 0.000137781 10 10 2.0000 4.0000 2.6000 5.9049e-06 bernstein_poly_ab_test(): Normal end of execution. bernstein_poly_ab_approx_test(): Python version: 3.6.9 bernstein_poly_ab_approx() evaluates the Bernstein polynomial approximant to a function F(X) defined over [A,B]. 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_poly_ab_approx_test(): Normal end of execution. bernstein_to_legendre_test(): Python version: 3.6.9 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.96791e-15 bernstein_to_legendre_test(): Normal end of execution. bernstein_to_power_test(): Python version: 3.6.9 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 0 0 0 0 1 : -5 5 0 0 0 2 : 10 -20 10 0 0 3 : -10 30 -30 10 0 4 : 5 -20 30 -20 5 5 : -1 5 -10 10 -5 Col: 5 Row 0 : 0 1 : 0 2 : 0 3 : 0 4 : 0 5 : 1 B = power_to_bernstein(5): Col: 0 1 2 3 4 Row 0 : 1 0 0 0 0 1 : 1 0.2 0 0 0 2 : 1 0.4 0.1 0 0 3 : 1 0.6 0.3 0.1 0 4 : 1 0.8 0.6 0.4 0.2 5 : 1 1 1 1 1 Col: 5 Row 0 : 0 1 : 0 2 : 0 3 : 0 4 : 0 5 : 1 ||A*B-I|| = 1.35064e-15 bernstein_to_power_test(): Normal end of execution. bernstein_vandermonde_test(): Python version: 3.6.9 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_vandermonde_test(): Normal end of execution. bernstein_polynomial_test(): Normal end of execution. Tue Oct 19 11:24:28 2021