The linear algebra that you will definitely learn at a science university is summarized in an easy-to-understand and logical manner. By the way, I implemented it in Python. Occasionally, it may be implemented in Julia. .. .. ・ Learn by running with Python! New Mathematics Textbook-Basic Knowledge Required for Machine Learning / Deep Learning- ・ World Standard MIT Textbook Strang Linear Algebra Introduction Understand linear algebra based on and implement it in python.
・ Jupyter Notebook ・ Language: Python3, Julia 1.4.0
Let's touch on the procession a little deeper. fundamentally,
A x = b
The standard is to shape it
The matrix has *** rows *** and *** columns ***.
・ The rows are lined up side by side
・ Lined up on the shield
until now,
What we have expressed as u = (1, 2, 3) is a column vector.
*** row vector: u = [1, 2, 3]
***
*** Column vector: u = (1, 2, 3)
***
And. Originally, it should be written as follows.
u =
\begin{bmatrix}
1 \\
2 \\
3
\end{bmatrix}
However, this article is annoying due to the markdown method, so I will write it as before.
ex) About simultaneous equations
\begin{matrix}
x - 2y = 1 \\
3x + 2y = 11
\end{matrix}
Is considered as a column vector. (= Linear thinking) The merit of linear equations is that negative command can be expressed by one equation. It can be transformed as follows,
x
\begin{bmatrix}
1 \\
3
\end{bmatrix}
+
y
\begin{bmatrix}
-2 \\
2
\end{bmatrix}
=
\begin{bmatrix}
1 \\
11
\end{bmatrix}
This time,
u =
\begin{bmatrix}
1 \\
3
\end{bmatrix}
,
v =
\begin{bmatrix}
-2 \\
2
\end{bmatrix}
,
b =
\begin{bmatrix}
1 \\
11
\end{bmatrix}
I can do it. This can be written in the form of Ax = b as follows when u and v are collectively referred to as A.
Ax =
\begin{bmatrix}
1 & -2\\
3 & 2
\end{bmatrix}
\begin{bmatrix}
x\\
y
\end{bmatrix}
=
\begin{bmatrix}
1 \\
11
\end{bmatrix}
= b
Will be. In this linear equation, we need to consider the applicable x and y. By the way, from an analytical point of view, it shows the intersections of straight lines.
a =
\begin{bmatrix}
0 & 1 & 2 \\
1 & 2 & 3
\end{bmatrix}
,
b =
\begin{bmatrix}
2 & 1 \\
2 & 1\\
2 & 1
\end{bmatrix}
And. Calculate the matrix.
import numpy as np
a = ([[0, 1 ,2],
[1, 2, 3]])
b = ([[2, 1],
[2, 1],
[2, 1]])
print(np.dot(a, b))
#=>[[ 6 3]
# [12 6]]
using LinearAlgebra
a = [0 1 2; 1 2 3]
b = [2 1; 2 1; 2 1]
a*b
#=>2×2 Array{Int64,2}:
# 6 3
# 12 6
In the previous comment, there was something about the LinearAlgebra
module, so this time I tried to make it easier. If you want to rationalize the mechanism of the contents, please do it without a module. It may be good to use a module for calculation adjustment.
Recommended Posts