Mathematics memorandum to keep up with the field # 4

queue

This time I would like to briefly summarize the matrix.

What is a matrix

As the name implies, it is composed of "rows" and "columns". A concrete example is as follows.

[5, 13]
[4, 6]
[20, 7]

In this case, the "row" is [5,13]. The column refers to [5, 4, 20].

Matrix adjustment

The adjustment of the two matrices can be adjusted between the elements. Specific example) In python, you can define a matrix with numpy's matix function.

>>> A = np.matrix([[5, 13], [4, 6], [20, 7]])
>>> B = np.matrix([[8, 15], [9, 10], [20, 8]])
>>> print(A)
[[ 5 13]
 [ 4  6]
 [20  7]]
>>> print(B)
[[ 8 15]
 [ 9 10]
 [20  8]]
>>> C = A + B
>>> print(C)
[[13 28]
 [13 16]
 [40 15]]

Matrix multiplication

Matrix multiplication is a bit more complicated than adding or subtracting. If what you multiply is simply one real number, you can multiply each element.

>>> print(A)
[[ 5 13]
 [ 4  6]
 [20  7]]
>>> print(A * 2)
[[10 26]
 [ 8 12]
 [40 14]]
>>> 

However, if it is a matrix that is multiplied by a matrix as shown below, it cannot be simply elements.

>>> print(A)
[[ 5 13]
 [ 4  6]
 [20  7]]
>>> print(D)
[[1 2]
 [3 4]]
>>> print(A * D)
[[44 62]
 [22 32]
 [41 68]]
>>> 

Let's see what we are doing above.

First, look at [5, 13], which is the first row of matrix A. There, the first column of matrix D, [1, 3], is multiplied for each element, and the total is added. Do the same for the second and third rows of matrix A2 and the second column of matrix D. In particular,

[5 * 1 + 13 * 3] = 44
[4 * 1 + 6 * 3] = 22
[20 * 1 + 7 * 3] = 41
[5 * 2 + 13 * 4] = 62
[4 * 2 + 6 * 4] = 32
[20 * 2 + 7 * 4] = 68

[44 62]
[22 32]
[41 68]

In addition, matrix multiplication has the property that if the order of multiplication and multiplication is changed, the value will change.

Recommended Posts

Mathematics memorandum to keep up with the field # 4
Mathematics memorandum to keep up with the field # 1
Mathematics memorandum to keep up with the field # 2
Mathematics memorandum to keep up with the field # 3
Memorandum (Add name only to people with the same surname in the list)
[Python] Round up with just the operator
[Django] I made a field to enter the date with 4 digit numbers
Match the colorbar to the figure with matplotlib
The road to compiling to Python 3 with Thrift
Try to use up the Raspberry Pi 2's 4-core CPU with Parallel Python
Try to solve the fizzbuzz problem with Keras
Log in to the remote server with SSH
A memorandum to make WebDAV only with nginx
The easiest way to get started with Django
Crop the image to rounded corners with pythonista
How to specify the NIC to scan with amazon-dash
2016 The University of Tokyo Mathematics Solved with Python
I tried to save the data with discord
The easiest way to synthesize speech with python
Try to solve the man-machine chart with Python
Specify the Python executable to use with virtualenv
I wanted to play with the Bezier curve
How to try the friends-of-friends algorithm with pyfof
Say hello to the world with Python with IntelliJ
The easiest way to use OpenCV with python
Introduction to Python with Atom (on the way)
Save the object to a file with pickle
Back up from QNAP to Linux with rsync
How to Learn Kaldi with the JUST Corpus
I tried to learn the sin function with chainer
Try to solve the programming challenge book with python3
The easiest way to set up Last-Modified in Flask
How to delete the specified string with the sed command! !! !!
Add information to the bottom of the figure with Matplotlib
Just add the driver to the shape key with blender
[Introduction to Python] How to iterate with the range function?
How to create a submenu with the [Blender] plugin
Try to visualize the room with Raspberry Pi, part 1
Try to solve the internship assignment problem with Python
The first algorithm to learn with Python: FizzBuzz problem
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
[Python] How to specify the download location with youtube-dl
Display the integrated temperature for each field with Z-GIS
Introduction to Mathematics Starting with Python Study Memo Vol.1
Convert the image in .zip to PDF with Python
I want to inherit to the back with python dataclass
Try to get the contents of Word with Golang
[Neo4J] ④ Try to handle the graph structure with Cypher
PyInstaller memorandum Convert Python [.py] to [.exe] with 2 lines
Specify MinGW as the compiler to use with Python
Transit to the update screen with the Django a tag
I tried to solve the problem with Python Vol.1
[Python] How to rewrite the table style with python-pptx [python-pptx]
Display / update the graph according to the input with PySimpleGui
Try to specify the axis with PyTorch's Softmax function
I wrote you to watch the signal with Go