Ask Your Question
1

Efficient way to define many variables?

asked 2019-06-09 10:38:14 +0200

anon gravatar image

updated 2019-06-09 10:39:45 +0200

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-06-09 10:49:14 +0200

FrédéricC gravatar image

If you mean polynomial variables:

sage: R = PolynomialRing(QQ, x, 44)
sage: x = R.gens()
sage: x[33]
x33
edit flag offensive delete link more

Comments

great thank you!

anon gravatar imageanon ( 2019-06-09 11:12:46 +0200 )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.

slelievre gravatar imageslelievre ( 2019-06-10 11:26:04 +0200 )edit

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: 2019-06-09 10:38:14 +0200

Seen: 1,219 times

Last updated: Jun 09 '19