Ask Your Question
0

How does sage manages same name variables

asked 2020-04-26 00:09:06 +0100

Recruiter gravatar image

Says I have 2 matrix named M in different cells how do they affect each other? Can it be dangerous?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-04-26 09:54:48 +0100

Sébastien gravatar image

updated 2020-04-26 09:57:55 +0100

It does this:

sage: M = identity_matrix(2)
sage: M
[1 0]
[0 1]
sage: M = 4
sage: M
4

In the noteboook, the most recent evaluated cell with M= ... will erase the previous affectation of the variable M.

The magic function %whos returns a table of type/value for each current variables that are defined and as you see, only one value is assigned to each variable:

sage: %whos
Variable   Type                                Data/Info
--------------------------------------------------------
M          Integer                             4
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2020-04-26 00:09:06 +0100

Seen: 198 times

Last updated: Apr 26 '20