Exercises 3.6 Homework
1.
Write a script that does the following:
- Asks the user to enter a number
n
that will be used for the size of a square matrix. - Creates a random n×n matrix A with entries distributed between -1 and 1.
- Computes the matrix \(B = A^2\text{.}\)
- Shows a histogram of all entries of B, with 30 buckets.
2.
Write a script that does the following:
- 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).
- Multiplies A by a random column vector x with entries uniformly distributed between 0 and 1.
- Shows the histogram of \(Ax\text{,}\) with 30 buckets.
- 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.