Term paper

239 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
239
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Term paper

  1. 1. PAPER – CAP643  Submitted To: -  Submitted By: Abhishek Kumar Mrs. Kavisha Mam ~1~ Roll No: - 1207B333 Reg No: - 11210885 Course: - MCA 3rd Sem. Section: D1207
  2. 2. ACKNOWLEDGEMENT The experience that we have gathered during this Design Problem has been unique .For this we are pleased to express our deepest sense of gratitude and regards to our respected teacher Mrs. Kavisha Mam for their guidance, inspiration and constructive suggestions that helps us in the preparation of the design problem. I am also thankful to my classmate constant encouragement and support. 2
  3. 3. INDEX SL. NO. 1 2 3 4 5 6 7 CONTENTS Introduction Abstract Operation on Jacobi Method Comparison with other linear equation Implementation of Jacobi Method in C Advantages Disadvantages 3 PAGE NO. 4 4-6 6-9 9-12 13-14 15 15
  4. 4. INTRODUCTION Gauss Jacobi method is the first iterative method used to solve linear system of equations. This project explains you how to solve the linear equation using Gauss Jacobi iterative method Abstract:This paper is concerned with the application of preconditioning techniques to the well-known Jacobi iterative method for solving the finite difference equations derived from the discretization of self-ad joint elliptic partial differential equations. The convergence properties of this one parameter preconditioned method are analyzed and the value of the optimum preconditioning parameter and the performance of the method determined for a variety of standard problems. Jacobi method involves rewriting equation 1 as follow: X=D-1(L+U)x+D-1b If we express it as an iterative method, we see it takes the form: X(k+1)=Gx(k)+f As a motivational example, we assume start with a linear system like this one: 1 5 9 2 6 1 3 7 2 x1 x2 x3 * 4 = 4 8 3
  5. 5. Let us solve the ith equation for xi : X1 = (4- 2x2-3x3)/1 X2 = (8- 5x1-7x3)/6 X3 = (3- 9x1-x2)/2 We can express this as an iterative method and rewrite it in a matrix format. x1 x2 x3 (k+1) = (k) 1/1 0 0 1/6 0 0 0 0 1/2 1/1 0 0 1/6 0 0 0 0 1/2 0 -5 -9 * * -2 0 -1 4 8 3 5 -3 -7 0 x1 * x2 x3 +
  6. 6. x1 x2 x3 (k+1) = 0 -5/6 -9/2 -1/2 -1/3 0 -7/6 -1/2 0 * x1 x2 + x3 1/4 8/6 3/2 As you see, this takes the form x(k+1)=Gx(k)+f. Let's implement Jacobi's method for this problem. There are some steps which are followed by Gauss Jacobi method to perform certain operation: Step 1 • Find the value of x1 from the first equation by substituting the initial values of other unknowns. • Find the value of x2 from the first equation by substituting the initial values of other unknowns. • Find the value of x3 from the first equation by substituting the initial values of other unknowns. And so on till the value of xn is computed from the nth equation using the initial values of x1, x2,…. xn-1. 6
  7. 7. Step 2 • Find out the value of x1 from the first equation by substituting the values of other unknowns got in the 1st iteration. • Find out the value of x2 from the first equation by substituting the values of other unknowns got in the 1st iteration. • Find out the value of x3 from the first equation by substituting the values of other unknowns got in the 1st iteration. Step 3 • Find out the value of x1 from the first equation by substituting the values of other unknowns got in the 2nd iteration. • Find out the value of x2 from the first equation by substituting the values of other unknowns got in the 2nd iteration. • Find out the value of x3 from the first equation by substituting the values of other unknowns got in the 2nd iteration. 7
  8. 8. Example x1+2x2+3x3 = 4 5x1+ 6x2+7x3 = 8 9x1+x2+2x3 = 3 Sol: As you see the system is diagonal system, therefore the convergence is assured. Since we want the solution correct up to 4 significant digits, therefore the iterative process will terminate as soon as we find the successive iteration do not produce any change at first four significant positions. We rewrite the given system of equations as X1 = (4- 2x2-3x3)/1 X2 = (8- 5x1-7x3)/6 X3 = (3- 9x1-x2)/2 8
  9. 9. We start with initial approximation as X1 = X2 = X3 = 0 Iteration 1: Substituting the initial values in the above equation, we obtain X1 =4.0000 X2 = 1.3333 X3 =1.5000 Iteration 2: Substituting the initial values in the above equation, we obtain X1 = -3.1667 X2 = -3.7500 X3 = -17.1667 Now compare Gauss Jacobi method from other linear equation like Gauss Seidel Method Gauss Seidel Method In Jacobi’s method, even though the new values of unknowns are computed in each iteration, but the values of unknowns in previous iterations are used in the subsequent iterations. That is, although a new value of x1 is computed from the first equation in a current iteration, but it is not used to compute the new values of other unknowns in the current iteration. 9
  10. 10. Note that the new values of the unknown are better than the old values, and should be used in preference to the poorer values Step 1 • Find out the value of x1 from the first equation by substituting the initial values of other unknowns. • Find out the value of x2 from the second equation by substituting current value of x1 and the initial values of other unknowns. • Find out the value of x3 from the first equation by substituting the current value of x1 and x2 initial values. And so on till the value of xn is computed from the nth equation using the initial values of x1, x2,…. xn-1. 10
  11. 11. Now we will solve same equation by Gauss Seidel method and then we will find the basic difference between both the methods. Our equation is: x1+2x2+3x3 = 4 5x1+ 6x2+7x3 = 8 9x1+x2+2x3 = 3 Sol: As you see the system is diagonal system, therefore the convergence is assured. Since we want the solution correct up to 4 significant digits, therefore the iterative process will terminate as soon as we find the successive iteration do not produce any change at first four significant positions. We rewrite the given system of equations as: X1 = (4- 2x2-3x3)/1 X2 = (8- 5x1-7x3)/6 X3 = (3- 9x1-x2)/2 We start with initial approximation as X1 = X2 = X3 = 0 Iteration 1: Substituting X2 = X3 = 0 in the first equation, we Obtain 11
  12. 12. X1 =4.0000 Substituting X1 = 4.0000 X3 = 0 in the second equation, we Obtain X2 = -2.0000 Substituting X1 = 4.0000 X2 = -2.0000 in the third equation, we Obtain X3 =-15.5000 Thus, we obtain X1 =4.0000 X2 = -2.0000 X3 =-15.5000 Iteration2: Now Substituting X2 =-2.0000 X3 = -15.5000 in the first equation, we Obtain X1 =54.5000 Substituting X1 = 54.5000 X3 = -15.5000 in the second equation, we Obtain X2 = -26.0000 Substituting X1 = 54.5000 X2 = -26.0000 in the third equation, we Obtain X3 =-230.7500 Thus, we obtain X1 =54.5000 X2 = -26.0000 X3 =-230.7500 Note: - now you can easily compare with both the output. Then you got different answer in both the iterative method. 12
  13. 13. Implementation of Gauss Jacobi method in C Language:- #include<stdio.h> #include<conio.h> #include<math.h> float fx(float y,float z) { float x; x=(4-2*y-3*z)/1; return x; } float fy(float x,float z) { float y; y=(8-5*x-7*z)/6; return y; } float fz(float x,float y) { 13
  14. 14. float z; z=(3-9*x-y)/2; return z; } void main() { float x=0,y=0,z=0,tx,ty,tz; int i,n; clrscr(); printf("Enter the number of iteration:"); scanf("%d",&n); for(i=0;i<n;i++) { tx=fx(y,z); ty=fy(x,z); tz=fz(x,y); x=tx; y=ty; z=tz; } printf("X=%fn",x); printf("Y=%fn",y); printf("Z=%f",z); getch(); } 14
  15. 15. Advantages and disadvantages Advantages: 1. Iterative. The Jacobi method first generates inexact results and subsequently refines its results at each iteration, with the residuals converging at an exponential rate. For many applications, this is highly desirable. Disadvantages: 1. Inflexible. The Jacobi method only works on matrices A for which ρ(A) < 1, or || A|| < 1holds. This makes it inapplicable to a large set of problems. Furthermore, determining whether a matrix satisfies the previous conditions is expensive to compute. 2. Large Set-Up Time. The Jacobi method cannot immediately begin producing results. Before it can begin its iteration, a matrix −D −1(L+U) must be computed. For large input matrices, this may not be a trivial operation, as it takes O(n2) time to perform this matrix multiplication. The result is a significant lag before any results can be output. 15

×