Vector check

2022. 4. 4. 21:00·.../Physics
728x90
728x90

Check NumPy Version

import numpy as np

np.__version__

1. 다음에 언급된 Physical Quantity들이 scalar인지 vector인지 고르시오.

  1. $20 \text{m}^2$의 넓이 : scalar
  2. $10 N$의 힘 : vector

2. 다음 벡터의 L2-Norm(크기)을 구하시오

  1. $\vec{a} = \langle1,0,2\rangle$
  2. $\vec{b}=\langle0,3\rangle$
vec = [[1,0,2],[0,3,0]]
L2_norm = np.linalg.norm(vec,axis=1,ord=2)
print('2-1:',L2_norm[0],'|np.sqrt(5)',np.sqrt(5))
print('2-2:',L2_norm[1])

3. 다음을 계산하시오.

다음과 같은 vector가 있음.

$$
\vec{a}=\langle2,1,-3\rangle ,
\vec{b}=\langle0,4,-2\rangle
$$

  1. $\vec{a}+\vec{b}$
  2. $\vec{a}-2\vec{b}$
  3. $3\vec{a}$
a = np.array([2,1,-3])
b = np.array([0,4,-2])

print('3-1:',a+b)
print('3-2:',a-2*b)
print('3-3:',3*a)

4. 다음 중 Unit vector인 것은?

  1. $\vec{a}=\langle0,2,-1\rangle$
  2. $\vec{a}=\langle0,0,-1\rangle$
  3. $\vec{a}=\langle1,1,1 \rangle$
  4. $\vec{a}=\langle\dfrac{3}{5}, 0 ,\dfrac{4}{5}\rangle$
vec = [[0,2,-1],[0,0,-1],[1,1,1],[3/5,0,4/5]]
L2_norm = np.linalg.norm(vec,axis=1,ord=2)
answers = [L2_norm==1]
for idx,val in enumerate(answers[0]):
    print('4-{}:{}'.format(idx+1,val))

5. 다음의 vector와 반대 방향의 unit vector를 구하시오.

$$
\vec{a} = \left< 3, 1, -2 \right>
$$

a = np.array([3,1,-2])
b = -1*a/np.linalg.norm(a)
print(b)
print(-3/np.sqrt(14),-1/np.sqrt(14),2/np.sqrt(14))

6. 다음을 구하시오.

$$
\vec{a}=\langle3,-2,1\rangle,\
\vec{b}=\langle-4,5,1\rangle
$$

  1. $\vec{a}\cdot\vec{b}$
  2. $\vec{b}\cdot\vec{b}$
a = np.array([3,-2,1])
b = np.array([-4,5,1])

print('6-1:',np.dot(a,b))
print('6-2:',np.dot(b,b))

7. 다음의 vector들이 orthogonal 인가?

  1. $\vec{a}=\langle4,0,0\rangle, \vec{b}=\langle0,-3,1\rangle$
  2. $\vec{a}=\langle4,0,1\rangle, \vec{b}=\langle0,-2,1\rangle$
def is_orthogonal(a,b):
    dot = np.dot(a,b)
    if dot == 0:
        #print('orthogonal')
        return True
    else:
        #print('not orthogonal')
        return False


a = np.array([4,0,0])
b = np.array([0,-3,1])
print('7-1: a and b is orthogonal:',is_orthogonal(a,b))

a = np.array([4,0,1])
b = np.array([0,-2,1])
print('7-2: a and b is orthogonal:',is_orthogonal(a,b))

#a = np.array([0,0,1])
#b = np.array([0,1,0])
#print('7-3: a and b is orthogonal:',is_orthogonal(a,b))

8. 다음을 구하시오.

$$
\vec{a}=\langle1,2,3\rangle, \vec{b}=\langle4,0,1\rangle
$$

  1. $\vec{a}\times\vec{b}$
  2. $\vec{b}\times\vec{b}$
  3. $\vec{b}\times\vec{a}$
a = np.array([1,2,3])
b = np.array([4,0,1])

print('8-1:',np.cross(a,b))
print('8-2:',np.cross(b,b))
print('8-3:',np.cross(b,a))

Ref.

(https://colab.research.google.com/github/dsaint31x/Physics/blob/master/src/20220329_vector_ex.ipynb#scrollTo=xlXBN-8da4Dj)

'... > Physics' 카테고리의 다른 글

Vibration & Wave  (0) 2022.04.12
Thermal Radiation (열복사): Blackbody Radiation, Wien’s Law, IR  (0) 2022.04.05
[Physics] Terminal Velocity and Differential Equation  (0) 2022.03.28
[Physics] 정지거리 계산에 사용되는 공식 유도.  (0) 2022.03.28
[History of Science] Aristotle’s Mechanics  (0) 2022.03.14
'.../Physics' 카테고리의 다른 글
  • Vibration & Wave
  • Thermal Radiation (열복사): Blackbody Radiation, Wien’s Law, IR
  • [Physics] Terminal Velocity and Differential Equation
  • [Physics] 정지거리 계산에 사용되는 공식 유도.
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (739)
      • Private Life (13)
      • Programming (56)
        • DIP (104)
        • ML (26)
      • Computer (119)
        • CE (53)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (350)
        • Signals and Systems (103)
        • Math (171)
        • Linear Algebra (33)
        • Physics (42)
        • 인성세미나 (1)
      • 정리필요. (54)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (1)
        • PET Study 2009 (1)
        • 방사선 장해방호 (4)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    Term
    SS
    numpy
    검사
    function
    fourier transform
    Vector
    signals_and_systems
    signal_and_system
    SIGNAL
    Optimization
    math
    linear algebra
    Convolution
    인허가제도
    Programming
    opencv
    Probability
    random
    Python
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
Vector check
상단으로

티스토리툴바