### Computing for Mathematics - 2021/2022 individual coursework

**Important** Do not delete the cells containing: 

```
### BEGIN SOLUTION


### END SOLUTION
```

write your solution attempts in those cells.

To submit this notebook:

- Change the name of the notebook from `main` to: `<student_number>`. For example, if your student number is `c1234567` then change the name of the notebook to `c1234567`.
- **Write all your solution attempts in the correct locations**;
- **Do not delete** any code that is already in the cells;
- Save the notebook (`File>Save As`);
- Follow the instructions given to submit.

#### Question 1

(__Hint__: This question is similar to [the first exercise of the Matrices chapter](https://vknight.org/pfm/tools-for-mathematics/04-matrices/solutions/main.html#question-1) of Python for mathematics.)

For each of the following matrices **output** their determinant.

a. \\(\begin{pmatrix}4 & 4 & 4 \\ 0 & 2 & 0 \\ 12 & 12 & 12\end{pmatrix}\\)

Available marks: 1


```python
import sympy as sym

### BEGIN SOLUTION


### END SOLUTION
```

b. \\(\begin{pmatrix}3\end{pmatrix}\\)

_Available marks: 1_


```python
x = sym.Symbol("x")

### BEGIN SOLUTION


### END SOLUTION
```

c. \\(\begin{pmatrix}50 \pi & 40 e & 1 \\ 12 & 3 & 1 \\ -500 & 400 & 
\pi ^e\end{pmatrix}\\)

_Available marks: 2_


```python
### BEGIN SOLUTION


### END SOLUTION
```

### Question 2


(__Hint__: This question is similar to the [second exercise of the Sequences chapter of Python for mathematics](https://vknight.org/pfm/tools-for-mathematics/07-sequences/solutions/main.html#question-2).)

Using recursion, create a function `get_sequence` which gives the terms of the following sequence:

\\[
\begin{cases}
a_0 &= -2\\
a_n & 4 a_{n-1}, n\geq 1
\end{cases}
\\]

_Available marks: 2_


```python
def get_sequence(n):
### BEGIN SOLUTION


### END SOLUTION
```

### Question 3

(__Hint__: This question is similar to the [fourth exercise of the Matrices chapter of Python for mathematics](https://vknight.org/pfm/tools-for-mathematics/04-matrices/solutions/main.html#question-4).)

The matrix \\(A\\) is given by: \\(
    \begin{pmatrix}
        4 & 3 & 2 & 3\\
        3 & 1 & 1 & 3\\
        0 & -1 & 2 & 1\\
        0 & 2 & 2 & 3\\
    \end{pmatrix}\\)


a. Create a variable `A_inv` which has value the inverse of `A`

_Available marks: 2_


```python
### BEGIN SOLUTION


### END SOLUTION
```

b. Create a variable `x_sol` which has value the vector 
representing the solution to the following linear system:
    
\\[
  \begin{eqnarray}
    4 x_1 + 3 x_2 + 2 x_3 + 3 x_4 &= 2\\
    3 x_1 + x_2 + x_3 + 3 x_4 &= 7\\
    - x_2 + 2 x_3 + x_4 &= 7\\
    2 x_2 + 2 x_3 + 3 x_4 &= 0\\
  \end{eqnarray}
\\]

_Available marks: 2_


```python
### BEGIN SOLUTION


### END SOLUTION
```

### Question 4

(__Hint__: This question is similar to the [second exercise of the Algebra chapter of Python for mathematics](https://vknight.org/pfm/tools-for-mathematics/03-calculus/solutions/main.html#question-2))

Consider the function: \\(f(x)=\frac{\cos(x)}{x}\\).

a. Create a variable `expression` which has value: \\(\frac{f(x)- f(x-h)}{h}\\)

_available marks: 2_


```python
h = sym.Symbol("h")

### BEGIN SOLUTION


### END SOLUTION
```

b. Create a variable `limit` which has value: \\(\lim_{h\to 0}\frac{f(x) - f(x-h)}{h}\\)

_available marks: 1_


```python
### BEGIN SOLUTION


### END SOLUTION
```


```python
limit
```




$\displaystyle - \frac{x \sin{\left(x \right)} + \cos{\left(x \right)}}{x^{2}}$



c. Using this, output the value \\(\frac{df}{dx}\\) at \\(x=\pi\\).

*available marks: 1*


```python
import math

### BEGIN SOLUTION


### END SOLUTION
```

c04a11ec807c9d29fa05142b9408bce899140f12
ipynb
Jupyter Notebook
assets/assessment/2021-2022/ind/assignment.ipynb
drvinceknight/cfm
06977f5c1ba37590b17a8d2a22f57e3575875b3b
MIT
2016-08-25T01:05:20.000Z
2021-07-04T16:17:06.000Z
assets/assessment/2021-2022/ind/assignment.ipynb
drvinceknight/cfm
06977f5c1ba37590b17a8d2a22f57e3575875b3b
MIT
2016-08-24T20:08:15.000Z
2021-12-19T23:26:14.000Z
assets/assessment/2021-2022/ind/assignment.ipynb
drvinceknight/cfm
06977f5c1ba37590b17a8d2a22f57e3575875b3b
MIT
2016-09-22T12:36:03.000Z
2019-03-13T13:21:30.000Z
Qwen/Qwen-72B
1. YES
2. YES

