Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Not sure of what your "double indexed variable means. One possible interpretation is a two-dimensionnal array of symbolic variables, flattened as needed :

sage: DIVar=[[var("alpha_%d_%d"%(u,v), latex_name="\\alpha_{%d,%d}"%(u, v)) for v in range(3)] for u in range(2)]

which is $$ \left[\left[{\alpha_{0,0}}, {\alpha_{0,1}}, {\alpha_{0,2}}\right], \left[{\alpha_{1,0}}, {\alpha_{1,1}}, {\alpha_{1,2}}\right]\right] $$

and can be used as:

sage: table([[f(u) for u in flatten(DIVar)] for f in (sin, cos, tan)], header_row=flatten(DIVar), header_column=[function("f")]+[sin, cos, tan])

  f   | alpha_0_0        alpha_0_1        alpha_0_2        alpha_1_0        alpha_1_1        alpha_1_2
+-----+----------------+----------------+----------------+----------------+----------------+----------------+
  sin | sin(alpha_0_0)   sin(alpha_0_1)   sin(alpha_0_2)   sin(alpha_1_0)   sin(alpha_1_1)   sin(alpha_1_2)
  cos | cos(alpha_0_0)   cos(alpha_0_1)   cos(alpha_0_2)   cos(alpha_1_0)   cos(alpha_1_1)   cos(alpha_1_2)
  tan | tan(alpha_0_0)   tan(alpha_0_1)   tan(alpha_0_2)   tan(alpha_1_0)   tan(alpha_1_1)   tan(alpha_1_2)

[ No LaTeX output here : the generated latex code uses tabular, not understood by ask.sagemath.org's Markdown. I know that there is a way to create an HTML version accepted here, but, for dear life, I'm unable to remember it... ].

HTH,