Matrix Operations
You will continue to look at how to use nested lists for some basic matrix operations. First, you look at how to add two matrices in Python. Matrix addition requires both matrices to have the same dimensions; the results will also be of the same dimensions.
In Exercise 23, Implementing Matrix Operations (Addition and Subtraction), you will be using the following matrix data, X
and Y
, in figures 2.7 and 2.8:
Exercise 23: Implementing Matrix Operations (Addition and Subtraction)
In this exercise you will add and subtract the X
and Y
matrixes using Python.
The following steps will enable you to complete the exercise:
- Open a new Jupyter Notebook.
- Create two nested lists,
X
andY
, to store the values:X = [[1,2,3],[4,5,6],[7,8,9]] Y = [[10,11,12],[13,14,15],[16,17,18]]
- Initialize a 3 x 3 zero matrix called
result
as a placeholder...