[sympy](https://docs.sympy.org/latest/index.html)


```python
# pip install sympy
# Jacobian https://docs.sympy.org/latest/modules/matrices/matrices.html

from sympy import sin, cos, Matrix
from sympy.abc import rho, phi
X = Matrix([rho*cos(phi), rho*sin(phi), rho**2])
Y = Matrix([rho, phi])
X.jacobian(Y)
```




$\displaystyle \left[\begin{matrix}\cos{\left(\phi \right)} & - \rho \sin{\left(\phi \right)}\\\sin{\left(\phi \right)} & \rho \cos{\left(\phi \right)}\\2 \rho & 0\end{matrix}\right]$




```python
X = Matrix([rho*cos(phi), rho*sin(phi)])
X.jacobian(Y)
```




$\displaystyle \left[\begin{matrix}\cos{\left(\phi \right)} & - \rho \sin{\left(\phi \right)}\\\sin{\left(\phi \right)} & \rho \cos{\left(\phi \right)}\end{matrix}\right]$




```python

```


```python
from sympy import MatrixSymbol, Matrix,diff
X = MatrixSymbol('X', 3, 3)
Y = MatrixSymbol('Y', 3, 3)
Z = (X.T*X).I*Y
```


```python
Z = (X.T*Y)*X
Z.diff(X).simplify()

# from sympy import derive_by_array
# derive_by_array(Z, X)

n=5
A = MatrixSymbol("A", n, n)
x = MatrixSymbol("x", n, 1)
diff(A.T*x, x)

```




$\displaystyle A$




```python
# https://github.com/sympy/sympy/issues/5858
x = MatrixSymbol("x", n, n)
diff(A.T*x, x)
```




$\displaystyle \frac{\partial}{\partial x} A^{T} x$



99206a919f282cd95b13f524f0461bc50a58fc86
ipynb
Jupyter Notebook
automatic_and_symbolic_differentiation/symbolic_differentiation.ipynb
shadialameddin/numerical_tools_and_friends
cc9f10f58886ee286ed89080e38ebd303d3c72a5
Unlicense
automatic_and_symbolic_differentiation/symbolic_differentiation.ipynb
shadialameddin/numerical_tools_and_friends
cc9f10f58886ee286ed89080e38ebd303d3c72a5
Unlicense
automatic_and_symbolic_differentiation/symbolic_differentiation.ipynb
shadialameddin/numerical_tools_and_friends
cc9f10f58886ee286ed89080e38ebd303d3c72a5
Unlicense
Qwen/Qwen-72B
1. YES
2. YES