Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Linear Algebra and the C Language/a068

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install and compile this file in your working directory. /* ------------------------------------ */ /* Save as : c00a.c */ /* ------------------------------------ */ #include "v_a.h" #include "dcircle.h" /* ------------------------------------ */ int main(void) { double p[R3*C3] ={ 6, 2, 0, 2, 3, 5}; double **Ap = ca_A_mR( p, i_mR(R3,C2)); double **A = m_circle_A_mR(Ap, i_mR(R4,C4)); int r; clrscrn(); printf(" A homogeneous linear system with as many equations\n"); printf(" as unknowns has a nontrivial solution if and only\n"); printf(" if the determinant of the matrix is zero. \n\n"); printf(" Equation of a circle: \n\n"); printf(" c1(x^2 +y^2) + c2 x + c3 y + c4 = 0\n\n"); printf(" The same equation with the values of the three points:\n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) printf(" c1(x%d^2+y%d^2)" " + c2 x%d + c3 y%d + c4 = 0\n",r,r,r,r); printf(" The four equation:\n\n"); printf(" c1(x^2 + y^2) + c2 x + c3 y + c4 = 0\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) printf(" c1(x%d^2+y%d^2)" " + c2 x%d + c3 y%d + c4 = 0\n",r,r,r,r); stop(); clrscrn(); printf(" The three points:\n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) printf(" P%d(%+.0f,%+.0f)",r,Ap[r][C1],Ap[r][C2]); printf("\n\nCofactor expansion along the first row\n\n"); printf(" x^2+y^2 x y 1"); p_Det_mR(A,6,0); printf(" The equation of the circle : \n\n"); printf(" %+.0f(x^2+y^2) %+.0f x %+.0f y %+.0f = 0\n\n", cofactor_R(A,R1,C1), cofactor_R(A,R1,C2), cofactor_R(A,R1,C3), cofactor_R(A,R1,C4)); printf(" Verify the result : \n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) verify_eq_circle_mR(A, Ap[r][C1], Ap[r][C2]); stop(); f_mR(A); f_mR(Ap); return 0; } /* --------------------------------- */ /* --------------------------------- */ Screen output example: A homogeneous linear system with as many equations as unknowns has a nontrivial solution if and only if the determinant of the matrix is zero. Equation of a circle: c1(x^2 +y^2) + c2 x + c3 y + c4 = 0 The same equation with the values of the three points: c1(x1^2+y1^2) + c2 x1 + c3 y1 + c4 = 0 c1(x2^2+y2^2) + c2 x2 + c3 y2 + c4 = 0 c1(x3^2+y3^2) + c2 x3 + c3 y3 + c4 = 0 The four equation: c1(x^2 + y^2) + c2 x + c3 y + c4 = 0 c1(x1^2+y1^2) + c2 x1 + c3 y1 + c4 = 0 c1(x2^2+y2^2) + c2 x2 + c3 y2 + c4 = 0 c1(x3^2+y3^2) + c2 x3 + c3 y3 + c4 = 0 Press return to continue. The three points: P1(+6,+2) P2(+0,+2) P3(+3,+5) Cofactor expansion along the first row x^2+y^2 x y 1 +40 +6 +2 +1 +4 +0 +2 +1 +34 +3 +5 +1 The equation of the circle : -18(x^2+y^2) +108 x +72 y -72 = 0 Verify the result : With x= +6.0 y= +2.0 eq=+0.00000 With x= +0.0 y= +2.0 eq=+0.00000 With x= +3.0 y= +5.0 eq=+0.00000 Press return to continue.