Created
February 19, 2020 03:15
-
-
Save fish8/3e717381a671a9d6ea80e9e284849824 to your computer and use it in GitHub Desktop.
sympy string expression to latex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sympy as sp | |
from collections import defaultdict | |
class GenerateSymbols(defaultdict): | |
def __missing__(self, key): | |
self[key] = sp.Symbol(key) | |
return self[key] | |
#global symbols in dictionary | |
gl = GenerateSymbols() | |
sp.latex(eval ('x1**2+alpha*y_i',gl)) #'\\alpha y_{i} + x_{1}^{2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment