03-Feb-2021 09:32:58 triangle_integrals_test: MATLAB/Octave version 9.9.0.1467703 (R2020b) Test triangle_integrals. I4_TO_PASCAL_TEST I4_TO_PASCAL converts a linear index to Pascal triangle indices. K => I J 1 0 0 2 1 0 3 0 1 4 2 0 5 1 1 6 0 2 7 3 0 8 2 1 9 1 2 10 0 3 11 4 0 12 3 1 13 2 2 14 1 3 15 0 4 16 5 0 17 4 1 18 3 2 19 2 3 20 1 4 I4_TO_PASCAL_DEGREE_TEST I4_TO_PASCAL_DEGREE converts a linear index to the degree of the corresponding Pascal triangle indices. K => D 1 0 2 1 3 1 4 2 5 2 6 2 7 3 8 3 9 3 10 3 11 4 12 4 13 4 14 4 15 4 16 5 17 5 18 5 19 5 20 5 PASCAL_TO_I4_TEST PASCAL_TO_I4 converts Pascal triangle indices to a linear index. I J => K 0 0 1 1 0 2 0 1 3 2 0 4 1 1 5 0 2 6 3 0 7 2 1 8 1 2 9 0 3 10 4 0 11 3 1 12 2 2 13 1 3 14 0 4 15 R8MAT_PRINT_TEST R8MAT_PRINT prints an R8MAT. The R8MAT: Col: 1 2 3 4 Row 1 : 11 12 13 14 2 : 21 22 23 24 3 : 31 32 33 34 4 : 41 42 43 44 5 : 51 52 53 54 6 : 61 62 63 64 R8MAT_PRINT_SOME_TEST R8MAT_PRINT_SOME prints some of an R8MAT. The R8MAT, rows 2:4, cols 1:2: Col: 1 2 Row 2 : 21 22 3 : 31 32 4 : 41 42 TRINOMIAL_TEST TRINOMIAL evaluates the trinomial coefficient: T(I,J,K) = (I+J+K)! / I! / J! / K! I J K T(I,J,K) 0 0 0 1 1 0 0 1 2 0 0 1 3 0 0 1 4 0 0 1 0 1 0 1 1 1 0 2 2 1 0 3 3 1 0 4 4 1 0 5 0 2 0 1 1 2 0 3 2 2 0 6 3 2 0 10 4 2 0 15 0 3 0 1 1 3 0 4 2 3 0 10 3 3 0 20 4 3 0 35 0 4 0 1 1 4 0 5 2 4 0 15 3 4 0 35 4 4 0 70 0 0 1 1 1 0 1 2 2 0 1 3 3 0 1 4 4 0 1 5 0 1 1 2 1 1 1 6 2 1 1 12 3 1 1 20 4 1 1 30 0 2 1 3 1 2 1 12 2 2 1 30 3 2 1 60 4 2 1 105 0 3 1 4 1 3 1 20 2 3 1 60 3 3 1 140 4 3 1 280 0 4 1 5 1 4 1 30 2 4 1 105 3 4 1 280 4 4 1 630 0 0 2 1 1 0 2 3 2 0 2 6 3 0 2 10 4 0 2 15 0 1 2 3 1 1 2 12 2 1 2 30 3 1 2 60 4 1 2 105 0 2 2 6 1 2 2 30 2 2 2 90 3 2 2 210 4 2 2 420 0 3 2 10 1 3 2 60 2 3 2 210 3 3 2 560 4 3 2 1260 0 4 2 15 1 4 2 105 2 4 2 420 3 4 2 1260 4 4 2 3150 0 0 3 1 1 0 3 4 2 0 3 10 3 0 3 20 4 0 3 35 0 1 3 4 1 1 3 20 2 1 3 60 3 1 3 140 4 1 3 280 0 2 3 10 1 2 3 60 2 2 3 210 3 2 3 560 4 2 3 1260 0 3 3 20 1 3 3 140 2 3 3 560 3 3 3 1680 4 3 3 4200 0 4 3 35 1 4 3 280 2 4 3 1260 3 4 3 4200 4 4 3 11550 0 0 4 1 1 0 4 5 2 0 4 15 3 0 4 35 4 0 4 70 0 1 4 5 1 1 4 30 2 1 4 105 3 1 4 280 4 1 4 630 0 2 4 15 1 2 4 105 2 2 4 420 3 2 4 1260 4 2 4 3150 0 3 4 35 1 3 4 280 2 3 4 1260 3 3 4 4200 4 3 4 11550 0 4 4 70 1 4 4 630 2 4 4 3150 3 4 4 11550 4 4 4 34650 RS_TO_XY_MAP_TEST: RS_TO_XY_MAP determines the coefficients of the linear map from a the reference in RS coordinates to the physical triangle in XY coordinates: X = a + b * R + c * S Y = d + e * R + f * S XY triangle vertices: Col: 1 2 3 Row 1 : 2 3 0 2 : 0 4 3 Mapping coefficients are: X = 2 + 1 * R + -2 * S Y = 0 + 4 * R + 3 * S Apply map to RS triangle vertices. Recover XY vertices (2,0), (3,4) and (0,3). V(1) = ( 2, 0 ) V(2) = ( 3, 4 ) V(3) = ( 0, 3 ) XY_TO_RS_MAP_TEST: XY_TO_RS_MAP determines the coefficients of the linear map from a general triangle in XY coordinates to the reference triangle in RS coordinates: R = a + b * X + c * Y S = d + e * X + f * Y XY triangle vertices: Col: 1 2 3 Row 1 : 2 3 0 2 : 0 4 3 Mapping coefficients are: R = -0.545455 + 0.272727 * X + 0.181818 * Y S = 0.727273 + -0.363636 * X + 0.0909091 * Y Apply map to XY triangle vertices. Recover RS vertices (0,0), (1,0) and (0,1). V(1) = ( 0, 0 ) V(2) = ( 1, 1.11022e-16 ) V(3) = ( 0, 1 ) POLY_PRINT_TEST: POLY_PRINT can print a D-degree polynomial in X and Y. p1(x,y) = +12.34 p2(x,y) = +1 +2 x +3 y p3(x,y) = xy = +1 xy p4(x,y) = +1 -2.1 x +3.2 y -4.3 x^2 +5.4 xy -6.5 y^2 +7.6 x^3 -8.7 x^2y +9.8 xy^2 -10.9 y^3 POLY_POWER_LINEAR_TEST: POLY_POWER_LINEAR computes the N-th power of a linear polynomial in X and Y. p1(x,y) = +1 +2 x +3 y p1(x,y)^n = +1 +4 x +6 y +4 x^2 +12 xy +9 y^2 Correct answer: p1(x,y)^2 = +1 +4 x +6 y +4 x^2 +12 xy +9 y^2 p1(x,y) = +2 -1 x +3 y p1(x,y)^3 = +8 -12 x +36 y +6 x^2 -36 xy +54 y^2 -1 x^3 +9 x^2y -27 xy^2 +27 y^3 Correct answer: p1(x,y)^n = +8 -12 x +36 y +6 x^2 -36 xy +54 y^2 -1 x^3 +9 x^2y -27 xy^2 +27 y^3 POLY_POWER_TEST: POLY_POWER computes the N-th power of an X,Y polynomial. p1(x,y) = +1 +2 x +3 y p2(x,y) = p1(x,y)^2 = +1 +4 x +6 y +4 x^2 +12 xy +9 y^2 p3(x,y)=correct answer = +1 +4 x +6 y +4 x^2 +12 xy +9 y^2 p1(x,y) = +1 -2 x +3 y -4 x^2 +5 xy -6 y^2 p2(x,y) = p1(x,y)^3 = +1 -6 x +9 y -21 xy +9 y^2 +40 x^3 -96 x^2y +108 xy^2 -81 y^3 +84 x^3y -141 x^2y^2 +171 xy^3 -54 y^4 -96 x^5 +384 x^4y -798 x^3y^2 +1017 x^2y^3 -756 xy^4 +324 y^5 -64 x^6 +240 x^5y -588 x^4y^2 +845 x^3y^3 -882 x^2y^4 +540 xy^5 -216 y^6 p3(x,y)=correct answer = +1 -6 x +9 y -21 xy +9 y^2 +40 x^3 -96 x^2y +108 xy^2 -81 y^3 +84 x^3y -141 x^2y^2 +171 xy^3 -54 y^4 -96 x^5 +384 x^4y -798 x^3y^2 +1017 x^2y^3 -756 xy^4 +324 y^5 -64 x^6 +240 x^5y -588 x^4y^2 +845 x^3y^3 -882 x^2y^4 +540 xy^5 -216 y^6 POLY_PRODUCT_TEST: POLY_PRODUCT computes the product of two X,Y polynomials. p1(x,y) = +1 +2 x +3 y p2(x,y) = +4 +5 x p3(x,y) = p1(x,y) * p2(x,y) = +4 +13 x +12 y +10 x^2 +15 xy Correct answer: p3(x,y)=p1(x,y)*p2(x,y) = +4 +13 x +12 y +10 x^2 +15 xy p1(x,y) = +1 -2 x +3 y -4 x^2 +5 xy -6 y^2 p2(x,y) = +7 +3 x^2 p3(x,y) = p1(x,y) * p2(x,y) = +7 -14 x +21 y -25 x^2 +35 xy -42 y^2 -6 x^3 +9 x^2y -12 x^4 +15 x^3y -18 x^2y^2 Correct answer: p3(x,y)=p1(x,y)*p2(x,y) = +7 -14 x +21 y -25 x^2 +35 xy -42 y^2 -6 x^3 +9 x^2y -12 x^4 +15 x^3y -18 x^2y^2 TRIANGLE01_MONOMIAL_INTEGRAL_TEST TRIANGLE01_MONOMIAL_INTEGRAL returns the integral Q of a monomial X^I Y^J over the interior of the unit triangle. I J Q(I,J) 0 0 0.5 0 1 0.166667 1 0 0.166667 0 2 0.0833333 1 1 0.0416667 2 0 0.0833333 0 3 0.05 1 2 0.0166667 2 1 0.0166667 3 0 0.05 0 4 0.0333333 1 3 0.00833333 2 2 0.00555556 3 1 0.00833333 4 0 0.0333333 0 5 0.0238095 1 4 0.0047619 2 3 0.00238095 3 2 0.00238095 4 1 0.0047619 5 0 0.0238095 TRIANGLE01_POLY_INTEGRAL_TEST TRIANGLE01_POLY_INTEGRAL returns the integral Q of a polynomial P(X,Y) over the interior of the unit triangle. p(x,y) = +1 +2 x +3 y Q = 1.33333 Q (exact) = 1.33333 p(x,y) = +1 xy Q = 0.0416667 Q (exact) = 0.0416667 p(x,y) = +1 -2 x +3 y -4 x^2 +5 xy -6 y^2 Q = 0.0416667 Q (exact) = 0.0416667 TRIANGLE_AREA_TEST: TRIANGLE_AREA determines the (signed) area of a triangle. Triangle vertices are: (X1,Y1) = (0,0) (X2,Y2) = 2*(cos(angle),sin(angle)) (X3,Y3) = (0,1) where angle will sweep from 0 to 360 degrees. I Angle X2 Y2 Area (degrees) 0 0.0000 2.0000 0.0000 1 1 15.0000 1.9319 0.5176 0.965926 2 30.0000 1.7321 1.0000 0.866025 3 45.0000 1.4142 1.4142 0.707107 4 60.0000 1.0000 1.7321 0.5 5 75.0000 0.5176 1.9319 0.258819 6 90.0000 0.0000 2.0000 6.12323e-17 7 105.0000 -0.5176 1.9319 -0.258819 8 120.0000 -1.0000 1.7321 -0.5 9 135.0000 -1.4142 1.4142 -0.707107 10 150.0000 -1.7321 1.0000 -0.866025 11 165.0000 -1.9319 0.5176 -0.965926 12 180.0000 -2.0000 0.0000 -1 13 195.0000 -1.9319 -0.5176 -0.965926 14 210.0000 -1.7321 -1.0000 -0.866025 15 225.0000 -1.4142 -1.4142 -0.707107 16 240.0000 -1.0000 -1.7321 -0.5 17 255.0000 -0.5176 -1.9319 -0.258819 18 270.0000 -0.0000 -2.0000 -1.83697e-16 19 285.0000 0.5176 -1.9319 0.258819 20 300.0000 1.0000 -1.7321 0.5 21 315.0000 1.4142 -1.4142 0.707107 22 330.0000 1.7321 -1.0000 0.866025 23 345.0000 1.9319 -0.5176 0.965926 24 360.0000 2.0000 -0.0000 1 TRIANGLE_XY_INTEGRAL_TEST TRIANGLE_XY_INTEGRAL determines Q, the integral of the monomial X*Y over a triangle (X1,Y1), (X2,Y2), (X3,Y3). (X1,Y1) = ( 0,0 ) (X2,Y2) = ( 1,0 ) (X3,Y3) = ( 1,2 ) Q = 0.5 (Expecting answer 1/2. (X1,Y1) = ( 0,0 ) (X2,Y2) = ( 4,0 ) (X3,Y3) = ( 0,1 ) Q = 0.666667 (Expecting answer 2/3. TRIANGLE_MONOMIAL_INTEGRAL_TEST TRIANGLE_MONOMIAL_INTEGRAL returns the integral Q of a monomial X^I Y^J over the interior of a triangle. Triangle vertices: (X1,Y1) = (0,0) (X2,Y2) = (1,0) (X3,Y3) = (0,1) Integrand = x^1 * y^0 Computed Q = 0.166667 Exact Q = 0.166667 Triangle vertices: (X1,Y1) = (0,0) (X2,Y2) = (1,0) (X3,Y3) = (1,2) Integrand = x^1 * y^1 Computed Q = 0.5 Exact Q = 0.5 Triangle vertices: (X1,Y1) = (-3,0) (X2,Y2) = (6,0) (X3,Y3) = (0,3) Integrand = x^1 * y^0 Computed Q = 13.5 Exact Q = 13.5 Triangle vertices: (X1,Y1) = (0,0) (X2,Y2) = (4,0) (X3,Y3) = (0,1) Integrand = x^1 * y^1 Computed Q = 0.666667 Exact Q = 0.666667 TRIANGLE_POLY_INTEGRAL_TEST TRIANGLE_POLY_INTEGRAL returns the integral Q of a polynomial over the interior of a triangle. Triangle vertices: (X1,Y1) = (0,0) (X2,Y2) = (1,0) (X3,Y3) = (0,1) Integrand p(x,y) = +1 x Computed Q = 0.166667 Exact Q = 0.166667 Triangle vertices: (X1,Y1) = (0,0) (X2,Y2) = (1,0) (X3,Y3) = (1,2) Integrand p(x,y) = +1 xy Computed Q = 0.5 Exact Q = 0.5 Triangle vertices: (X1,Y1) = (0,0) (X2,Y2) = (1,0) (X3,Y3) = (1,3) Integrand p(x,y) = +2 -3 x +1 xy Computed Q = 1.125 Exact Q = 1.125 Triangle vertices: (X1,Y1) = (0,3) (X2,Y2) = (1,1) (X3,Y3) = (5,3) Integrand p(x,y) = -40 y +6 x^2 Computed Q = -311.667 Exact Q = -311.667 triangle_integrals_test: Normal end of execution. 03-Feb-2021 09:32:58