Introduction to Vectors: Linear Algebra in Python <1>

linear algebra

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.

environment

・ Jupyter Notebook ・ Language: Python3, Julia1.4

Linear combination (introduction to vectors)

The linear combination is composed of ** scalar product ** and ** vector sum **. Let a and b be the two scalars, and v and w be the sum of the vectors.

Scalar product is

av,bw

What was hung like.

Vector sum is

v + w

What was added like. The combination of these two is called *** linear combination ***. Therefore,

av + bw

It is a shape like. By the way, since this has two terms, *** a two-dimensional surface is stretched ***. (If v = w>, it is different.)

Implemented in python

import numpy as np

#vector
v = np.array([1, 2, 3])
w = np.array([4, 5, 6])
#scalar
a = 2
b = 5

#Linear combination shape
linearcomb = a * v + b * w
print(linearcomb) 

Implemented in julia

#vector
v = [1, 2, 3]
w = [4, 5, 6]
#scalar
a = 2
b = 5

linearcomb = a * v + b * w
print(linearcomb)

Both appear in the terminal as below

[22 29 36]

So far.

Recommended Posts

Introduction to Vectors: Linear Algebra in Python <1>
Introduction to Linear Algebra in Python: A = LU Decomposition
Basic Linear Algebra Learned in Python (Part 1)
[Introduction to Python] How to use class in Python?
Eigenvalues and eigenvectors: Linear algebra in Python <7>
Linear Independence and Basis: Linear Algebra in Python <6>
Introduction to Effectiveness Verification Chapter 1 in Python
Introduction to Python language
Introduction to OpenCV (python)-(2)
Linear search in Python
Introduction to effectiveness verification Chapter 3 written in Python
tse --Introduction to Text Stream Editor in Python
I wrote "Introduction to Effect Verification" in Python
Introduction to Generalized Linear Models (GLM) with Python
Identity matrix and inverse matrix: Linear algebra in Python <4>
Inner product and vector: Linear algebra in Python <2>
Matrix Calculations and Linear Equations: Linear Algebra in Python <3>
Introduction to Effectiveness Verification Chapter 2 Written in Python
Introduction to Python Django (2) Win
To flush stdout in Python
Login to website in Python
Design Patterns in Python: Introduction
Speech to speech in python [text to speech]
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Python Programming
How to develop in Python
Online linear regression in Python
Introduction to Python For, While
Post to Slack in Python
First Computational Physics: Quantum mechanics and linear algebra in python.
Introduction to Effectiveness Verification Chapters 4 and 5 are written in Python
[Introduction to Udemy Python 3 + Application] 58. Lambda
[Introduction to Udemy Python 3 + Application] 31. Comments
[Python] How to do PCA in Python
Introduction to Python Numerical Library NumPy
Practice! !! Introduction to Python (Type Hints)
How to collect images in Python
[Introduction to Python] <numpy ndarray> [edit: 2020/02/22]
[Introduction to Udemy Python 3 + Application] 57. Decorator
Introduction to Python Hands On Part 1
[Introduction to Python3 Day 13] Chapter 7 Strings (7.1-7.1.1.1)
How to use SQLite in Python
[Introduction to Python] How to parse JSON
In the python command python points to python3.8
[Introduction to Python3 Day 14] Chapter 7 Strings (7.1.1.1 to 7.1.1.4)
Introduction to Protobuf-c (C language ⇔ Python)
[Introduction to Udemy Python3 + Application] 59. Generator
Try to calculate Trace in Python
[Introduction to Python3 Day 15] Chapter 7 Strings (7.1.2-7.1.2.2)
[Introduction to Python] Let's use pandas
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
6 ways to string objects in Python
How to use PubChem in Python
[Introduction to Python] Let's use pandas
[Introduction to Udemy Python 3 + Application] Summary
[Introduction to Python] Let's use pandas
An introduction to Python for non-engineers
How to handle Japanese in Python