1 beyond basics Ⅱ complex arithmetic more on matrices doing calculus whit matlab jae hoon kim...

11
1 Beyond Basics • Complex Arithmetic • More on Matrices • Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National Univers ity

Upload: avice-wilson

Post on 27-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

1

Beyond Basics Ⅱ

• Complex Arithmetic

• More on Matrices

• Doing Calculus whit Matlab

Jae Hoon Kim

Department of Physics

Kangwon National University

Page 2: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

2

Complex Arithmetic

• Matlab 에서 복소수는 'i' 를 사용하여 나타낸다 .>> solve('x^2 + 2*x + 2 = 0')

ans =

[-1+i]

[-1-i]

>> (2 + 3*i)*(4 - i)

ans =

11.0000 + 10.0000i

Page 3: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

3

More on Matrices

• Element-by-element operation

>> A.*B (element-by-element product)

>> A./B (element-by-element quotient) A : vector

>> A.^C (raising each of the elements) B&C :vector or scalar

• submatrice 구하기 ① >> a(4,[1 2])

ans =

1 2

② >> a(2:3,2:4)ans =

3 2 4

1 1 0

Page 4: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

4

• Special Matrices

>> zeros(2,3)( 모든 element 가 0 인 행렬 )

ans =

0 0 0

0 0 0

>> ones(2,3)( 모든 element 가 1 인 행렬 )

ans =

1 1 1

1 1 1

>> eyes(3)( 단위 행렬 )

ans =

1 0 0

0 1 0

0 0 1

Page 5: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

5

• solving Linear Systems 연립일차방정식의 풀이 2x+3y=2

x+2y=3

>> A=[2 3;1 2]

A =

2 3

1 2

>> b=[2; 3]

b =

2

3

>> x=A\b ( 행렬의 오른쪽 나눗셈 ('/'), 행렬의 왼쪽 나눗셈 ('\'))

x =

-5

4

bxA

3

2

21

32

y

x

Page 6: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

6

• calculating Eigenvalues and Eigenvectors

>> A = [3 -2 0; 2 -2 0; 0 1 1];

>> eig (A)( 행렬 A 의 eigenvalues 값을 구한다 )

ans =

1

-1

2

>> [U, R] = eig(A)(U 는 eigenvectors 값을 R 에는 eigenvalues 값을 출력함 )

U =

0 -0.4082 -0.8165

0 -0.8165 -0.4082

1.0000 0.4082 -0.4082

R =

1 0 0

0 -1 0

0 0 2

Page 7: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

7

Doing Calculus whit MATLAB• Differentiation>> syms x; diff(x^3)

ans =

3*x^2

>> f = inline('x^3', 'x'); diff(f(x))

ans =

3*x^2

>> diff(f(x), 2) (2 차 미분 )

ans=

6*x

• 미분방정식 풀이

xy'+1 =y

>>dsolve('x*Dy + 1 = y', 'x') ans= 1+x*C1

Page 8: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

8

• Integration

( 부정적분 )

>> int('x^2', 'x')

ans =

1/3*x^3

( 정적분 )

>>syms x; int(asin(x), 0, 1)

ans =

1/2*pi-1

dxx2

1

0

1sin xdx

1

0

4^ dxe x

( 수치적분 )>>quadl('exp(-x.^4)', 0, 1)ans =0.8448

( 이중 적분 )>> syms x y; int(int(x^2+y^2, y, 0, sin(x)), 0, pi)ans =pi^2-32/9

0

sin

0

22 )(x

dydxyx

Page 9: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

9

• Limits

>> limit(abs(x)/x, x, 0, 'left')(left: 좌극한 right: 우극한 abs: 절대값 )ans =

-1

>>limit(abs(x)/x, x, inf)(inf: 무한대 )ans =

1

x

x

xlim

0

x

x

xlim

Page 10: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

10

• Sums and Products

>> x = 1:7;

>> sum(x)

ans =

28

>> prod(x)

ans =

5040

)7,6,5,4,3,2,1(x

7

1i

i

7

1i

i

>> syms k n; symsum(1/k-1/(k+1), 1,n)ans =

-1/(n+1)+1

>>syms n; symsum(1/n^2, 1, inf)ans =

1/6*pi^2

n

k kk1

)1

11( (finite symbolic sum)

12

1

n n(infinite symbolic sum)

Page 11: 1 Beyond Basics Ⅱ Complex Arithmetic More on Matrices Doing Calculus whit Matlab Jae Hoon Kim Department of Physics Kangwon National University

11

• Taylor Series

>> syms x; taylor(sin(x), x, 10)(sinx 를 x 에 대하여 10 차 항까지 전개 )

ans =x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9