## 2020年3月28日土曜日

### 数学 - Python - 解析学 - n次元空間 - ユークリッド空間 - ベクトルの外積、内積、スカラー倍、性質

1. $\begin{array}{l}-\left(b×a\right)\\ =-\left({b}_{2}{a}_{3}-{b}_{3}{a}_{2},{b}_{3}{a}_{1}-{b}_{1}{a}_{3},{b}_{1}{a}_{2}-{b}_{2}{a}_{1}\right)\\ =\left({a}_{2}{b}_{3}-{a}_{3}{b}_{2},{a}_{3}{b}_{1}-{a}_{1}{b}_{3},{a}_{1}{b}_{2}-{a}_{2}{b}_{1}\right)\\ =a×b\end{array}$

2. $\begin{array}{l}a×\left(b+b\text{'}\right)\\ =\left({a}_{2}\left({b}_{3}+{b}_{3}\text{'}\right)-{a}_{3}\left({b}_{2}+{b}_{2}\text{'}\right),{a}_{3}\left({b}_{1}+{b}_{1}\text{'}\right)-{a}_{1}\left({b}_{3}+{b}_{3}\text{'}\right),{a}_{1}\left({b}_{2}+{b}_{2}\text{'}\right)-{a}_{2}\left({b}_{1}+{b}_{1}\text{'}\right)\right)\\ =\left({a}_{2}{b}_{3}+{a}_{2}{b}_{3}\text{'}-{a}_{3}{b}_{2}-{a}_{3}{b}_{2}\text{'},\\ {a}_{3}{b}_{1}+{a}_{3}{b}_{1}\text{'}-{a}_{1}{b}_{3}-{a}_{1}{b}_{3}\text{'},\\ {a}_{1}{b}_{2}+{a}_{1}{b}_{2}\text{'}-{a}_{2}{b}_{1}-{a}_{2}{b}_{1}\text{'}\right)\\ =\left({a}_{2}{b}_{3}-{a}_{3}{b}_{2},{a}_{3}{b}_{1}-{a}_{1}{b}_{3},{a}_{1}{b}_{2}-{a}_{2}{b}_{1}\right)\\ +\left({a}_{2}{b}_{3}\text{'}-{a}_{3}{b}_{2},{a}_{3}{b}_{1}\text{'}-{a}_{1}{b}_{3}\text{'},{a}_{1}{b}_{2}\text{'}-{a}_{2}{b}_{1}\text{'}\right)\\ =a×b-a×b\text{'}\end{array}$

3. $\begin{array}{l}\left(\alpha a\right)×b\\ =\left(\alpha {a}_{2}{b}_{3}-\alpha {a}_{3}{b}_{2},\alpha {a}_{3}{b}_{1}-\alpha {a}_{1}{b}_{3},\alpha {a}_{1}{b}_{2}-\alpha {a}_{2}{b}_{1}\right)\\ =\alpha \left({a}_{2}{b}_{3}-{a}_{3}{b}_{2},{a}_{3}{b}_{1}-{a}_{2}{b}_{3},{a}_{2}{b}_{2}-{a}_{2}{b}_{1}\right)\\ =\alpha \left(a×b\right)\\ \left(\alpha a\right)×b\\ =\left({a}_{2}\left(\alpha {b}_{3}\right)-{a}_{3}\left(\alpha {b}_{2}\right),{a}_{3}\left(\alpha {b}_{1}\right)-{a}_{1}\left(\alpha {b}_{3}\right),{a}_{1}\left(\alpha {b}_{2}\right)-{a}_{2}\left(\alpha {b}_{1}\right)\right)\\ =a×\left(\alpha b\right)\end{array}$

4. $\begin{array}{l}\left(a×b\right)·c\\ =\left({a}_{2}{b}_{3}-{a}_{3}{b}_{2}\right){c}_{1}+\left({a}_{3}{b}_{1}-{a}_{1}{b}_{3}\right){c}_{2}+\left({a}_{1}{b}_{2}-{a}_{2}{b}_{1}\right){c}_{3}\\ ={a}_{2}{b}_{3}{c}_{1}-{a}_{3}{b}_{2}{c}_{1}+{a}_{3}{b}_{1}{c}_{2}-{a}_{1}{b}_{3}{c}_{2}+{a}_{1}{b}_{2}{c}_{3}-{a}_{2}{b}_{1}{c}_{3}\\ a·\left(b×c\right)\\ ={a}_{1}\left({b}_{2}{c}_{3}-{b}_{3}{c}_{2}\right)+{a}_{2}\left({b}_{3}{c}_{1}-{b}_{1}{c}_{3}\right)+{a}_{3}\left({b}_{1}{c}_{2}-{b}_{2}{c}_{1}\right)\\ ={a}_{2}{b}_{3}{c}_{1}-{a}_{3}{b}_{2}{c}_{1}+{a}_{3}{b}_{1}{c}_{2}-{a}_{1}{b}_{3}{c}_{2}-{a}_{2}{b}_{1}{c}_{3}\end{array}$

よって、

$\left(a×b\right)·c=a·\left(b×c\right)$

5. $\begin{array}{l}\left(a×b\right)×c\\ =\left({a}_{2}{b}_{3}-{a}_{3}{b}_{2},{a}_{3}{b}_{1}-{a}_{1}{b}_{3},{a}_{1}{b}_{2}-{a}_{2}{b}_{1}\right)×c\\ =\left(\left({a}_{3}{b}_{1}-{a}_{1}{b}_{3}\right){c}_{3}-\left({a}_{1}{b}_{2}-{a}_{2}{b}_{1}\right){c}_{2},\\ \left({a}_{1}{b}_{2}-{a}_{2}{b}_{1}\right){c}_{1}-\left({a}_{2}{b}_{3}-{a}_{3}{b}_{2}\right){c}_{3},\\ \left({a}_{2}{b}_{3}-{a}_{3}{b}_{2}\right){c}_{2}-\left({a}_{3}{b}_{1}-{a}_{1}{b}_{3}\right){c}_{1}\right)\\ =\left({a}_{3}{b}_{1}{c}_{3}-{a}_{1}{b}_{3}{c}_{3}-{a}_{1}{b}_{2}{c}_{2}+{a}_{2}{b}_{1}{c}_{2},\\ {a}_{1}{b}_{2}{c}_{1}-{a}_{2}{b}_{1}{c}_{1}-{a}_{2}{b}_{3}{c}_{3}+{a}_{3}{b}_{2}{c}_{3},\\ {a}_{2}{b}_{3}{c}_{2}-{a}_{3}{b}_{2}{c}_{2}-{a}_{3}{b}_{1}{c}_{1}+{a}_{1}{b}_{3}{c}_{1}\right)\\ \left(a·c\right)b-\left(b·c\right)a\\ =\left({a}_{1}{b}_{1}{c}_{1}+{a}_{2}{b}_{1}{c}_{2}+{a}_{3}{b}_{1}{c}_{3},\\ {a}_{1}{b}_{2}{c}_{1}+{a}_{2}{b}_{2}{c}_{2}+{a}_{3}{b}_{2}{c}_{3},\\ {a}_{1}{b}_{3}{c}_{1}+{a}_{2}{b}_{3}{c}_{2}+{a}_{3}{b}_{3}{c}_{3}\right)-\\ \left({a}_{1}{b}_{1}{c}_{1}+{a}_{1}{b}_{2}{c}_{2}+{a}_{1}{b}_{3}{c}_{3},\\ {a}_{2}{b}_{1}{c}_{1}+{a}_{2}{b}_{2}{c}_{2}+{a}_{2}{b}_{3}{c}_{3},\\ {a}_{3}{b}_{1}{c}_{1}+{a}_{3}{b}_{2}{c}_{2}+{a}_{3}{b}_{3}{c}_{3}\right)\\ =\left({a}_{2}{b}_{1}{c}_{2}+{a}_{3}{b}_{1}{c}_{3}-{a}_{1}{b}_{2}{c}_{2}-{a}_{2}{b}_{3}{c}_{3},\\ {a}_{1}{b}_{2}{c}_{1}+{a}_{3}{b}_{2}{c}_{3}-{a}_{2}{b}_{1}{c}_{1}-{a}_{2}{b}_{3}{c}_{3},\\ {a}_{1}{b}_{3}{c}_{1}+{a}_{2}{b}_{3}{c}_{2}-{a}_{3}{b}_{1}{c}_{1}-{a}_{3}{b}_{2}{c}_{2}\right)\end{array}$

よって、

$\left(a×b\right)×c=\left(a·c\right)b-\left(b·c\right)a$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix

print('10.')

alpha = symbols('α')
a = Matrix(symbols('a:3')).reshape(1, 3)
b = Matrix(symbols('b:3')).reshape(1, 3)
c = Matrix(symbols('c:3')).reshape(1, 3)

class MyTestCase(TestCase):
def test_a(self):
self.assertEqual(a.cross(b).simplify(), (-b.cross(a)).simplify())

def test_b(self):
self.assertEqual(a.cross(b + c).simplify(),
(a.cross(b) + a.cross(c)).simplify())
self.assertEqual((a + b).cross(c).simplify(),
(a.cross(c) + b.cross(c)).simplify())

def test_c(self):
self.assertEqual((alpha * a).cross(b).simplify(),
a.cross(alpha * b).simplify(),
alpha * a.cross(b))

def test_d(self):
self.assertEqual(a.cross(b).dot(c).expand(),
a.dot(b.cross(c)).expand())

def test_e(self):
self.assertEqual(a.cross(b).cross(c).simplify(),
(a.dot(c) * b - b.dot(c) * a).simplify())

if __name__ == "__main__":
main()


% ./sample10.py -v
10.
test_a (__main__.MyTestCase) ... ok
test_b (__main__.MyTestCase) ... ok
test_c (__main__.MyTestCase) ... ok
test_d (__main__.MyTestCase) ... ok
test_e (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 5 tests in 0.824s

OK
%