Ask Your Question
0

How does sage manages same name variables

asked 2020-04-25 17:09:06 -0500

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 02:54:48 -0500

Sébastien gravatar image

updated 2020-04-26 02:57:55 -0500

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-25 17:09:06 -0500

Seen: 64 times

Last updated: Apr 26