02-Mar-2019 21:28:18 r8poly_test MATLAB version Test r8poly. R8_SIGN_TEST R8_SIGN returns the sign of an R8. R8 R8_SIGN(R8) -1.250000 -1.000000 -0.250000 -1.000000 0.000000 1.000000 0.500000 1.000000 9.000000 1.000000 R82POLY2_PRINT_TEST R82POLY2_PRINT prints an R82POLY2, a quadratic polynomial in x and y. Coefficients a, b, c, d, e, f: 1 2 3 4 5 6 p(x,y) = 1 * x^2 + 2 * y^2 + 3 * xy + 4 * x + 5 * y + 6 R82POLY2_TYPE_TEST R82POLY2_TYPE determines the type of a second order equation in two variables. p(x,y) = 9 * x^2 + -4 * y^2 + 0 * xy + -36 * x + -24 * y + -36 Type = 1 The set of solutions forms a hyperbola. p(x,y) = 4 * x^2 + 1 * y^2 + -4 * xy + 3 * x + -4 * y + 1 Type = 2 The set of solutions forms a parabola. p(x,y) = 9 * x^2 + 16 * y^2 + 0 * xy + 36 * x + -32 * y + -92 Type = 3 The set of solutions forms an ellipse. p(x,y) = 1 * x^2 + 1 * y^2 + 0 * xy + -6 * x + -10 * y + 115 Type = 4 The set of solutions forms an imaginary ellipse. (There are no real solutions). p(x,y) = 0 * x^2 + 0 * y^2 + 1 * xy + 3 * x + -1 * y + -3 Type = 5 The set of solutions forms a pair of intersecting lines. p(x,y) = 1 * x^2 + 2 * y^2 + 0 * xy + -2 * x + 16 * y + 33 Type = 6 The set of solutions is a single point. p(x,y) = 0 * x^2 + 1 * y^2 + 0 * xy + 0 * x + -6 * y + 8 Type = 7 The set of solutions form a pair of distinct parallel lines. p(x,y) = 0 * x^2 + 1 * y^2 + 0 * xy + 0 * x + -6 * y + 10 Type = 8 The set of solutions forms a pair of imaginary parallel lines. (There are no real solutions). p(x,y) = 0 * x^2 + 1 * y^2 + 0 * xy + 0 * x + -2 * y + 1 Type = 9 The set of solutions forms a pair of coincident lines. p(x,y) = 0 * x^2 + 0 * y^2 + 0 * xy + 2 * x + -1 * y + 1 Type = 10 The set of solutions forms a single line. p(x,y) = 0 * x^2 + 0 * y^2 + 0 * xy + 0 * x + 0 * y + 0 Type = 11 The set of solutions is all space. p(x,y) = 0 * x^2 + 0 * y^2 + 0 * xy + 0 * x + 0 * y + 1 Type = 12 The set of solutions is empty. R8MAT_INVERSE_3D_TEST R8MAT_INVERSE_3D inverts a 3 by 3 matrix. Matrix A to be inverted: Col: 1 2 3 Row 1 : 1 2 3 2 : 4 5 6 3 : 7 8 0 Inverse matrix B: Col: 1 2 3 Row 1 : -1.77778 0.888889 -0.111111 2 : 1.55556 -0.777778 0.222222 3 : -0.111111 0.222222 -0.111111 Product C = A * B: Col: 1 2 3 Row 1 : 1 -1.11022e-16 0 2 : 5.55112e-16 1 0 3 : 1.77636e-15 -8.88178e-16 1 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 R8POLY_DEGREE_TEST R8POLY_DEGREE determines the degree of an R8POLY. The R8POLY: p(x) = 4.000000 * x^3 + 3.000000 * x^2 + 2.000000 * x + 1.000000 Dimensioned degree = 3, Actual degree = 3 The R8POLY: p(x) = 3.000000 * x^2 + 2.000000 * x + 1.000000 Dimensioned degree = 3, Actual degree = 2 The R8POLY: p(x) = 4.000000 * x^3 + 2.000000 * x + 1.000000 Dimensioned degree = 3, Actual degree = 3 The R8POLY: p(x) = 1.000000 Dimensioned degree = 3, Actual degree = 0 The R8POLY: p(x) = 0 Dimensioned degree = 3, Actual degree = 0 R8POLY_DERIV_TEST R8POLY_DERIV computes the coefficients of the derivative of a polynomial. The initial polynomial p(x) = 1.000000 * x^4 - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 The derivative of order 0 p(x) = 1.000000 * x^4 - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 The derivative of order 1 p(x) = 4.000000 * x^3 - 30.000000 * x^2 + 70.000000 * x - 50.000000 The derivative of order 2 p(x) = 12.000000 * x^2 - 60.000000 * x + 70.000000 The derivative of order 3 p(x) = 24.000000 * x - 60.000000 The derivative of order 4 p(x) = 0 R8POLY_LAGRANGE_COEF_TEST R8POLY_LAGRANGE_COEF returns the coefficients for a Lagrange basis polynomial. Abscissas: 1: 1 2: 2 3: 3 4: 4 5: 5 The Lagrange basis polynomial: p(x) = 0.041667 * x^4 - 0.583333 * x^3 + 2.958333 * x^2 - 6.416667 * x + 5.000000 The Lagrange basis polynomial: p(x) = - 0.166667 * x^4 + 2.166667 * x^3 - 9.833333 * x^2 + 17.833333 * x - 10.000000 The Lagrange basis polynomial: p(x) = 0.250000 * x^4 - 3.000000 * x^3 + 12.250000 * x^2 - 19.500000 * x + 10.000000 The Lagrange basis polynomial: p(x) = - 0.166667 * x^4 + 1.833333 * x^3 - 6.833333 * x^2 + 10.166667 * x - 5.000000 The Lagrange basis polynomial: p(x) = 0.041667 * x^4 - 0.416667 * x^3 + 1.458333 * x^2 - 2.083333 * x + 1.000000 R8POLY_LAGRANGE_0_TEST R8POLY_LAGRANGE_0 evaluates the Lagrange factor W(X) at a point. The number of data points is 5 Abscissas: 1: 0 2: 1 3: 2 4: 3 5: 4 X W(X) 0.000000 0.000000e+00 0.222222 3.224441e+00 0.444444 3.489983e+00 0.666667 2.304527e+00 0.888889 7.207573e-01 1.111111 -5.988247e-01 1.333333 -1.316872e+00 1.555556 -1.356162e+00 1.777778 -8.345611e-01 2.000000 0.000000e+00 2.222222 8.345611e-01 2.444444 1.356162e+00 2.666667 1.316872e+00 2.888889 5.988247e-01 3.111111 -7.207573e-01 3.333333 -2.304527e+00 3.555556 -3.489983e+00 3.777778 -3.224441e+00 4.000000 0.000000e+00 R8POLY_LAGRANGE_1_TEST R8POLY_LAGRANGE_1 evaluates the Lagrange factor W'(X) at a point. The number of data points is 5 Abscissas: 1: 0 2: 1 3: 2 4: 3 5: 4 X W'(X) 0.000000 2.400000e+01 0.222222 6.536199e+00 0.444444 -3.020271e+00 0.666667 -6.864198e+00 0.888889 -6.897729e+00 1.111111 -4.730376e+00 1.333333 -1.679012e+00 1.555556 1.232129e+00 1.777778 3.271453e+00 2.000000 4.000000e+00 2.222222 3.271453e+00 2.444444 1.232129e+00 2.666667 -1.679012e+00 2.888889 -4.730376e+00 3.111111 -6.897729e+00 3.333333 -6.864198e+00 3.555556 -3.020271e+00 3.777778 6.536199e+00 4.000000 2.400000e+01 R8POLY_LAGRANGE_2_TEST R8POLY_LAGRANGE_2 evaluates the Lagrange factor W"(X) at a point. The number of data points is 5 Abscissas: 1: 0 2: 1 3: 2 4: 3 5: 4 X W"(X) 0.000000 -1.000000e+02 0.222222 -5.903978e+01 0.444444 -2.861454e+01 0.666667 -7.407407e+00 0.888889 5.898491e+00 1.111111 1.262003e+01 1.333333 1.407407e+01 1.555556 1.157750e+01 1.777778 6.447188e+00 2.000000 0.000000e+00 2.222222 -6.447188e+00 2.444444 -1.157750e+01 2.666667 -1.407407e+01 2.888889 -1.262003e+01 3.111111 -5.898491e+00 3.333333 7.407407e+00 3.555556 2.861454e+01 3.777778 5.903978e+01 4.000000 1.000000e+02 R8POLY_LAGRANGE_FACTOR_TEST R8POLY_LAGRANGE_FACTOR evaluates the Lagrange factor W(X) at a point. For this test, we use 5 functions. Abscissas: 1: 0 2: 0.8 3: 1.6 4: 2.4 5: 3.2 X W(X) W'(X) 4.500000 131.818050 274.542900 4.000000 39.321600 112.230400 3.500000 5.925150 32.142900 3.000000 -1.108800 2.030400 2.500000 -0.267750 -2.857100 2.000000 0.460800 0.230400 1.500000 -0.160650 1.542900 1.000000 -0.369600 -1.169600 0.500000 0.846450 -2.657100 0.000000 0.000000 9.830400 R8POLY_LAGRANGE_VAL_TEST R8POLY_LAGRANGE_VAL evaluates a Lagrange interpolating polynomial at a point. Number of data points = 5 Abscissas: 1: 0 2: 1 3: 2 4: 3 5: 4 Here are the values of the functions at several points: X L1 L2 L3 L4 L5 0.000000 1.000000 0.000000 -0.000000 0.000000 -0.000000 0.500000 0.273438 1.093750 -0.546875 0.218750 -0.039062 1.000000 -0.000000 1.000000 0.000000 -0.000000 0.000000 1.500000 -0.039062 0.468750 0.703125 -0.156250 0.023438 2.000000 0.000000 -0.000000 1.000000 0.000000 -0.000000 2.500000 0.023438 -0.156250 0.703125 0.468750 -0.039062 3.000000 -0.000000 0.000000 -0.000000 1.000000 0.000000 3.500000 -0.039062 0.218750 -0.546875 1.093750 0.273438 4.000000 0.000000 -0.000000 0.000000 -0.000000 1.000000 And the derivatives: X L'1 L'2 L'3 L'4 L'5 0.000000 -2.083333 4.000000 -3.000000 1.333333 -0.250000 0.500000 -0.916667 0.708333 0.375000 -0.208333 0.041667 1.000000 -0.250000 -0.833333 1.500000 -0.500000 0.083333 1.500000 0.041667 -1.125000 1.125000 -0.041667 0.000000 2.000000 0.083333 -0.666667 0.000000 0.666667 -0.083333 2.500000 0.000000 0.041667 -1.125000 1.125000 -0.041667 3.000000 -0.083333 0.500000 -1.500000 0.833333 0.250000 3.500000 -0.041667 0.208333 -0.375000 -0.708333 0.916667 4.000000 0.250000 -1.333333 3.000000 -4.000000 2.083333 R8POLY_ORDER_TEST R8POLY_ORDER determines the order of an R8POLY. The R8POLY: p(x) = 4.000000 * x^3 + 3.000000 * x^2 + 2.000000 * x + 1.000000 Dimensioned order = 4, Actual order = 4 The R8POLY: p(x) = 3.000000 * x^2 + 2.000000 * x + 1.000000 Dimensioned order = 4, Actual order = 3 The R8POLY: p(x) = 4.000000 * x^3 + 2.000000 * x + 1.000000 Dimensioned order = 4, Actual order = 4 The R8POLY: p(x) = 1.000000 Dimensioned order = 4, Actual order = 1 The R8POLY: p(x) = 0 Dimensioned order = 4, Actual order = 1 R8POLY_PRINT_TEST R8POLY_PRINT prints an R8POLY. The R8POLY: p(x) = 9.000000 * x^5 + 0.780000 * x^4 + 56.000000 * x^2 - 3.400000 * x + 12.000000 The R8POLY: p(x) = 0.780000 * x^4 + 56.000000 * x^2 - 3.400000 * x + 12.000000 The R8POLY: p(x) = 1.000000 * x^5 + 0.780000 * x^4 + 56.000000 * x^2 + 12.000000 The R8POLY: p(x) = 0 R8POLY_SHIFT_TEST R8POLY_SHIFT shifts an R8POLY p(x) to q(z) where z=scale*x+shift. p(x): p(x) = 2.000000 * x^2 - 1.000000 * x + 6.000000 z = scale * x + shift Scale = 2 Shift = 3 q(z): p(x) = 0.500000 * x^2 - 3.500000 * x + 12.000000 Expected q(z): p(x) = 0.500000 * x^2 - 3.500000 * x + 12.000000 R8POLY_VALUE_TEST R8POLY_VALUE evaluates a polynomial at one point. The polynomial coefficients: p(x) = 1.000000 * x^4 - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 I X P(X) 1 0.0000 24 2 0.3333 10.8642 3 0.6667 3.45679 4 1.0000 0 5 1.3333 -0.987654 6 1.6667 -0.691358 7 2.0000 0 8 2.3333 0.493827 9 2.6667 0.493827 10 3.0000 0 11 3.3333 -0.691358 12 3.6667 -0.987654 13 4.0000 0 14 4.3333 3.45679 15 4.6667 10.8642 16 5.0000 24 R8POLY_VALUE_FAST_TEST R8POLY_VALUE_FAST evaluates a polynomial at several points. The polynomial coefficients: p(x) = 1.000000 * x^4 - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 Table of values i, x(i), p(x(i)): 1: 0 24 2: 0.333333 10.8642 3: 0.666667 3.45679 4: 1 0 5: 1.33333 -0.987654 6: 1.66667 -0.691358 7: 2 0 8: 2.33333 0.493827 9: 2.66667 0.493827 10: 3 0 11: 3.33333 -0.691358 12: 3.66667 -0.987654 13: 4 0 14: 4.33333 3.45679 15: 4.66667 10.8642 16: 5 24 R8POLY_VALUE_HORNER_TEST R8POLY_VALUE_HORNER evaluates a polynomial at one point, using Horner's method. The polynomial coefficients: p(x) = 1.000000 * x^4 - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 I X P(X) 1 0.0000 24 2 0.3333 10.8642 3 0.6667 3.45679 4 1.0000 0 5 1.3333 -0.987654 6 1.6667 -0.691358 7 2.0000 0 8 2.3333 0.493827 9 2.6667 0.493827 10 3.0000 0 11 3.3333 -0.691358 12 3.6667 -0.987654 13 4.0000 0 14 4.3333 3.45679 15 4.6667 10.8642 16 5.0000 24 R8POLY_VALUES_HORNER_TEST R8POLY_VALUES_HORNER evaluates a polynomial at a point, using Horner's method. The polynomial: p(x) = 1.000000 * x^4 - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 X, P(X): 1: 0 24 2: 0.333333 10.8642 3: 0.666667 3.45679 4: 1 0 5: 1.33333 -0.987654 6: 1.66667 -0.691358 7: 2 0 8: 2.33333 0.493827 9: 2.66667 0.493827 10: 3 0 11: 3.33333 -0.691358 12: 3.66667 -0.987654 13: 4 0 14: 4.33333 3.45679 15: 4.66667 10.8642 16: 5 24 R8POLY2_EX_TEST R8POLY2_EX finds the extreme value of a parabola determined by three points. Parabolic coefficients: A = 2.000000, B = -4.000000, C = 10.000000 Point 1 : ( 1, 8 ) Point 2 : ( 2, 10 ) Point 3 : ( 3, 16 ) R8POLY2_EX returns XMIN = 1.000000, YMIN = 8.000000 R8POLY2_EX2_TEST R8POLY2_EX2 finds the extreme value of a parabola determined by three points. Parabolic coefficients: A = 2.000000, B = -4.000000, C = 10.000000 Point 1 : ( 1, 8 ) Point 2 : ( 2, 10 ) Point 3 : ( 3, 16 ) R8POLY2_EX2 returns XMIN = 1.000000, YMIN = 8.000000 and A = 2.000000, B = -4.000000, C = 10.000000 R8POLY2_ROOT_TEST R8POLY2_ROOT finds quadratic equation roots. A B C R1 R2 2.000000 -2.000000 -24.000000 4.000000 -3.000000 1.000000 -20.000000 100.000000 10.000000 10.000000 1.000000 -2.000000 10.000000 1.000000 1.000000 R8POLY2_RROOT_TEST R8POLY2_RROOT finds the real parts of quadratic equation roots. A B C R1 R2 2.000000 -2.000000 -24.000000 4.000000 -3.000000 1.000000 -20.000000 100.000000 10.000000 10.000000 1.000000 -2.000000 10.000000 1.000000 1.000000 1.000000 0.000000 1.000000 -0.000000 -0.000000 1.000000 -6.000000 10.000000 3.000000 3.000000 R8POLY2_VAL_TEST R8POLY2_VAL evaluates a parabola given 3 data points. Our parabola will be 2*x^2 + 3 * x + 1. Case 1: 3 distinct data points: -1.000000 0.000000 1.000000 6.000000 3.000000 28.000000 Sampled data: X, Y, Y', Y" 0.000000 1.000000 3.000000 4.000000 1.000000 6.000000 7.000000 4.000000 2.000000 15.000000 11.000000 4.000000 3.000000 28.000000 15.000000 4.000000 Case 2: X1=X2, X3 distinct: -1.000000 0.000000 -1.000000 -1.000000 3.000000 28.000000 Sampled data: X, Y, Y', Y" 0.000000 1.000000 3.000000 4.000000 1.000000 6.000000 7.000000 4.000000 2.000000 15.000000 11.000000 4.000000 3.000000 28.000000 15.000000 4.000000 Case 3: X1=X2=X3: -1.000000 0.000000 -1.000000 -1.000000 -1.000000 4.000000 Sampled data: X, Y, Y', Y" 0.000000 1.000000 3.000000 4.000000 1.000000 6.000000 7.000000 4.000000 2.000000 15.000000 11.000000 4.000000 3.000000 28.000000 15.000000 4.000000 R8POLY2_VAL2_TEST R8POLY2_VAL2 evaluates parabolas through 3 points in a table Our data tables will actually be parabolas: A: 2*x^2 + 3 * x + 1. B: 4*x^2 - 2 * x + 5. 1 2.000000 15.000000 17.000000 2 4.000000 45.000000 61.000000 3 6.000000 91.000000 137.000000 4 8.000000 153.000000 245.000000 5 10.000000 231.000000 385.000000 Interpolated data: LEFT, X, Y1, Y2 1 1.000000 6.000000 7.000000 2 3.000000 28.000000 35.000000 3 5.000000 66.000000 95.000000 3 7.000000 120.000000 187.000000 3 9.000000 190.000000 311.000000 R8POLY3_ROOT_TEST R8POLY3_ROOT finds roots of cubic equations. Polynomial coefficients: A = 1.000000, B = -6.000000, C = 11.000000, D = -6.000000 Roots: 1.000000 3.000000 2.000000 Polynomial coefficients: A = 9.000000, B = -36.000000, C = 54.000000, D = -27.000000 Roots: 1.000000 1.500000 1.500000 Polynomial coefficients: A = 1.000000, B = -5.000000, C = 8.000000, D = -4.000000 Roots: 1.000000 2.000000 2.000000 Polynomial coefficients: A = 1.000000, B = -8.000000, C = 25.000000, D = -26.000000 Roots: 2.000000 3.000000 3.000000 R8POLY4_ROOT_TEST R8POLY4_ROOT finds roots of quartic equations. A = 1.000000 B = -10.000000 C = 35.000000 D = -50.000000 E = 24.000000 Roots: 4.000000 1.000000 3.000000 2.000000 A = 1.000000 B = -5.000000 C = 1.000000 D = 21.000000 E = -18.000000 Roots: 3.000000 3.000000 1.000000 -2.000000 A = 1.000000 B = -22.000000 C = 141.000000 D = -220.000000 E = 100.000000 Roots: 10.000000 10.000000 1.000000 1.000000 A = 1.000000 B = -16.000000 C = 72.000000 D = -128.000000 E = 80.000000 Roots: 10.000000 2.000000 2.000000 2.000000 A = 1.000000 B = -20.000000 C = 150.000000 D = -500.000000 E = 625.000000 Roots: 5.000000 5.000000 5.000000 5.000000 A = 1.000000 B = 2.000000 C = 1.000000 D = 8.000000 E = -12.000000 Roots: -0.000000 -0.000000 1.000000 -3.000000 A = 1.000000 B = 0.000000 C = 13.000000 D = 0.000000 E = 36.000000 Roots: 0.000000 0.000000 0.000000 -0.000000 R8R8_PRINT_TEST R8R8_PRINT prints a pair of R8's with a label. Center : ( 1.23, 7.45 ) ( 1.23, 7.45 ) Focus : ( 1.23457, 7.45679e+06 ) R8VEC_EVEN_TEST R8VEC_EVEN computes N evenly spaced values between XLO and XHI. XLO = 0.000000 XHI = 99.000000 while N = 10 Resulting array: 1: 0 2: 11 3: 22 4: 33 5: 44 6: 55 7: 66 8: 77 9: 88 10: 99 R8VEC_EVEN_SELECT_TEST R8VEC_EVEN_SELECT returns the I-th of N evenly spaced values between XLO and XHI. XLO = 0.000000 XHI = 99.000000 while N = 10 X(2) = 11 X(5) = 44 X(8) = 77 R8VEC_INDICATOR1_TEST R8VEC_INDICATOR1 returns a 1-based indicator vector. The indicator1 vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 R8VEC_IS_DISTINCT_TEST R8VEC_IS_DISTINCT is TRUE if an R8VEC only contains distinct entries. X: 0 1 3 X is distinct X: 1.5 1.6 1.5 X is NOT distinct. X: -1 1 10 X is distinct R8VEC_LINSPACE_TEST For a R8VEC: R8VEC_LINSPACE: evenly spaced points between A and B; r8vec_linspace ( 5, 10, 20 ) 1: 10 2: 12.5 3: 15 4: 17.5 5: 20 R8VEC_PRINT_TEST R8VEC_PRINT prints an R8VEC. The R8VEC: 1: 123.456 2: 5e-06 3: -1e+06 4: 3.14159 R8VEC_TRANSPOSE_PRINT_TEST R8VEC_TRANSPOSE_PRINT prints an R8VEC "tranposed", that is, placing multiple entries on a line. The vector X: 1 2.2 -3.3 4.45 5.678 600 0.0078 8.123 9.45 10.03 11.1 12.99 ROOTS_TO_R8POLY_TEST: ROOTS_TO_R8POLY is given N real roots, and constructs the coefficient vector of the corresponding polynomial. N real roots: 1: 1 2: -4 3: 3 4: 0 5: 3 Corresponding polynomial: p(x) = 1.000000 * x^5 - 3.000000 * x^4 - 13.000000 * x^3 + 51.000000 * x^2 - 36.000000 * x r8poly_test Normal end of execution. 02-Mar-2019 21:28:18