<jupyter_start><jupyter_text>Question 1<jupyter_code># Question 1. Create a Python code that displays a square matrix whose length
# is 5 (10 points)

import numpy as np

q1 = np.full((5,5), 1)
print(q1)<jupyter_output>[[1 1 1 1 1]
 [1 1 1 1 1]
 [1 1 1 1 1]
 [1 1 1 1 1]
 [1 1 1 1 1]]<jupyter_text>Question 2<jupyter_code># Question 2. Create a Python code that displays a square matrix whose elements
# below the principal diagonal are zero (10 points)

q2 = np.array([[1,2,3,4,5],[0,6,7,8,9],[0,0,10,11,12],[0,0,0,13,14],[0,0,0,0,15]])
print(q2)<jupyter_output>[[ 1  2  3  4  5]
 [ 0  6  7  8  9]
 [ 0  0 10 11 12]
 [ 0  0  0 13 14]
 [ 0  0  0  0 15]]<jupyter_text>Question 3<jupyter_code># Question 3. Create a Python code that displays a square matrix which is
# symmetrical (10 points)
# Edit, This code block didn't get updated

q3_a = np.array([[0,1,2],[3,4,5],[6,7,8]])
q3_b = np.transpose(q3_a)
print(q3_a)
print('symmetric transpose')
print(q3_b)<jupyter_output>[[0 1 2]
 [3 4 5]
 [6 7 8]]
symmetric transpose
[[0 3 6]
 [1 4 7]
 [2 5 8]]<jupyter_text>Question 4<jupyter_code># Question 4. What is the inverse of matrix C? Show your solution by python 
# coding. (20 points)

q4_a = np.array([[1,2,3],[2,3,3],[3,4,-2]])
q4 = np.linalg.inv(q4_a)
print(q4_a)
print()
print(q4)<jupyter_output>[[ 1  2  3]
 [ 2  3  3]
 [ 3  4 -2]]

[[-3.6  3.2 -0.6]
 [ 2.6 -2.2  0.6]
 [-0.2  0.4 -0.2]]<jupyter_text>Question 5<jupyter_code># Question 5. What is the determinant of the given matrix in Question 4? Show 
# your solution by python coding. (20 points)

print(q4_a)
print(round(np.linalg.det(q4_a)))<jupyter_output>[[ 1  2  3]
 [ 2  3  3]
 [ 3  4 -2]]
5<jupyter_text>Question 6<jupyter_code># Question 6. Find the roots of the linear equations by showing its python codes
# (30 points)
# 5X1 + 4X2 + X3 = 3.4
# 10X1 + 9X2 + 4X3 = 8.8
# 10X1 + 13X2 + 15X3 = 19.2

print('given:')
print('5X1 + 4X2 + X3 = 3.4')
print('10X1 + 9X2 + 4X3 = 8.8')
print('10X1 + 13X2 + 15X3 = 19.2')
print()
q6_A = np.array([[5,4,1],[10,9,4],[10,13,15]])
q6_B = np.array([[3.4],[8.8],[19.2]])
print(q6_A)
print(q6_B)
print()
q6 = np.linalg.inv(q6_A).dot(q6_B)
print(q6)
print()
print('proof')
print('X1 =',q6[0], 'X2 =',q6[1], 'X3 =',q6[2])
print()
print('5X1 + 4X2 + X3 =',(5*q6[0])+(4*q6[1])+(q6[2]))
print('10X1 + 9X2 + 4X3 =',(10*q6[0])+(9*q6[1])+(4*q6[2]))
print('10X1 + 13X2 + 15X3 =',(10*q6[0])+(13*q6[1])+(15*q6[2]))<jupyter_output>given:
5X1 + 4X2 + X3 = 3.4
10X1 + 9X2 + 4X3 = 8.8
10X1 + 13X2 + 15X3 = 19.2

[[ 5  4  1]
 [10  9  4]
 [10 13 15]]
[[ 3.4]
 [ 8.8]
 [19.2]]

[[0.2]
 [0.4]
 [0.8]]

proof
X1 = [0.2] X2 = [0.4] X3 = [0.8]

5X1 + 4X2 + X3 = [3.4]
10X1 + 9X2 + 4X3 = [8.8]
10X1 + 13X2 + 15X3 = [19.2]
{'fraction_non_alphanumeric': 0.20660237388724034, 'fraction_numerical': 0.1632047477744807, 'mean_word_length': 3.8420107719928187, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '452043', 'license': 'Apache-2.0', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1369, 'n_words': 349, 'path': 'Midterm_Exam.ipynb', 'repo_name': 'CustodioJustin/Linear-Algebra-58019', 'size': '2696'}