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/a07p

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 "dconic.h" /* ------------------------------------ */ int main(void) { double xy[8] ={ 1, 0, 2, 3, 3, 4, 4, 0 }; double **XY = ca_A_mR(xy,i_mR(R4,C2)); double **A = i_mR(R5,C5); double **b = i_mR(R5,C1); double **Ab = i_Abr_Ac_bc_mR(R5,C5,C1); clrscrn(); printf("\n"); printf(" Find the coefficients a, b, c, d, e, of the curve \n\n"); printf(" ax**2 + by**2 + cx + dy + e = 0 \n\n"); printf(" that passes through these four points. \n\n"); printf(" x y"); p_mR(XY,S5,P0,C6); printf("\n"); printf(" Using the given points, we obtain this matrix.\n"); printf(" (a = 1. This is my choice)\n\n"); printf(" x**2 y**2 x y "); i_A_b_with_XY_mR(XY,A,b); c_A_b_Ab_mR(A,b,Ab); p_mR(Ab,S7,P2,C6); stop(); clrscrn(); printf(" The Gauss Jordan process will reduce this matrix to : \n"); gj_TP_mR(Ab); p_mR(Ab,S7,P2,C6); printf(" The coefficients a, b, c, d, e, of the curve are : \n\n"); p_eq_conica_mR(Ab); stop(); clrscrn(); printf(" x y \n"); p_mR(XY,S5,P0,C6); printf("\n"); printf(" Verify the result : \n\n"); verify_XY_mR(Ab,XY[R1][C1],XY[R1][C2]); verify_XY_mR(Ab,XY[R2][C1],XY[R2][C2]); verify_XY_mR(Ab,XY[R3][C1],XY[R3][C2]); verify_XY_mR(Ab,XY[R4][C1],XY[R4][C2]); printf("\n\n\n"); stop(); f_mR(XY); f_mR(A); f_mR(b); f_mR(Ab); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: Find the coefficients a, b, c, d, e, of the curve ax**2 + by**2 + cx + dy + e = 0 that passes through these four points. x y +1 +0 +2 +3 +3 +4 +4 +0 Using the given points, we obtain this matrix. (a = 1. This is my choice) x**2 y**2 x y +1.00 +0.00 +0.00 +0.00 +0.00 +1.00 +1.00 +0.00 +1.00 +0.00 +1.00 +0.00 +4.00 +9.00 +2.00 +3.00 +1.00 +0.00 +9.00 +16.00 +3.00 +4.00 +1.00 +0.00 +16.00 +0.00 +4.00 +0.00 +1.00 +0.00 Press return to continue. The Gauss Jordan process will reduce this matrix to : +1.00 +0.00 +0.00 +0.00 +0.00 +1.00 +0.00 +1.00 +0.00 +0.00 +0.00 -0.17 -0.00 -0.00 +1.00 -0.00 -0.00 -5.00 +0.00 +0.00 +0.00 +1.00 +0.00 +1.17 +0.00 +0.00 +0.00 +0.00 +1.00 +4.00 The coefficients a, b, c, d, e, of the curve are : +1.00x**2 -0.17y**2 -5.00x +1.17y +4.00 = 0 Press return to continue. x y +1 +0 +2 +3 +3 +4 +4 +0 Verify the result : With x = +1.0 and y = +0.0 ax**2 + by**2 + cx+ dy + e = +0.00000 With x = +2.0 and y = +3.0 ax**2 + by**2 + cx+ dy + e = +0.00000 With x = +3.0 and y = +4.0 ax**2 + by**2 + cx+ dy + e = +0.00000 With x = +4.0 and y = +0.0 ax**2 + by**2 + cx+ dy + e = +0.00000 Press return to continue. Copy and paste in Octave: function xy = f (x,y) xy = +1.000000000*x^2 -0.166666667*y^2 -5.000000000*x +1.166666667*y +4.000000000; endfunction f (+1,+0) f (+2,+3) f (+3,+4) f (+4,+0)