<jupyter_start><jupyter_text>[sympy](https://docs.sympy.org/latest/index.html)<jupyter_code># 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)
X = Matrix([rho*cos(phi), rho*sin(phi)])
X.jacobian(Y)
from sympy import MatrixSymbol, Matrix,diff
X = MatrixSymbol('X', 3, 3)
Y = MatrixSymbol('Y', 3, 3)
Z = (X.T*X).I*Y
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)

# https://github.com/sympy/sympy/issues/5858
x = MatrixSymbol("x", n, n)
diff(A.T*x, x)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19799498746867167, 'fraction_numerical': 0.013784461152882205, 'mean_word_length': 5.549180327868853, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '583589', 'license': 'Unlicense', 'n_tokens_mistral': 362, 'n_tokens_neox': 348, 'n_words': 71, 'path': 'automatic_and_symbolic_differentiation/symbolic_differentiation.ipynb', 'repo_name': 'shadialameddin/numerical_tools_and_friends', 'size': '798'}