```python
import numpy as np
from sympy import *
init_printing(use_latex='mathjax')
```


```python
x1, x2, t = symbols('x1 x2 t')

F = Matrix([
    x1 ** 2 * x2 ** 2 + x1 * x2,
    1 - t ** 2,
    1 + t ** 2
])
F.jacobian([x1,x2, t])
```




$$\left[\begin{matrix}2 x_{1} x_{2}^{2} + x_{2} & 2 x_{1}^{2} x_{2} + x_{1} & 0\\0 & 0 & - 2 t\\0 & 0 & 2 t\end{matrix}\right]$$




```python
x1, x2, x3, t = symbols('x1 x2 x3 t')

F = Matrix([
       x1 ** 3 * cos(x2) * exp(x3)
])
T = Matrix([
    2 * t,
    1 - t ** 2,
    exp(t)
])
jf = F.jacobian([x1,x2, x3])
jt = T.jacobian([t])
display(jf)
display(jt)
```


$$\left[\begin{matrix}3 x_{1}^{2} e^{x_{3}} \cos{\left (x_{2} \right )} & - x_{1}^{3} e^{x_{3}} \sin{\left (x_{2} \right )} & x_{1}^{3} e^{x_{3}} \cos{\left (x_{2} \right )}\end{matrix}\right]$$



$$\left[\begin{matrix}2\\- 2 t\\e^{t}\end{matrix}\right]$$



```python
x1, x2, u1, u2, t = symbols('x1 x2 u1, u2, t')

F = Matrix([
    x1 ** 2 - x2 ** 2
])
U = Matrix([
    2 * u1 + 3 * u2,
    2 * u1 - 3 * u2
])
T = Matrix([
    cos(t / 2),
    sin(2 * t)
])
jf = F.jacobian([x1,x2, x3])
ju = U.jacobian([u1, u2])
jt = T.jacobian([t])
display(jf)
display(ju)
display(jt)
```


$$\left[\begin{matrix}2 x_{1} & - 2 x_{2} & 0\end{matrix}\right]$$



$$\left[\begin{matrix}2 & 3\\2 & -3\end{matrix}\right]$$



$$\left[\begin{matrix}- \frac{1}{2} \sin{\left (\frac{t}{2} \right )}\\2 \cos{\left (2 t \right )}\end{matrix}\right]$$



```python
x1, x2, u1, u2, t = symbols('x1 x2 u1, u2, t')

F = Matrix([
    cos(x1)*sin(x2)
])
U = Matrix([
    2 * u1 ** 2 + 3 * u2 ** 2 - u2,
    2 * u1 - 5 * u2 ** 3
])
T = Matrix([
    exp(t / 2),
    exp(-2 * t)
])
jf = F.jacobian([x1,x2, x3])
ju = U.jacobian([u1, u2])
jt = T.jacobian([t])
display(jf)
display(ju)
display(jt)
```


$$\left[\begin{matrix}- \sin{\left (x_{1} \right )} \sin{\left (x_{2} \right )} & \cos{\left (x_{1} \right )} \cos{\left (x_{2} \right )} & 0\end{matrix}\right]$$



$$\left[\begin{matrix}4 u_{1} & 6 u_{2} - 1\\2 & - 15 u_{2}^{2}\end{matrix}\right]$$



$$\left[\begin{matrix}\frac{e^{\frac{t}{2}}}{2}\\- 2 e^{- 2 t}\end{matrix}\right]$$



```python
x1, x2, x3, u1, u2, t = symbols('x1 x2 x3 u1 u2 t')

F = Matrix([
    sin(x1) * cos(x2) * exp(x3)
])
U = Matrix([
    sin(u1) + cos(u2),
    cos(u1) - sin(u2),
    exp(u1 + u2)
])
T = Matrix([
    1 + t / 2,
    1 - t / 2
])
jf = F.jacobian([x1,x2, x3])
ju = U.jacobian([u1, u2])
jt = T.jacobian([t])
display(jf)
display(ju)
display(jt)
```


$$\left[\begin{matrix}e^{x_{3}} \cos{\left (x_{1} \right )} \cos{\left (x_{2} \right )} & - e^{x_{3}} \sin{\left (x_{1} \right )} \sin{\left (x_{2} \right )} & e^{x_{3}} \sin{\left (x_{1} \right )} \cos{\left (x_{2} \right )}\end{matrix}\right]$$



$$\left[\begin{matrix}\cos{\left (u_{1} \right )} & - \sin{\left (u_{2} \right )}\\- \sin{\left (u_{1} \right )} & - \cos{\left (u_{2} \right )}\\e^{u_{1} + u_{2}} & e^{u_{1} + u_{2}}\end{matrix}\right]$$



$$\left[\begin{matrix}\frac{1}{2}\\- \frac{1}{2}\end{matrix}\right]$$



```python

```

9db75be7f04ce1bcf44dece345ba6204da12c53d
ipynb
Jupyter Notebook
Certification 2/Week3.1 - Multivariate Chain rule.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
2018-04-16T02:53:59.000Z
2021-05-16T06:51:57.000Z
Certification 2/Week3.1 - Multivariate Chain rule.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
Certification 2/Week3.1 - Multivariate Chain rule.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
2019-05-20T02:06:55.000Z
2020-05-18T06:21:41.000Z
Qwen/Qwen-72B
1. YES
2. YES