10 January 2014 01:50:56 PM BERNSTEIN_POLYNOMIAL_PRB C++ version Test the BERNSTEIN_POLYNOMIAL library. TEST01: BERNSTEIN_POLY_01 evaluates the Bernstein polynomials based on the interval [0,1]. BERNSTEIN_POLY_01_VALUES returns some exact values. 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 TEST02 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 TEST03: 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 TEST04 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 TEST05 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 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 TEST06 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_POLYNOMIAL_PRB Normal end of execution. 10 January 2014 01:50:56 PM