2017年6月13日火曜日

学習環境

ラング線形代数学(上)(S.ラング (著)、芹沢 正三 (翻訳)、ちくま学芸文庫)の4章(線形写像)、1(写像)、練習問題1-7.を取り組んでみる。


    1. cosx

    2. e x

    3. 1 x

    1. 0 x e t dt = [ e t ] 0 x = e x 1

    2. 0 x 1 1+ t 2 dt = [ arctant ] 0 x =arctanxarctan0 =arctanx

    3. 0 x costdt = [ sint ] 0 x =sinxsin0 =sinx

    1. ( 2,3,1 )·( 1,2,3 )=2+6+3=11

    2. ( 2,3,1 )·( 1,5,0 )=2+15=13

    3. ( 2,3,1 )·( 2,1,1 )=4+31=6

  1. F( 1 )=( e,1 ) F( 0 )=( 1,0 ) F( 1 )=( 1 e ,1 )

  2. ( F+G )( x )=( e t +t,3t ) ( F+G )( 1 )=( e+1,3 ) ( F+G )( 2 )=( e 2 +2,6 ) ( F+G )( 0 )=( 1,0 )

  3. ( 2F )( x )=( 2 e t ,2t ) ( 2F )( 0 )=( 2,0 ) ( πF )( x )=( π e t ,πt ) ( πF )( 1 )=( πe,π )

    1. F( X )=( 1,1,0,1 )·( 1,1,1,3 )+2 =1+13+2 =1

    2. F(X)=(2,3,1,1)·(1,1,1,3)+2 =2+3+1+3+2 =11

コード(Emacs)

Python 3

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

from sympy import pprint, symbols, sin, exp, log, cos, Derivative, Integral, Matrix

print('1.')
x = symbols('x')
for i, f in enumerate([sin, exp, log]):
    print('({0})'.format(chr(ord('a') + i)))
    g = Derivative(f(x), x, 1)
    pprint(g)
    pprint(g.doit())
    print()

print('2.')
t = symbols('t')
for i, f in enumerate([exp(t), 1 / (1 + t ** 2), cos(t)]):
    print('({0})'.format(chr(ord('a') + i)))
    g = Integral(f, (t, 0, x))
    pprint(g)
    pprint(g.doit())
    print()

print('3.')
A = Matrix([[2, 3, -1]])
for i, x in enumerate([[1, 2, -3], [-1, 5, 0], [2, 1, 1]]):
    print('({0})'.format(chr(ord('a') + i)))
    print(A.dot(x))
    print()

print('4.')
ft = Matrix([[exp(t), t]])
for i, t0 in enumerate([1, 0, -1]):
    print('({0})'.format(chr(ord('a') + i)))
    pprint(ft.subs({t: t0}))
    print()

print('5.')
gt = Matrix([[t, 2 * t]])
for i, t0 in enumerate([1, 2, 0]):
    print('({0})'.format(chr(ord('a') + i)))
    pprint((ft + gt).subs({t: t0}))
    print()

print('7.')
A = [1, 1, -1, 3]
for i, x0 in enumerate([(1, 1, 0, -1), (2, 3, -1, 1)]):
    print('({0})'.format(chr(ord('a') + i)))
    X = Matrix([x0])
    print(X.dot(A) + 2)

入出力結果(Terminal, IPython)

$ ./sample1.py
1.
(a)
d         
──(sin(x))
dx        
cos(x)

(b)
d ⎛ x⎞
──⎝ℯ ⎠
dx    
 x
ℯ 

(c)
d         
──(log(x))
dx        
1
─
x

2.
(a)
x      
⌠      
⎮  t   
⎮ ℯ  dt
⌡      
0      
 x    
ℯ  - 1

(b)
x          
⌠          
⎮   1      
⎮ ────── dt
⎮  2       
⎮ t  + 1   
⌡          
0          
atan(x)

(c)
x          
⌠          
⎮ cos(t) dt
⌡          
0          
sin(x)

3.
(a)
11

(b)
13

(c)
6

4.
(a)
[ℯ  1]

(b)
[1  0]

(c)
⎡ -1    ⎤
⎣ℯ    -1⎦

5.
(a)
[1 + ℯ  3]

(b)
⎡     2   ⎤
⎣2 + ℯ   6⎦

(c)
[1  0]

7.
(a)
1
(b)
11
$

0 コメント:

コメントを投稿

Comments on Google+: