Examples - pi.science.math.PICramersRule
1. How to compute system of the three linear equitions ?
Suppose this three linear equitions (Ax=B):
equitions
Use this code for calc solution:
/* degree=3 */ PICramersRule cramersRule = new PICramersRule( 3 ); /* set A side coeficients */ cramersRule.Get_matrixA().AddValues( new int[] { 1, 2, -3, 2, -3, -5, 1, 1, 1 } ); /* set B side */ cramersRule.Get_matrixB().AddValues( new int[] { -9, -8, 4 } ); /* calc */ int i = cramersRule.Calc(); switch ( i ) { case -1: Console.WriteLine( "Some error." ); break; case 0: Console.WriteLine( "System of linear equitions has no solution." ); break; case 1: Console.WriteLine( "Result = " + cramersRule.Get_results().AsString( 0 ) ); break; }
Output:
Result = 2;-1;3
Roots of the three linear equitions are -> x1=2, x2=-1, x3=3.