Skip to content
Snippets Groups Projects
Commit 178acef1 authored by Benjamin Berkels's avatar Benjamin Berkels
Browse files

Upload New File

parent 69720a83
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
### IPython notebook for Example 2.3.3 from the lecture
%% Cell type:code id: tags:
``` python
import numpy as np
from IPython.display import display, Math
display(Math(r'A \in \mathbb{R}^{6 \times 3}, A_1 \in \mathbb{R}^{6 \times 4}\text{ from Example 1.1.1}'))
delta_t = 0.15
n = 6
t = np.arange(1, n+1) * delta_t
A_1 = np.stack((t, np.exp(t), t**3, np.sin(t)), axis=1)
A = A_1[:, :-1]
print("A_1 = ")
print(A_1)
print("A = ")
print(A)
```
%% Cell type:code id: tags:
``` python
display(Math(r'U^TAV=\Sigma'))
U, sigma, VT = np.linalg.svd(A)
np.set_printoptions(precision=4, suppress=True)
print("sigma(A) =", sigma)
print("kappa(A) = {:.1f}".format(sigma[0]/sigma[-1]))
```
%% Cell type:code id: tags:
``` python
display(Math(r'U_1^TA_1V_1=\Sigma_1'))
U_1, sigma_1, VT_1 = np.linalg.svd(A_1)
np.set_printoptions(precision=5)
print("sigma(A_1) =", sigma_1)
print("kappa(A_1) = {:.1e}".format(sigma_1[0]/sigma_1[-1]))
```
%% Cell type:code id: tags:
``` python
display(Math(r'\delta y^1=10^{-2} \begin{pmatrix} 1 & 0 & -1 & -1 & -0.5 & 1 \end{pmatrix}^T'))
delta_y1 = 1e-2*np.array([1, 0, -1, -1, -0.5, 1])
display(Math(r'\delta y^2=10^{-2}\begin{pmatrix} -1 & 1 & 1 & -0.5 & -2 & 1 \end{pmatrix}^T'))
delta_y2 = 1e-2*np.array([-1, 1, 1, -0.5, -2, 1])
```
%% Cell type:code id: tags:
``` python
np.set_printoptions(precision=4)
print("U_1^T\delta y^1 =", np.matmul(U_1.T, delta_y1))
print("U_1^T\delta y^2 =", np.matmul(U_1.T, delta_y2))
display(Math(r'\Rightarrow\ \delta y^1\text{ is dominated by }u_3, \delta y^2\text{ dominated by }u_4'))
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment