Translate

이 블로그 검색

2012년 5월 16일 수요일

Tips for Matrix Calc

1. Roots of Higher-order Equations
ex) 3x^4 - 5x^3 + 11x^2 - 8 = 0
-Change Mode to Matrix
-Make a matrix of coefficients
 #x4=[3,-5,11,0,-8]
-Execute the function 'roots'
 roots(#x4)
-The result should be
 [ 0.945216
  -0.706456
   0.714+i1.866
   0.714-i1.866 ]

2. Solving System of Linear Equations
ex) 2x -y + z = -1
    3x +3y + 9z = 0
    3x + 3y + 5z = 4
-Change Mode to Matrix
-Make two matrices of coefficients
 #a=[2,-1,1;3,3,9;3,3,5]
 #b=[-1;0;4]
-Use the function '\'(backslash)
 #b\#a
 #a\#b
-The result should be
 [ 1.0
   2.0
  -1.0 ]

3. Calc Regression (Least Square Equation)
ex1) x = {2, 3, 6, 8, 12, 15}
     y = {10, 17, 24, 37, 49, 70}
     If you suppose that y = ax + b
     Then What would a and b be?
-Change Mode to Matrix
-Make two matrices of coefficients
 #x=[2,1;3,1;6,1;8,1;12,1;15,1]
 #y=[10;17;24;37;49;70]
-Use the function '\'(backslash)
 #y\#x
 #x\#y
-The result should be
 [ 4.345361
   1.185567 ]
 That is, a = 4.34536 and b = 1.185567

ex2) x = {2, 3, 6, 8, 12, 15}
     y = {55, 43, 32, 26, 44, 70}
     If you suppose that y = ax^2 + bx + c
     Then What would a, b and c be?
-Change Mode to Matrix
-Make two matrices of coefficients
 #x=[2^2,2,1;3^2,3,1;6^2,6,1;8^2,8,1;12^2,12,1;15^2,15,1]
 #y=[55,43,32,26,44,70]
 #y=[55;43;32;26;44;70]
-Use the function '\'(backslash)
 #y\#x
 #x\#y
-The result should be
 [ 0.796157
  -12.2257
   74.77246 ]
 That is, a = 0.796157, b = -12.2257 and c  = 74.77246

댓글 없음:

댓글 쓰기