Check NumPy Version
import numpy as np
np.__version__
1. 다음에 언급된 Physical Quantity들이 scalar인지 vector인지 고르시오.
- $20 \text{m}^2$의 넓이 : scalar
- $10 N$의 힘 : vector
2. 다음 벡터의 L2-Norm
(크기)을 구하시오
- $\vec{a} = \langle1,0,2\rangle$
- $\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
$$
- $\vec{a}+\vec{b}$
- $\vec{a}-2\vec{b}$
- $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인 것은?
- $\vec{a}=\langle0,2,-1\rangle$
- $\vec{a}=\langle0,0,-1\rangle$
- $\vec{a}=\langle1,1,1 \rangle$
- $\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
$$
- $\vec{a}\cdot\vec{b}$
- $\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 인가?
- $\vec{a}=\langle4,0,0\rangle, \vec{b}=\langle0,-3,1\rangle$
- $\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
$$
- $\vec{a}\times\vec{b}$
- $\vec{b}\times\vec{b}$
- $\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.
반응형
'... > 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 |