From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 75/CH8/EX8.10/ex_10.sce | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 75/CH8/EX8.10/ex_10.sce (limited to '75/CH8/EX8.10') diff --git a/75/CH8/EX8.10/ex_10.sce b/75/CH8/EX8.10/ex_10.sce new file mode 100755 index 000000000..e360f6d20 --- /dev/null +++ b/75/CH8/EX8.10/ex_10.sce @@ -0,0 +1,29 @@ + // EXAMPLE (PG 547) + + // Gauss Jacobi Method + +A = [10 3 1;2 -10 3;1 3 10] // Coefficient Matrix +b = [14 -5 14]' // Right hand matrix + +x = [0 0 0]' // Initial Gauss +d = diag(A) // Diagonal elements of matrix A +a11 = d(1,1) +a22 = d(2,1) +a33 = d(3,1) +D = [a11 0 0;0 a22 0;0 0 a33] // Diagonal matrix of A +[L,U] = lu(A) // L is lower triangular matrix, U is upper triangular matrix +H = -inv(D)*(L+U) +C = inv(D)*b + +for(m=0:6) // Initialising 'for' loop for setting no of iterations to 6 + x = H*x+C; + disp(x) + m=m+1; + x; // Solution + // Rounding off to 4 decimal places + x = x*10^4; + x = int(x); + x = x*10^(-4); + disp(x) // Final Solution + +end \ No newline at end of file -- cgit