Issue
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).
Solution
Just set evaluate=False
into sympify
:
for i in range(-1,2):
display(Math(sym.latex(sym.sympify(f'3/{i}', evaluate=False))))
Answered By - Davide_sd
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.