## 2019年7月25日木曜日

### 数学 - Python - 線形代数学 - 行列と双線形写像 - 2次形式 - 体K上の有限次元ベクトル空間、対称双線形形式の値の完全な決定

ラング線形代数学(下) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の8章(行列と双線形写像)、2(2次形式)、練習問題4の解答を求めてみる。

1. $\begin{array}{l}\frac{1}{4}\left(f\left(\left({x}_{1},{x}_{2}\right)+\left({y}_{1},{y}_{2}\right)\right)-f\left(\left({x}_{1},{x}_{2}\right)-\left({y}_{1},{y}_{2}\right)\right)\right)\\ =\frac{1}{4}\left(f\left({x}_{1}+{y}_{1},{x}_{2}+{y}_{2}\right)-f\left({x}_{1}-{y}_{1},{x}_{2}-{y}_{2}\right)\right)\\ =\frac{1}{4}\left(\left({x}_{1}+{y}_{1}\right)\left({x}_{2}+{y}_{2}\right)-\left({x}_{1}-{y}_{1}\right)\left({x}_{2}-{y}_{2}\right)\right)\\ =\frac{1}{4}\left(2{x}_{1}{y}_{2}+2{x}_{2}{y}_{1}\right)\\ =\frac{1}{2}\left({x}_{1}{y}_{2}+{x}_{2}{y}_{1}\right)\end{array}$

2. $\begin{array}{l}g\left(X,Y\right)\\ =\frac{1}{4}\left(f\left({x}_{1}+{y}_{1},{x}_{2}+{y}_{2},{x}_{3}+{y}_{3},{x}_{4}+{y}_{4}\right)-f\left({x}_{1}-{y}_{1},{x}_{2}-{y}_{2},{x}_{3}-{y}_{3},{x}_{4}-{y}_{4}\right)\right)\\ =\frac{1}{4}\left(\left({x}_{1}+{y}_{1}\right)\left({x}_{3}+{y}_{3}\right)+{\left({x}_{4}+{y}_{4}\right)}^{2}-\left({x}_{1}-{y}_{1}\right)\left({x}_{3}-{y}_{3}\right)-{\left({x}_{4}-{y}_{4}\right)}^{2}\right)\\ =\frac{1}{4}\left(2{x}_{1}{y}_{3}+2{x}_{3}{y}_{1}+4{x}_{4}{y}_{4}\right)\\ =\frac{1}{2}\left({x}_{1}{y}_{3}+{x}_{3}{y}_{1}\right)+{x}_{4}{y}_{4}\end{array}$

3. $\begin{array}{l}\frac{1}{4}\left(2\left({x}_{1}+{y}_{1}\right)\left({x}_{2}+{y}_{2}\right)-\left({x}_{3}+{y}_{3}\right)\left({x}_{4}+{y}_{4}\right)-2\left({x}_{1}-{y}_{1}\right)\left({x}_{2}-{y}_{2}\right)+\left({x}_{3}-{y}_{3}\right)\left({x}_{4}-{y}_{4}\right)\right)\\ =\frac{1}{4}\left(4{x}_{1}{y}_{2}+4{x}_{2}{y}_{1}-2{x}_{3}{y}_{4}-2{x}_{4}{y}_{3}\right)\\ ={x}_{1}{x}_{2}+{x}_{2}{y}_{1}-\frac{1}{2}\left({x}_{3}{y}_{4}+{x}_{4}{y}_{3}\right)\end{array}$

4. $\begin{array}{l}\frac{1}{4}\left({\left({x}_{1}+{y}_{1}\right)}^{2}-{\left({x}_{1}-{y}_{1}\right)}^{2}-5\left(\left({x}_{2}+{y}_{2}\right)\left({x}_{3}+{y}_{3}\right)-\left({x}_{2}-{y}_{2}\right)\left({x}_{3}-{y}_{3}\right)\right)+{\left({x}_{4}+{y}_{4}\right)}^{2}-{\left({x}_{4}-{y}_{4}\right)}^{2}\right)\\ =\frac{1}{4}\left(4{x}_{1}{y}_{1}-5\left(2\left({x}_{2}{y}_{3}+{x}_{3}{y}_{2}\right)\right)+4{x}_{4}{y}_{4}\right)\\ ={x}_{1}{y}_{1}-\frac{5}{2}\left({x}_{2}{y}_{3}+{x}_{3}{y}_{2}\right)+{x}_{4}{y}_{4}\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Matrix,  Rational

print('4.')

def g(f, v, w):
return (f(v + w) - f(v - w)) / 4

def f1(x):
return x[0] * x[1]

def f2(x):
return x[0] * x[2] + x[3] ** 2

def f3(x):
return 2 * x[0] * x[1] - x[2] * x[3]

def f4(x):
return x[0] ** 2 - 5 * x[1] * x[2] + x[3] ** 2

fs = [f1, f2, f3, f4]
v = Matrix(symbols('x1, x2, x3, x4'))
w = Matrix(symbols('y1, y2, y3, y4'))

for i, f in enumerate(fs):
print(f'({chr(ord("a")+ i)})')
pprint(g(f, v, w).expand())
print()


C:\Users\...>py sample4.py
4.
(a)
x₁⋅y₂   x₂⋅y₁
───── + ─────
2       2

(b)
x₁⋅y₃   x₃⋅y₁
───── + ───── + x₄⋅y₄
2       2

(c)
x₃⋅y₄   x₄⋅y₃
x₁⋅y₂ + x₂⋅y₁ - ───── - ─────
2       2

(d)
5⋅x₂⋅y₃   5⋅x₃⋅y₂
x₁⋅y₁ - ─────── - ─────── + x₄⋅y₄
2         2

C:\Users\...>