## MATLAB code for Linear Algebra and Probability for Computer Science Applications

### Examples discussed in the text

#### Chapter 1: Matlab

• hailstone.m Hailstone procedure, p. 6.
• p35.m Script to compute x35, p. 6.
• fib.m Recursive definition of Fibonacci numbers, p. 8.
• t1.m Local and global variables, p. 9.

#### Chapter 5: Algorithms

• sampleRandomSings.m sampleRandomSings(n,k) calls testRandomSings(n) k times and find the frequency with which LU decomposition generates a zero vector in the last row and the frequency with which the rank is measured at n-1. See section 5.2.3, p. 122.

#### Chapter 6: Geometry

• TransformImage.m Coordinate transformation on image arrays. p. 174.
• EulerRotation.m. Computes the 3x3 rotation matrix for the Z-X-Z Eulerian angles. Useful subroutine in testing Assignment 6.3 (p. 178).
• polyhedra.m Script to constructs 5 polyhedra as cellular arrays of faces. Useful for testing Assignmment 6.3 (p. 178).

#### Chapter 7: Change of Basis, DFT, and SVD

• getimage.m . Converts an image file to an array. Used in exercise 7.3. Credit: Pascal Getreuer.
• dft.m Uses FFT to convert time-domain to frequency domain (real DFT). Section 7.10.2, p. 213.
• idft.m Uses FFT to convert frequency domain to time-domain (real DFT). Section 7.10.2, p. 213.
• trigBasis.m . Matrix whose columns are the trigonometric Fourier components of size 2K. Section 7.10.2, p. 213.

#### Chapter 12: Monte Carlo Methods

• MCCircle.m Estimate the area of a circle, and create a plot. Section 12.1.
• MCPrimes.m Estimate the number of integer solutions to "x2 + y2 + z2" is prime where x, y, and z are between 0 and N.
• RelabellingSig.m Use resampling to determine whether the difference in mean between data sets V and W is significant. Discussed section 12.7, p. 368.

### Code used to generate figures in the text

The code to generate figure 6.19 is not included here, as that is the answer to Programming Assignment 6.3.