ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 18 Nov 2018 15:59:29 +0100question about Python assignment of lists; meaning of equals sign; how to save a list?https://ask.sagemath.org/question/44324/question-about-python-assignment-of-lists-meaning-of-equals-sign-how-to-save-a-list/I have a list, then modify it, but want to save the old list to then modify in a different way.
I try to save the original using a different name and =, but it seems the two names are forever linked by the equals sign,
so the modification also changes the original. Why does this happen, and how do I deal with this?
Example:
sage: L1 = [1, 2]
sage: L2 = [3, 4]
sage: L3 = L1
sage: L1
[1, 2]
sage: L2
[3, 4]
sage: L3
[1, 2]
sage: L1.extend(L2)
sage: L1
[1, 2, 3, 4]
sage: L2
[3, 4]
sage: L3
[1, 2, 3, 4]
The same thing happens with "append".
Help please!!!
Note: this does not happen with variables with numerical (not list) values. For example:
sage: a = 4
sage: b = a
sage: a = 5
sage: a
5
sage: b
4
So it seems that the equals sign means two different things: for numbers it is an assignment;
for lists it is an identification. This is driving me crazy. I cannot find it explained anywhere (maybe because it is so "well-known"?)alSun, 18 Nov 2018 15:59:29 +0100https://ask.sagemath.org/question/44324/Define a modular form from its $q$-expansion coefficientshttps://ask.sagemath.org/question/44072/define-a-modular-form-from-its-q-expansion-coefficients/I have a certain modular form for $\Gamma(N)$ and weight $0$ which I know but just by it's $q$-expansion coefficients, and I want to compute the action of Hecke operators on this modular form. How do I define a modular form object from its q-expansion coefficients, so that I can use it as an input for M.hecke_operator?voaFri, 26 Oct 2018 03:34:33 +0200https://ask.sagemath.org/question/44072/How to define Sage function with Optional arguments?https://ask.sagemath.org/question/35192/how-to-define-sage-function-with-optional-arguments/I need to define a Sage function with optional arguments.
The number of mandatory arguments is 2 and there are up to 3 optional arguments.
How do I do this is Sage?VovaWed, 19 Oct 2016 20:56:35 +0200https://ask.sagemath.org/question/35192/How to find limit of a recursive sequence?https://ask.sagemath.org/question/9562/how-to-find-limit-of-a-recursive-sequence/For example, I have this sequence:
f(0) = 1
f(n) = 1/5 * (f(n-1)^2 + f(n-1) + 3)
How do I find the limit of this sequence? I have been searching for how to do this for a while, but I can't find the answer.ZombifierSat, 24 Nov 2012 23:57:16 +0100https://ask.sagemath.org/question/9562/