How to use sympy.latex()
and sympy.sympify()
to produce unevaluated parameterized expression fr'\frac{{3}}{{{i}}}'
?
from IPython.display import display, Math
import sympy as sym
for i in range(-1,2):
display(Math(fr'\frac{{3}}{{{i}}}'))
for i in range(-1,2):
display(Math(sym.latex(sym.sympify(f'3/{i}'))))
Edit
The objective is to generate:
fr'\frac{{3}}{{{-1}}}'
fr'\frac{{3}}{{{0}}}'
fr'\frac{{3}}{{{1}}}'
with sympy.latex()
and sympy.sympify()
(or its variant).
CodePudding user response:
Just set evaluate=False
into sympify
:
for i in range(-1,2):
display(Math(sym.latex(sym.sympify(f'3/{i}', evaluate=False))))