2017年5月9日火曜日

学習環境

ラング線形代数学(上)(S.ラング (著)、芹沢 正三 (翻訳)、ちくま学芸文庫)の2章(ベクトル空間)、3(基底)、練習問題1.を取り組んでみる。


    1. a 1 ( 1,1,1 )+ a 2 ( 0,1,1 )=0 a 1 =0 a 1 + a 2 =0 a 2 =0 a 1 a 2 =00=0

    2. a 1 ( 1,0 )+ a 2 ( 1,1 )=0 a 1 + a 2 =0 a 2 =0 a 1 =0

    3. a 1 =0 a 1 =0 a 1 + a 2 =0 a 2 =0 2 a 2 =0

    4. 2 a 1 + a 2 =0 a 1 =0 a 1 =0 a 2 =0

    5. a 1 π=0 a 1 =0 a 2 =0

    6. a 1 + a 2 =0 2 a 1 +3 a 2 =0 a 2 = a 1 2 a 1 3 a 1 =0 a 1 =0 a 1 =0 a 2 =0

    7. a 1 + a 2 =0 a 1 + a 2 + a 3 =0 a 2 a 3 =0 a 3 =0 a 2 =0 a 1 =0

    8. a 3 =0 a 1 +2 a 2 +5 a 3 =0 a 1 +2 a 2 =0 a 1 + a 2 +3 a 3 =0 a 1 + a 2 =0 a 2 =0 a 1 =0

コード(Emacs)

Python 3

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sympy import Symbol, solve, pi

a1 = Symbol('a1')
a2 = Symbol('a2')
a3 = Symbol('a3')

for (x1, x2, x3), (y1, y2, y3) in [((1, 1, 1), (0, 1, -1)),
                                   ((-1, 1, 0), (0, 1, 2))]:
    expr1 = a1 * x1 + a2 * y1
    expr2 = a1 * x2 + a2 * y2
    expr3 = a1 * x3 + a2 * y3
    print(solve((expr1, expr2, expr3), dict=True))

for (x1, x2), (y1, y2) in [((1, 0), (1, 1)),
                           ((2, -1), (1, 0)),
                           ((pi, 0), (0, 1)),
                           ((1, 2), (1, 3))]:

    expr1 = a1 * x1 + a2 * y1
    expr2 = a1 * x2 + a2 * y2
    print(solve((expr1, expr2), dict=True))

for (x1, x2, x3), (y1, y2, y3), (z1, z2, z3) in [
        ((1, 1, 0), (1, 1, 1), (0, 1, -1)),
        ((0, 1, 1), (0, 2, 1), (1, 5, 3))]:
    expr1 = a1 * x1 + a2 * y1 + a3 * z1
    expr2 = a1 * x2 + a2 * y2 + a3 * z2
    expr3 = a1 * x3 + a2 * y3 + a3 * z3
    print(solve((expr1, expr2, expr3), dict=True))

入出力結果(Terminal, IPython)

$ ./sample1.py 
[{a2: 0, a1: 0}]
[{a2: 0, a1: 0}]
[{a2: 0, a1: 0}]
[{a2: 0, a1: 0}]
[{a2: 0, a1: 0}]
[{a2: 0, a1: 0}]
[{a2: 0, a3: 0, a1: 0}]
[{a1: 0, a2: 0, a3: 0}]
$

0 コメント:

コメントを投稿

Comments on Google+: