<jupyter_start><jupyter_text>Mandatory exercises Consider the system $Ax = b$ where\begin{equation}    A=\begin{bmatrix}        2 & 1 & 2\\        1 & 0 & 3\\        4 & -3 & -1    \end{bmatrix}    \text{ and }    b=\begin{bmatrix}        -3\\        1\\        -6    \end{bmatrix}\end{equation} 1. Perform the $LU$-factorization of the matrix $A$ by using Gaussian elimination with partial pivoting. Conclude by specifying $L$, $U$, and the permutation matrix $P$ . How is $A$ related to the matrices $L, U$ and $P$?<jupyter_code>import scipy.linalg
import scipy
import numpy as np

A = np.array([[2, 1, 2],
     [1, 0, 3],
     [4, -3, -1]])
P, L, U = scipy.linalg.lu(A)

print('A='+str(A))
print('P='+str(P))
print('L='+str(L))
print('U='+str(U))

print(scipy.dot(P.T,A))
print(scipy.dot(L,U))<jupyter_output>A=[[ 2  1  2]
 [ 1  0  3]
 [ 4 -3 -1]]
P=[[0. 1. 0.]
 [0. 0. 1.]
 [1. 0. 0.]]
L=[[1.   0.   0.  ]
 [0.5  1.   0.  ]
 [0.25 0.3  1.  ]]
U=[[ 4.  -3.  -1. ]
 [ 0.   2.5  2.5]
 [ 0.   0.   2.5]]
[[ 4. -3. -1.]
 [ 2.  1.  2.]
 [ 1.  0.  3.]]
[[ 4.00000000e+00 -3.00000000e+00 -1.00000000e+00]
 [ 2.00000000e+00  1.00000000e+00  2.00000000e+00]
 [ 1.00000000e+00  1.11022302e-16  3.00000000e+00]]
{'fraction_non_alphanumeric': 0.2202826267664173, 'fraction_numerical': 0.14380714879467996, 'mean_word_length': 2.2628726287262872, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '269243', 'license': 'MIT', 'n_tokens_mistral': 667, 'n_tokens_neox': 556, 'n_words': 144, 'path': 'Workouts/Workout1.ipynb', 'repo_name': 'enigne/ScientificComputingBridging', 'size': '1203'}