I need to define some variables in Sage with 2 indices and the second index is negative. For example, Y[2, -6]. I know how to define variables with one index:
rank=8
R=PolynomialRing(QQ, 'a' ,rank+1)
a=R.gens()
Edit: I tried the following codes to define Y[i,s]:
m, n = 8, 8
Y = {(i,j): var("Y_{}{}".format(i,j),
latex_name="Y_{{{}{}}}".format(i,j))
for i in [0..m] for j in [(-2*n)..0]}
But it is said that "The name "Y_0-16" is not a valid Python identifier".
Is there some way to define Y[i,s] in Sage? Thank you very much.
This may do what you want.
Usage:
We replaced the "minus sign"
-with anmin Python identifiers but the LaTeX name is as desired.In a Jupyter sheet,
%display latexwill ensure LaTeX rendering.