# Efficient way to define many variables?

Hi, I want to use a computer to look at some examples of a certain determinant function. This function depends on many variables (like up to 50-100 in some examples), and the only way I know how to define variables at the moment is something like this:

a, b, c = var('a, b, c')

So, this limits me to using no more than 26 variables. I would like to have variables x_{i,j}, y_{i,j}, z_{i,j} which are indexed by a pair of positive integers i,j not exceeding a number n (which will depend on the example I'm doing, e.g. let's say n=10).

Is there a good way to define all these variables and have Sage recognize them?

Also, this determinant is a polynomial in these variables, and many terms will cancel. Is there a way to get Sage to simplify the expression and make these cancellations? It seems I would need to tell it that my variables commute with each other, which I don't know how to do.

edit retag close merge delete

Sort by » oldest newest most voted

If you mean polynomial variables:

sage: R = PolynomialRing(QQ, x, 44)
sage: x = R.gens()
sage: x[33]
x33

more

great thank you!

( 2019-06-09 04:12:46 -0500 )edit

@anon -- if this answers your question, please click the "accept" button (tick mark) at the top left of the question. This will mark the answer as accepted and mark your question as answered in the list of questions on the front page of Ask Sage and in results for searches on Ask Sage.

( 2019-06-10 04:26:04 -0500 )edit