Skip to main content

Exercises 3.6 Homework

1.

Write a script that does the following:

  1. Asks the user to enter a number n that will be used for the size of a square matrix.
  2. Creates a random n×n matrix A with entries distributed between -1 and 1.
  3. Computes the matrix \(B = A^2\text{.}\)
  4. Shows a histogram of all entries of B, with 30 buckets.
2.

Write a script that does the following:

  1. Asks the user for the number of rows and the number of columns, and creates a random matrix A of this size (with entries uniformly distributed between 0 and 1).
  2. Multiplies A by a random column vector x with entries uniformly distributed between 0 and 1.
  3. Shows the histogram of \(Ax\text{,}\) with 30 buckets.
  4. Displays formatted output: “The smallest entry of Ax is ... and the largest entry of Ax is ...”, with 9 digits after decimal dot in each of them.