<jupyter_start><jupyter_text>Lab 2 - Plotting  Discussion   NumPyNumPy or Numerical Python, is mainly used for matrix and vector operations. It is capable of declaring computing and representing matrices.Most Python scientific programming libraries uses Numpy as the basic code.  Representing Vectors Now that you know how to represent vectors using their component and matrix form we can now hard-code them in Python. Let's say that youhave the vectors: $$ A = 4\hat{x} + 3\hat{y} \\B = 2\hat{x} - 5\hat{y}$$ In which it's matrix equivalent is: $$ A = \begin{bmatrix} 4 \\ 3\end{bmatrix} , B = \begin{bmatrix} 2 \\ -5\end{bmatrix} , C = \begin{bmatrix} 4 \\ 3\ \\ -2\end{bmatrix} , D = \begin{bmatrix} 2 \\ -2\\ 5\end{bmatrix}$$$$ A = \begin{bmatrix} 4 & 3\end{bmatrix} , B = \begin{bmatrix} 2 & -5\end{bmatrix} , C = \begin{bmatrix} 4 & 3\ & -2\end{bmatrix} , D = \begin{bmatrix} 2 & -2 & 3\end{bmatrix}$$ We can the start doing numpy code with this by:<jupyter_code>import numpy as np ## 'np' here is short-hand name of the library (numpy) or a nickname.
A = np.array([4,3])
B = np.array([2,-5])
C = np.array([
              [4],
              [3],
              [-2]
])
D = np.array([
              [2],
              [-2],
              [3]
])
print(A)
print(B)
print(C)
print(D)<jupyter_output>[4 3]
[ 2 -5]
[[ 4]
 [ 3]
 [-2]]
[[ 2]
 [-2]
 [ 3]]<jupyter_text>Describing vectors in NumPyDescribing vectors is very important if we want to perform basic to advanced operations with them. The fundamental ways in describingvectors are knowing their shape, size and dimensions.<jupyter_code>A.shape
H = np.array([1,0,2,5,0.2,0])
H.shape
B.size
C.ndim<jupyter_output><empty_output><jupyter_text>Addition<jupyter_code>R = np.add(A,B)
P = np.add(C,D)
R
P
R = A + B
R
pos1 = np.array([0,0,0])
pos2 = np.array([0,1,3])
pos3 = np.array([1,5,-2])
pos4 = np.array([5,-3,3])
#R = pos1 + pos2 + pos3 + pos4
#R = np.multiply(pos3,pos4)
R = pos3/pos4
R<jupyter_output><empty_output><jupyter_text>Try for yourself<jupyter_code>### Try<jupyter_output><empty_output><jupyter_text>Scaling<jupyter_code>#S = 5 *A
S = np.multiply(5,A)
S<jupyter_output><empty_output><jupyter_text>Try to implement scaling with two vectors<jupyter_code><jupyter_output><empty_output><jupyter_text>MatPLotLib MatPlotLib or MATLab Plotting library is Python's take on MATLabs plotting feature. MatPlotLib can be used vastly from graping values tovisualizing several dimensions of data.  Visualizing Data<jupyter_code>import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
A = [1,-1]
B = [5,2]
#plt.plot(A, label='A')
#plt.plot(B ,label='B')
plt.scatter(A[0],A[1] ,label='A',c='green')
plt.scatter(B[0],B[1] ,label='B',c='red')
plt.grid()
plt.legend()
plt.show()

A = np.array([1,-1])
B = np.array([1,5])
plt.title("Resultant Vector\nMagnitude:{}".format(Magnitude))
plt.xlim(-5,5)
plt.ylim(-5,5)
plt.quiver(0,0,A[0],A[1],angles='xy',scale_units='xy',scale=1,color='red')
plt.quiver(A[0],A[1],B[0],B[1],angles='xy',scale_units='xy',scale=1,color='green')
R = A + B
plt.quiver(0,0,R[0],R[1],angles='xy',scale_units='xy',scale=1,color='blue')
plt.grid()
plt.show()
Magnitude = np.sqrt(np.sum(R**2))
print(Magnitude)
Slope = R[1]/R[0]
print(Slope)
Angle = (np.arctan(Slope))*(180/np.pi)
print(Angle)<jupyter_output><empty_output><jupyter_text>activity put it in a statement Try plotting Three Vectors and show the Resultant Vector as a result. Use Head to Tail Method.<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17015781922525108, 'fraction_numerical': 0.03299856527977044, 'mean_word_length': 4.677524429967427, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '397645', 'license': 'Apache-2.0', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1341, 'n_words': 336, 'path': 'LinAlg_Lab2_checkpoint.ipynb', 'repo_name': 'AndrewInterino/LinearAlg2021-2022', 'size': '3485'}