3x3 Matrix Solver v0.9
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> May 27, 1998
- 582 views
Below is the aforementioned program I wrote. It solves 3x3 matrices. It will prompt for a through l. Your system must be in the form: ax+by+cz =3D j dx+ey+fz =3D k gx+hy+iz =3D l I need not say these values (a through l) are real numbers. And the solv= er uses Kramer's Rule to solve for une unique soltion. This is version 0.9 because I've tested it, but not at length. Some work= will be done such as: 1. profiling the program 2. setting up a for loop to prompt for a through l 3. displaying a one-screen documentation file 4. making the program's text less cryptic 5. Annotate the program with comments. Note: This program requires Irv's INPUT.E program. If you don't have thi= s very helpful routine, email me or email Irv at mountains at mindspring.com with "send input.e" *without the quotes!* in the subject field. Any questions about the program or other suggestions and critisisms, email me= (through the list is fine). Without further delay, -----33matrix.ex----- include input.e clear_screen() atom a,b,c,d,e,f,g,h,i,j,k,l,I i =3D input("Enter a: ") a =3D i puts(1,"\n") i =3D input("Enter b: ") b =3D i puts(1,"\n") i =3D input("Enter c: ") c =3D i puts(1,"\n") i =3D input("Enter d: ") d =3D i puts(1,"\n") i =3D input("Enter e: ") e =3D i puts(1,"\n") i =3D input("Enter f: ") f =3D i puts(1,"\n") i =3D input("Enter g: ") g =3D i puts(1,"\n") i =3D input("Enter h: ") h =3D i puts(1,"\n") i =3D input("Enter i: ") I =3D i puts(1,"\n") i =3D input("Enter j: ") j =3D i puts(1,"\n") i =3D input("Enter k: ") k =3D i puts(1,"\n") i =3D input("Enter l: ") l =3D i puts(1,"\n") -- atom aa,bb,cc,dd,ee,ff,gg,hh,II,jj,kk,ll aa =3D a bb =3D b cc =3D c dd =3D d ee =3D e ff =3D f gg =3D g hh =3D h II =3D I jj =3D j kk =3D k ll =3D l -- atom M,N,O,P M =3D a*e*I-a*f*h+b*f*g-b*d*I+c*d*h-c*e*g a =3D j d =3D k g =3D l N =3D a*e*I-a*f*h+b*f*g-b*d*I+c*d*h-c*e*g a =3D aa d =3D dd g =3D gg b =3D j e =3D k h =3D l O =3D a*e*I-a*f*h+b*f*g-b*d*I+c*d*h-c*e*g b =3D bb e =3D ee h =3D hh c =3D j f =3D k I =3D l P =3D a*e*I-a*f*h+b*f*g-b*d*I+c*d*h-c*e*g -- atom x,y,z x =3D N/M y =3D O/M z =3D P/M sequence answer answer =3D {x,y,z} print(1,answer) =