1 / 116

Computation as a third pillar of science

Computational Methods and Programming M.Sc. II, Sem -IV Under Academic Flexibility (Credit) Scheme. Computation. Computation as a third pillar of science. Theory. Observation/ Experiment. Traditional view. Modern view. What are we going to study ?. Ordinary Differential equations

ullery
Télécharger la présentation

Computation as a third pillar of science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computational Methods and ProgrammingM.Sc. II, Sem-IV Under Academic Flexibility (Credit) Scheme

  2. Computation Computation as a third pillar of science Theory Observation/ Experiment Traditional view Modern view

  3. What are we going to study ? • Ordinary Differential equations • Partial Differential Equations • Matrix Algebra • Monte Carlo Methods and Simulations

  4. 1. Ordinary Differential Equations • Types of differential equations • Numerical solutions of ordinary differential equations • Euler method • Applications to non-linear and vector equations • Leap-Frog method • Runge-Kutta method • The predictor corrector method • The intrinsic method

  5. 2. Partial Differential Equations • Types of equations • Elliptic Equations-Laplace’s equations • Hyperbolic Equations-Wave Equation, • Eularian-Lagrangian Methods • Parabolic Equations-Diffusion, • Conservative Methods- • The equation of continuity • Maxwell’s Equations • Dispersion

  6. 3. Matrix Algebra • Types of Matrices • Simple matrix problems • Elliptic equations-Poisson’s equation • System of equation and Matrix inversion • Iterative method- The Jacobi method • Matrix Eigen Value problems- Schrodinger’s Equation

  7. 4. Monte Carlo methods and Simulation • Random number generators • Monte Carlo Integration • The Metropolis Algorithm • The Ising model • Quantum Monte Carlo

  8. Reference Books • 1. Potter D, Computational Physics, Wiley, Chichester, 1973 • 2. Press W H et. al., Numerical Recipes: The Art of Scientific Computing, CUP, Cambridge, 1992 • 3. Wolfrom S, Mathematica- A System For Doing Mathematics By Computer, Addison Wesley, 1991 • 4. Angus McKinnon, Computational Physics - 3rd/4th Year Option, Notes in .pdf format

  9. Some questions on Unit No 3 and 4 • Discuss the types of matrices. • Explain the method of Elimination of unknowns, solve the following equations by the same: • 5x - 3y + 9z = 0.7 • 0.007x + 4.17y + 8.3z = 10.79 • 4x - 3.7y + 0.5z = 0.157 • and explain Write note on Gauss–Seidel Method • Explain Elliptic equations as a Poisson’s equation • State Matrix Eigen Value problems- Schrodinger’s Equation • What is Random number generators? • Write note on Monte-Carlo integration. • What is Metropolis Algorithm ? Explain Ising model in detail. • Write note on Quantum Monte Carlo

  10. Chapter 3 Matrix Algebra Nearly every scientific problem which is solvable on a computer can be represented by matrices. However the ease of solution can depend crucially on the types of matrices involved. There are 3 main classes of problems which we might want to solve: 1. Trivial Algebraic Manipulation such as addition, A + B or multiplication, AB, of matrices. 2. Systems of equations: Ax = b where A and b are known and we have to find x. This also includes the case of finding the inverse, A-1. The standard example of such a problem is Poisson’s equation. 3. Eigenvalue Problems: Ax =  x. This also includes the generalised eigenvalue problem: Ax =  B x. Here we will consider the time–independent Schrodinger equation.

  11. Matrices A matrix is defined as a square or rectangular array of numbers that obeys certain laws. This is a perfectly logical extension of familiar mathematical concepts. Use of Matrix We can write the linear equations given below more elegantly and compactly by collecting the coefficients in a 3×3 square array of numbers called a matrix:

  12. Row matrix A row matrix consists of a single row. For example: Column matrix A column matrix consists of a single column. For example: Rank The rank m of a matrix is the maximal number of linearly independent row vectors it has; with 0 ≤ m ≤ n. As the triple scalar product for above matrix is not zero, they span a non zero volume, are linearly independent, and the homogeneous linear equations have only the trivial solution. In this case, the matrix is said to have rank 3.

  13. Equality Two matrices A=B are defined to be equal if and only if aij =bij for all values of i and j. Example

  14. Special matrices Square matrix Unit matrix Null matrix

  15. Special matrices Square matrix A square matrix is of order m×m. A square matrix is symmetric if . For example: A square matrix is skew-symmetric if . For example:

  16. Special matrices Unit matrix A unit matrix is a diagonal matrix with all elements on the leading diagonal being equal to unity. For example: The product of matrix A and the unit matrix is the matrix A:

  17. Special matrices Null matrix A null matrix is one whose elements are all zero. Notice that But that if we cannot deduce that or

  18. Trace In any square matrix the sum of the diagonal elements is called the trace. For example, Clearly, the trace is a linear operation: trace(A − B) = trace(A) − trace(B).

  19. Matrix addition We also need to add and subtract matrices according to rules that, again, are suggested by and consistent with adding and subtracting linear equations. When we deal with two sets of linear equations in the same unknowns that we can add or subtract, then we add or subtract individual coefficients keeping the unknowns the same. This leads us to the definition A + B = C if and only if aij + bij = cijfor all values of i and j, with the elements combining according to the laws of ordinary algebra (or arithmetic if they are simple numbers). This means that A + B = B + A, commutation.

  20. Two matrices of the same order are said to be conformable for addition or subtraction. • Two matrices of different orders cannot be added or subtracted, e.g., are NOT conformable for addition or subtraction.

  21. Properties Matrices A, B and C are conformable, • A + B = B + A • A + (B +C) = (A + B) +C • l(A + B) = lA + lB, where l is a scalar (commutative law) (associative law) (distributive law)

  22. Matrix subtraction: Example (Scalar multiplication and matrix subtraction) Find (a) 3A, (b) –B, (c) 3A – B Scalar multiplication:

  23. Sol: (a) (b) (c)

  24. Matrix Multiplication We now write linear equations in terms of matrices because their coefficients represent an array of numbers that we just defined as a matrix, The above inhomogeneous equations can be written similarly

  25. Example :(Multiplication of Matrices) Sol:

  26. Properties Matrices A, B and C are conformable, • A(B + C) = AB + AC • (A + B)C = AC + BC • A(BC) = (AB) C However • AB  BA in general • AB = 0 NOT necessarily imply A = 0 orB = 0 • AB = ACNOT necessarily imply B = C

  27. Transpose of a matrix:

  28. Properties of transposes:

  29. MatrixInversion We cannot define division of matrices, but for a square matrix A with nonzero determinant we can find a matrix A−1, called the inverse of A, so that A−1A = AA−1 = I.

  30. Proof: Notes: (1) The inverse of A is denoted by Theorem : (The inverse of a matrix is unique) If B andC are both inverses of the matrix A, thenB = C. Consequently, the inverse of a matrix is unique.

  31. Ans: Note that Example: Show B is the the inverse of matrix A.

  32. Inverse of a 33 matrix Cofactor matrix of A The cofactor for each element of matrix A:

  33. Cofactor matrix of is then given by:

  34. Inverse matrix of is given by:

  35. Simple C Program /* A first C Program*/ #include <stdio.h> void main() {printf("Happy New Year 2014 \n"); }

  36. Matrix multiplication in c language 1 Requirements Design, develop and execute a program in C to read two matrices A (m x n) and B (p x q) and compute the product of A and B if the matrices are compatible for multiplication. The program must print the input matrices and the resultant matrix with suitable headings and format if the matrices are compatible for multiplication, otherwise the program must print a suitable message. (For the purpose of demonstration, the array sizes m, n, p, and q can all be less than or equal to 3) 2 Analysis c[i, j] = a[i,k]  b[k,j]

  37. 3 Design 3.1 Algorithm Start Read matrix A[m,n] Read matrix B[p,q] if n is not equal to p, Print “Matrix Multiplication not possible”. stop Write matrix A[m,n] Write matrix B[p,q] for i = 0 to m-1 for j = 0 to q-1 c[i][j]=0; for k = 0 to n-1 c[i][j] += a[i][k]*b[k][j] write the matrix C[m,n] Stop

  38. 3.2 Flowchart

  39. 4 Code/ program #include <stdio.h> int main() { int m, n, p, q, c, d, k, sum = 0; int first[10][10], second[10][10], multiply[10][10]; printf("Enter the number of rows and columns of first matrix\n"); scanf("%d%d", &m, &n); printf("Enter the elements of first matrix\n"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &first[c][d]); printf("Enter the number of rows and columns of second matrix\n"); scanf("%d%d", &p, &q); if ( n != p ) printf("Matrices with entered orders can't be multiplied with each other.\n"); else { printf("Enter the elements of second matrix\n"); for ( c = 0 ; c < p ; c++ ) for ( d = 0 ; d < q ; d++ ) scanf("%d", &second[c][d]); for ( c = 0 ; c < m ; c++ ) { for ( d = 0 ; d < q ; d++ ) { for ( k = 0 ; k < p ; k++ ) { sum = sum + first[c][k]*second[k][d]; } multiply[c][d] = sum; sum = 0; } } printf("Product of entered matrices:-\n"); for ( c = 0 ; c < m ; c++ ) { for ( d = 0 ; d < q ; d++ ) printf("%d\t", multiply[c][d]); printf("\n"); } } return 0; }

  40. =MINVERSE(A2:C4) =MMULT(array1,array2) =MDETERM(array) =TRANSPOSE(A2:C2)

  41. C code to find inverse of a matrix

  42. C code to find inverse of a matrix Inverse of a 3x3 matrix in c #include<stdio.h> intmain(){ inta[3][3],i,j; floatdeterminant=0; printf("Enter the 9 elements of matrix: "); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&a[i][j]); printf("\nThe matrix is\n"); for(i=0;i<3;i++){ printf("\n"); for(j=0;j<3;j++) printf("%d\t",a[i][j]); } for(i=0;i<3;i++) determinant = determinant + (a[0][i]*(a[1][(i+1)%3]*a[2][(i+2)%3] - a[1][(i+2)%3]*a[2][(i+1)%3])); printf("\nInverse of matrix is: \n\n"); for(i=0;i<3;i++){ for(j=0;j<3;j++) printf("%.2f\t",((a[(i+1)%3][(j+1)%3] * a[(i+2)%3][(j+2)%3]) - (a[(i+1)%3][(j+2)%3]*a[(i+2)%3][(j+1)%3]))/ determinant); printf("\n"); } return0; }

  43. Example Find (a) the eigenvalues and (b) the eigenvectors of the matrix Solution: (a) The eigenvalues: The characteristic equation is which has two roots

  44. (b) The eigenvectors: For  =1 = 6 the system for eigen vectors assumes the form: (A  I) X = 0 i.e. (A  6I) X = 0 Thus x1 = 4x2, and

  45. For  =2 = 1 the system for eigen vectors assumes the form Thus x1 = x2, and

  46. Example Find a matrix S that diagonalizes Solution: We have first to find the eigenvalues and the corresponding eigen- vectors of matrix A. The characteristic equation of A is so that the eigenvalues of A are  = 1 and  = 5.

More Related