Dear Physics 102 class, On the course website you can download five files: jacobi.c the subroutine for diagonalizing a matrix nrutil.c a file containing some utilities used by jacobi.c nrutil.h a header file for nrutil.c jacobi_test.c the main module which reads in the matrix and calls jacobi.c input.txt sample input file Here's how to use them: First, download the files. Next, compile the different pieces: gcc -o jacobi_test.o -c jacobi_test.c gcc -o jacobi.o -c jacobi.c gcc -o nrutil.o -c nrutil.c The '-o' tells the compiler to create object files with the indicated names. Then put everything together: gcc -o jacobi_test jacobi_test.o jacobi.o nrutil.o -lm Then run the program, which is called jacobi_test (again, the '-o' told the compiler to give it this special name instead of the default 'a.out') jacobi_test You can either input stuff from the screen: first the dimension of the matrix, then the entries in each row, with each entry separated by a space and the rows separated by a carriage return, or you can enter the same information into a file, and then tell the program to look in the file for the input via the command '< input.txt' jacobi_test < input.txt Here's what should happen: $ jacobi_test dimension of the matrix: 5 enter a 5 x 5 matrix (separated by space): 3 0 1 0 .5 0 4 1 0 .1 1 1 5 .4 .2 0 0 .4 2 1 .5 .1 .2 1 3 eigen problem for matrix A: 3.000 0.000 1.000 0.000 0.500 0.000 4.000 1.000 0.000 0.100 1.000 1.000 5.000 0.400 0.200 0.000 0.000 0.400 2.000 1.000 0.500 0.100 0.200 1.000 3.000 number of Jacobi applied: 49 eigenvalues: 2.523 3.834 5.982 1.280 3.382 eigenvectors: 0.820 -0.391 0.305 0.234 -0.168 0.257 0.689 0.426 0.071 0.523 -0.376 -0.062 0.827 -0.140 -0.388 -0.346 -0.301 0.124 0.804 0.357 -0.030 -0.528 0.162 -0.523 0.648 Your numerical homework over the next few weeks will involve tweaking these programs to look at some aspects of vibrations of crystal lattices.