Physics Derivation Graph navigation Sign in

sympy to AST using latex

Published 2020-05-01T21:55:00Z by Physics Derivation Graph

Given an expression in Latex, extract the symbols:
based on

>>> import sympy
>>> from sympy.parsing.latex import parse_latex
>>> symp_lat = parse_latex('x^2 + a x + b = 0')

>>> symp_lat.atoms(sympy.Symbol)
{x, b, a}

Given an expression in Latex, generate the graphviz of the AST:

>>> graphviz_of_AST_for_expr =