First time here? Check out the FAQ!

Ask Your Question
1

Efficient way to define many variables?

asked 5 years ago

anon gravatar image

updated 5 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

FrédéricC gravatar image

If you mean polynomial variables:

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

Comments

great thank you!

anon gravatar imageanon ( 5 years ago )

@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.

slelievre gravatar imageslelievre ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 1,921 times

Last updated: Jun 09 '19