<a href="https://colab.research.google.com/github/tnaka78/mit_ocw_1806_spring_2005/blob/master/lecture01.ipynb" target="_parent"></a>


```
import numpy as np
import matplotlib.pyplot as plt
```

# Lecture 1: The Geometry of Linear Equations

$$
\begin{align}
2x -y & = 0 \\
-x +2y & = 3
\end{align}
$$
を行列で表すと
$$
\left[
  \begin{array}{cc}
    2 & -1 \\
    -1 & 2
  \end{array}
\right]
\left[
  \begin{array}{c}
    x \\
    y
  \end{array}
\right] =
\left[
  \begin{array}{r}
    0\\
    3
  \end{array}
\right]
$$

## Row Picture
行ごとに見ていく方法（方程式をそのままプロットするイメージ）


```
xs = np.linspace(-5, 5, 100)
ys1 = [2 * x for x in xs]
ys2 = [(3+x)/2 for x in xs]
fig, ax = plt.subplots()
ax.plot(xs, ys1, color='blue')
ax.plot(xs, ys2, color='red')
ax.hlines(2, -5, 5, linestyles='dotted')
ax.vlines(1, -5, 5, linestyles='dotted')
ax.annotate('[1, 2]', [1, 2])
ax.axis([-5, 5, -5, 5])
plt.show()
```

2本の線の交点が答え→$x=1, y=2$

## Column Picture
列ごとに見ていく方法（一つの列を一つのベクトルをみなす）
$$
\left[
  \begin{array}{c}
    2 \\
    -1
  \end{array}
\right]
x+
\left[
  \begin{array}{c}
    -1\\
    2
  \end{array}
\right]
y=
\left[
  \begin{array}{r}
    0\\
    3
  \end{array}
\right]
$$


```
fig, ax = plt.subplots()
ax.quiver(0, 0, 2, -1, angles='xy', scale_units='xy', scale=1, color='blue')
ax.annotate('[2, -1]', [2, -1], color='blue')
ax.quiver(0, 0, -1, 2, angles='xy', scale_units='xy', scale=1, color='red')
ax.annotate('[-1, 2]', [-1, 2], color='red')
ax.quiver(0, 0, 0, 3, angles='xy', scale_units='xy', scale=1, color='green')
ax.annotate('[0, 3]', [0, 3], color='green')
ax.axis([-4, 4, -4, 4])
plt.show()
```

青のベクトル1個分と赤のベクトル2個分を足すと緑のベクトルになる→ $x=1, y=2$

f6b1a850e7cb134924970a97f99b3ba271cfb0bd
ipynb
Jupyter Notebook
lecture01.ipynb
tnaka78/mit_ocw_1806_spring_2005
10006fa0052c6802dbb522b1bef0a7b9ea3cfa62
MIT
lecture01.ipynb
tnaka78/mit_ocw_1806_spring_2005
10006fa0052c6802dbb522b1bef0a7b9ea3cfa62
MIT
lecture01.ipynb
tnaka78/mit_ocw_1806_spring_2005
10006fa0052c6802dbb522b1bef0a7b9ea3cfa62
MIT
Qwen/Qwen-72B
1. YES
2. YES