/********************************************************** * Test program for cubature over triangles using 3-point * * Newton-Cotes and Romberg-Richardson extrapolation * * ------------------------------------------------------- * * SAMPLE RUN: * * (Integrate function f(x,y)=xy in triangle defined by * * 3 points (0, 0), (10, 0) and (0, 10) ). * * * * -------------------------------------------------- * * # Newton- Error Value Error * * Cotes Code Integral Estimation * * -------------------------------------------------- * * 1 0 3750.000000 0.00000e+000 * * 2 0 -138.888889 -9.72222e+002 * * 3 0 379.629630 3.24074e+001 * * 4 0 412.551440 5.14403e-001 * * 5 0 416.166384 1.41209e-002 * * 6 0 416.604559 4.27905e-004 * * 7 0 416.658917 1.32708e-005 * * -------------------------------------------------- * * * * ------------------------------------------------------- * * Reference: * * "Numerical Algorithms with C, By Gisela Engeln-Muellges * * and Frank Uhlig, Springer-Verlag, 1996" [BIBLI 11]. * * * * C++ Release 1.0 By J-P Moreau, Paris. * * (www.jpmoreau.fr) * *********************************************************** Note: to link with files: basis_r.cpp, kubnec.cpp, vmblock.cpp and f_beisp.cpp. -------------------------------------------------------- */ #include // For REAL, etc. //header of function called (see kubnec.cpp) int Kub3RoRi ( REAL Px, REAL Py, //1st triangle summit REAL Qx, REAL Qy, //2nd " " REAL Rx, REAL Ry, //3rd " " int n, //number of integration points REAL f (REAL,REAL), //function f(x,y) to integrate REAL* Wert, //approximation of the double integral REAL* FehlerSch //error estimation ); void main (void) { REAL W, F; int i, j; REAL xmaly (REAL, REAL); // from F_Beisp.cpp printf("\n"); printf("--------------------------------------------------\n"); printf(" # Newton- Error Value Error \n"); printf(" Cotes Code Integral Estimation \n"); printf("--------------------------------------------------\n"); for (j = 1; j <= 7; j++) { // Px, Py, Qx, Qy, Rx, Ry i = Kub3RoRi ( ZERO, ZERO, TEN, ZERO, ZERO, TEN, j, xmaly, // from F_Beisp.cpp &W, &F); printf (" %2d %2d ", j, i); printf (" %12.6f %13.5e\n", W, F); } printf("--------------------------------------------------\n"); return; } //end of file tk3nec.cpp