```python
from sympy import *
init_printing(use_unicode=True)
from IPython.display import display
```

# Task 1


```python
#v0, v1= Symbol('v_0'), Symbol('v_1')

v0 = Matrix([[0.5], [0.5], [0.5], [0.5]])
v1 = Matrix([[0.5], [0.5], [-0.5], [-0.5]])

v0.dot(v1)
```

#### Answer: 0

# Task 2. 
If $\{\mathbf{v}^{(0)},\ \mathbf{v}^{(1)},\ \mathbf{v}^{(2)},\ \mathbf{v}^{(3)}\}$ is a full **orthonormal** basis, the following system of equations must be satisfied:

$$\begin{cases}
\langle \mathbf{v}^{(0)}, \mathbf{v}^{(3)}\rangle = 0 \\ 
\langle \mathbf{v}^{(1)}, \mathbf{v}^{(3)}\rangle = 0 \\ 
\langle \mathbf{v}^{(2)}, \mathbf{v}^{(3)}\rangle = 0 \\ 
\langle \mathbf{v}^{(3)}, \mathbf{v}^{(3)}\rangle = 1 
\end{cases}$$

Let $\mathbf{v}^{(3)} = \begin{pmatrix} a & b & c & d \end{pmatrix}$.


```python
v2 = Matrix([[0.5], [-0.5], [0.5], [-0.5]])
a, b, c, d = symbols('a b c d')
v3 = Matrix([[a], [b], [c], [d]])
answer = solve([v0.dot(v3), v1.dot(v3), v2.dot(v3), v3.dot(v3)-1], (a, b, c, d))
answer
```

#### Answer: 2

# Task 3.

Let expansion coefficients vector $\mathbf x = \begin{pmatrix} a & b & c & d \end{pmatrix}$.


```python
v3 = Matrix(next(iter(answer)))
y = Matrix([2.5, 0.5, 1.5, -0.5])
x = (a, b, c, d)

basis_matrix = v0.row_join(v1).row_join(v2).row_join(v3)
linsolve((basis_matrix, y), x)
```

#### Answer: 2.0 1.0 2.0 0.0

# Task 4.
We just need to solve 4 sytems of linear equations in this task


```python
solve([y.dot(x), v1.dot(x), v2.dot(x), v3.dot(x)], (a, b, c, d))
```


```python
solve([y.dot(x), v0.dot(x), v1.dot(x), v2.dot(x)], (a, b, c, d))
```


```python
solve([y.dot(x), v0.dot(x), v2.dot(x), v3.dot(x)], (a, b, c, d))
```


```python
solve([y.dot(x), v1.dot(x), v2.dot(x), (v3-2*v1).dot(x)], (a, b, c, d))
```

#### Answer: cells 1, 3 and 4 must be selected

# Task 5.
Solution is very simple.

New $\mathbf{x'}=\begin{bmatrix} x_0-x_2 \\ x_1-x_0 \\ x_2-x_1 \end{bmatrix} = \begin{bmatrix} 1 \cdot x_0 + 0 \cdot x_1 -1 \cdot x_2 \\ -1 \cdot x_0 + 1 \cdot x_1 + 0 \cdot x_2 \\ 0 \cdot x_0 -1 \cdot x_1 + 1 \cdot x_2 \end{bmatrix} $. Now we can determine the matrix $\mathbf{F}=\begin{bmatrix} 1 && 0 && -1 \\ -1 && 1 && 0 \\ 0 && -1 && 1 \end{bmatrix}$.

#### Answer: 1 0 -1 -1 1 0 0 -1 1

# Task 6.
In the task 5 the matrix $\mathbf{D}$ was defined, that matrix represents delay by 1 (right shift). In this task the matrix $\mathbf{A}$ is a delay matrix again.

Thus $\mathbf{A}^4=\begin{bmatrix} 1 && 0 && 0 && 0 \\ 0 && 1 && 0 && 0 \\ 0 && 0 && 1 && 0 \\ 0 && 0 && 0 && 1 \end{bmatrix}$.


```python
A = Matrix([[0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]])
A**4
```

#### Answer: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

af3653bf7a175bb3b5fc6e038c3242a7d4f111b1
ipynb
Jupyter Notebook
hw2.ipynb
hshi24/coursera-dsp-hw
b7302b5f2457691e25d28025223ec042c192c371
MIT
2021-02-06T08:30:21.000Z
2021-02-06T08:30:21.000Z
hw2.ipynb
hshi24/coursera-dsp-hw
b7302b5f2457691e25d28025223ec042c192c371
MIT
hw2.ipynb
hshi24/coursera-dsp-hw
b7302b5f2457691e25d28025223ec042c192c371
MIT
Qwen/Qwen-72B
1. YES
2. YES