I believe I learned of a Python package which can automatically convert a Python function into mathematical notation. For example, when applied to
def power(a, b):
return a**b
the package would produce
power = ab
in a Jupyter Notebook, possibly using LaTeX.
Does anyone know what that package is?
Edit: I was thinking of a single-purpose package. I’m aware of SymPy and was not thinking of that, but the answer by @cards suggests it could work.
Someone on Mastodon reminded me of the package I was thinking of: latexify.
latexify is a Python package to compile a fragment of Python source code to a corresponding LaTeX expression
It can extract the mathematical operations from all lines of a function. Examples are in a Google Colab notebook.