```python
from sympy.abc import x,y,z
from sympy import sin,Matrix
from sympy import *
import numpy as np
```

### Jacobian
Use sympy to replicate the MATLAB documentation https://uk.mathworks.com/help/symbolic/jacobian.html

#### 1. Jacobian of Vector Function


```python
X = Matrix([x*y*z,y**2,x+z])
Y = Matrix([x,y,z])
X.jacobian(Y)
```




$\displaystyle \left[\begin{matrix}y z & x z & x y\\0 & 2 y & 0\\1 & 0 & 1\end{matrix}\right]$



#### 2. Jacobian of Scalar Function


```python
X = Matrix([2*x+3*y+4*z])
Y = Matrix([x,y,z])
X.jacobian(Y)
```




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



#### 3. Jacobian with Respect to Scalar


```python
X = Matrix([x**2*y,x*sin(y)])
Y = Matrix([x])
a = X.jacobian(Y)
```


```python
print(a)
```

    Matrix([[2*x*y], [sin(y)]])



```python
b = a.subs([(x,0),(y,0)])
```


```python
print(b)
```

    Matrix([[0], [0]])



```python
np.array(b).astype(int).squeeze()+1
```




    array([1, 1])



#### 4. Others


```python
x, y = symbols('x y')
f = x + y
f.subs([(x,10),(y,20)])
f
```




$\displaystyle x + y$




```python
x, y, z, t = symbols('x y z t')
expr = cos(x)+1
expr.subs(x,y)
```




$\displaystyle \cos{\left(y \right)} + 1$




```python
a = expr.subs(x,0)
```


```python
print(a+1)
```

    3



```python

```

1da54f51069522d53ac78f2db1f8eed605c1d0fe
ipynb
Jupyter Notebook
Robotics/Jacobian/.ipynb_checkpoints/Jacobian-checkpoint.ipynb
zcemycl/ProbabilisticPerspectiveMachineLearning
8291bc6cb935c5b5f9a88f7b436e6e42716c21ae
MIT
2019-11-20T10:20:29.000Z
2021-11-09T11:15:23.000Z
Capstone/Jacobian/Jacobian.ipynb
kasiv008/Robotics
302b3336005acd81202ebbbb0c52a4b2692fa9c7
MIT
Capstone/Jacobian/Jacobian.ipynb
kasiv008/Robotics
302b3336005acd81202ebbbb0c52a4b2692fa9c7
MIT
2020-05-27T03:56:38.000Z
2021-05-02T13:15:42.000Z
Qwen/Qwen-72B
1. YES
2. YES