ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 16 Apr 2019 02:25:03 -0500generate a list of variables with two indiceshttp://ask.sagemath.org/question/46214/generate-a-list-of-variables-with-two-indices/Hi
I would like to make a list of variables with two consecutive indices, example rr_10, rr_21 .. etc
I tried :
n=3
rrL=list(var('rr_%d%d' %i %(i-1)) for i in [1..n])
without success:**not enough arguments for format string**
what is the missing arguments here ? ortolljTue, 16 Apr 2019 02:25:03 -0500http://ask.sagemath.org/question/46214/return lists that do not share all of the same elementshttp://ask.sagemath.org/question/46159/return-lists-that-do-not-share-all-of-the-same-elements/ I am having Sage generate an array of lists for me, but I do not want it to give me the lists that have all of the same elements. For example, if Sage gives me
[1 2 3 4]
[2 3 4 1]
[1 3 4 2]
I only want Sage to give me [1 2 3 4]. I want to create a new array with these non-repeated lists. How do I do that? Thank you!merluzaSun, 14 Apr 2019 11:19:37 -0500http://ask.sagemath.org/question/46159/How do I get the result of right_kernel into a matrix?http://ask.sagemath.org/question/45935/how-do-i-get-the-result-of-right_kernel-into-a-matrix/Hello,
I have a simple program I am running where I define a matrix C, then define
B=C.right_kernel()
I would then like to create another matrix, D, that is a block matrix with C and B as blocks, C on top of B. So far my code for that is
Dlist = []
for i in range(len(rowsofmatrix)):
Dlist.append(C[i,:])
for i in range(20-len(rowsofmatrix)):
Dlist.append(B[i,:])
where rowsofmatrix is a list I used to define the matrix C. The Dlist.append(C[I,:]) works just fine, but the second one involving B does not, and I imagine this has something to do with the form of B. Is there a way I can express B as a regular matrix? Or, alternatively, is there a better way to do this altogether?
ThankscaucherThu, 28 Mar 2019 20:00:40 -0500http://ask.sagemath.org/question/45935/Divide Combinations(n,k) into multiple parts (n > 1110)http://ask.sagemath.org/question/45606/divide-combinationsnk-into-multiple-parts-n-1110/I asked a similar question here: https://ask.sagemath.org/question/45347/sagemath-heap-size-limit/. I closed it, because the answer matched the question there. However, now I have an extra question related to it:
C = Combinations(2110, 3)
C_cardinality = binomial(2110, 3) # 1.563.429.820
N = C_cardinality / 95 # Number of parts = 95 (chunk size)
R = range(0, C_cardinality , N)
Because C_cardinality is too big, I would like to divide C into multiple parts, which are then used on multiple computers to process separately. In order to be sure that these multiple parts are totally different but covering the whole C, I use C's list:
c0 = C.list()[R[0]:R[0]+N]
c1 = C.list()[R[1]:R[1]+N]
c2 = C.list()[R[2]:R[2]+N]
...
However, my computer's RAM (memory 128GB) is not enough to store the `C`'s list. Therefore, I iterate `C` and store in a CSV instead:
def storeCSV(data, fo, wtype='a'):
with open(fo, wtype) as wFile:
write_file = csv.writer(wFile)
write_file.writerow([data])
index = 0
count = 0
for c in C:
storeCSV(c, "part_%s.csv" % index)
count += 1
if count == N:
count = 0
index += 1
print index
Unfortunately, this CSV write is too slow, i.e ~6000 write/min, which means I have to wait about 3800 hours for the whole `C` to finish.
You might wonder why I need to divide `C` into multiple parts. After having these parts, I will run the following code on different computers with a purpose to collect information among set of 3 numbers:
v = MatrixSpace(GF(2), 3,9)
g3 = (c for c in c0 if block_matrix(3, 1, [v[c[0]], v[c[1]], v[c[2]]]).rank() >= 6) # or c1, c2, ..., cN
rel = dict()
for g in list(map(tuple,g3)):
# (1, 2, 3)
rel.setdefault(g[::2], []).append(g[1]) # '[1, 3]': 2
rel.setdefault(g[:2], []).append(g[-1]) # '[1, 2]': 3
rel.setdefault(g[1:], []).append(g[0]) # '[2, 3]': 1
Specifically, I got all Combinations of 3 numbers within `c0, c1,...,cN`. Then, I filter what I need and store in `g3`. For all `g3` of format (A, B, C), I collect (A,B), (B,C), (A,C) as keys and C,A,B as values respectively. The most important reason I must collect this in a Python dictionary is that I need to retrieve any `rel[(X, Y)]` later on.
I wish the problem is described clearly and someone can support. Thank a lot !!!imnvshSat, 02 Mar 2019 18:25:24 -0600http://ask.sagemath.org/question/45606/Sagemath heap size limithttp://ask.sagemath.org/question/45347/sagemath-heap-size-limit/Hi all, I am not new to Python, but new to Sagemath.
My code:
v = MatrixSpace(GF(2), 2, 6)
size = binomial(4096,3)
g3 = []
for c in Combinations(range(4096), 3):
m = block_matrix(3, 1, [v[c[0]], v[c[1]], v[c[2]]])
if m.rank() >= 4:
g3.append(c)
The variable "g3" raises up to about 20 GB in total. Sagemath catches "Memory Error" at some point; therefore, I divide "g3" into 1920 different parts to save. Now I need to process further with "g3", i.e. I need to assign "g3" parts again to some variables to use. The 1st solution that I think of is to create 1920 different variables to store the whole "g3" in my code; however, this way is a bit inconvenient.
Is there any better solution?
For example, increasing the limit of "list" size (python list type []), which might help me to save up to 11.444.858.880 lists in the list "g3" (about 11 billion is the size from binomial(4096,3)). I have a computer of 128 GB RAM, and it is very nice if I can utilize the computer's strength.
There is an old topic on this: trac.sagemath.org/ticket/6772. However, I do not really get the idea there.
I wish to be supported :-) Thank you a lot !!!imnvshWed, 06 Feb 2019 16:43:15 -0600http://ask.sagemath.org/question/45347/how to change rhs() of an equation in an equation listhttp://ask.sagemath.org/question/45269/how-to-change-rhs-of-an-equation-in-an-equation-list/ Hi
sorry for this basic question !
var('x y')
eqT=[x==3,y==4]
show(eqT[0].rhs())
((eqT[0]).rhs())=5
I got this mesage:
**File "<ipython-input-55-19bf87f1683d>", line 4
((T[Integer(0)]).rhs())=Integer(5)
SyntaxError: can't assign to function call**ortolljFri, 01 Feb 2019 12:05:44 -0600http://ask.sagemath.org/question/45269/implicit_plot plot of a listhttp://ask.sagemath.org/question/45196/implicit_plot-plot-of-a-list/ Hello,
On Sage 8.5, Release Date: 2018-12-22, I am doing
`var('x,y')`
`F1 =plot([k/x for k in [-5..5]], (-5, 5), ymin=-5, ymax = 5, detect_poles=True, color="red")`
`F2= implicit_plot([y^2 - x^2 -c for c in [-5..5]], (x,-5,5), (y,-5,5))`
to obtain two families of orthogonal curves. While the first family is ok, there seems to be a problem with the second one.
I can circunvent my problem by doing a lis of plots (instead of the plot of a list), as follows :
`[implicit_plot(y^2 - x^2 -c ==0, (x,-5,5), (y,-5,5), color="blue" ) for c in [-5..5]]`
I was expecting that `plot(...)` and `implicit_plot(...)` would beheave in the same manner in this situation. Why this is not the case? Am I missing something in the syntax?
Regards,
JC
JCSat, 26 Jan 2019 21:47:23 -0600http://ask.sagemath.org/question/45196/List creation with local variableshttp://ask.sagemath.org/question/44834/list-creation-with-local-variables/Can one create a list with some assumptions inside [ ], without having to make loops?logomathWed, 02 Jan 2019 06:33:53 -0600http://ask.sagemath.org/question/44834/question about Python assignment of lists; meaning of equals sign; how to save a list?http://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 08:59:29 -0600http://ask.sagemath.org/question/44324/polynomial list, arrayhttp://ask.sagemath.org/question/11065/polynomial-list-array/I would like to store polynomials in an array/list in Sage. How do I do this?
-------
I am editing my question due to the confusion expressed below.
I would like to generate a list of polynomials from a loop. HansThu, 19 Jun 2014 15:30:28 -0500http://ask.sagemath.org/question/11065/list of random non-zero elementshttp://ask.sagemath.org/question/43657/list-of-random-non-zero-elements/I was wondering if there was a short way to generate lists of random non-zero elements of GF(q) ? What I have so far is:
L=[];
for i in range(10):
a=GF(25).random_element();
while a==0:
a=GF(25).random_element();
L.append(a);ParkerThu, 13 Sep 2018 04:14:36 -0500http://ask.sagemath.org/question/43657/How to get a list of the combinations such that the elements are equal to some $n$http://ask.sagemath.org/question/43570/how-to-get-a-list-of-the-combinations-such-that-the-elements-are-equal-to-some-n/ I want a generalization of this kind
`[(r1, ..., rk) for r1 in range(n+1) ... for rk in range(n+1) if r1 + ... + rk = n]`
For a general number of $r$'s and any $n$MarioMMon, 03 Sep 2018 20:45:31 -0500http://ask.sagemath.org/question/43570/Is there a command to find the place of an element in an array?http://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/ For example, let v=[a, b, c, d]
I wonder if there is already encoded a function f such that f(a)=0, f(b)=1, f(c)=2..logomathFri, 30 Mar 2018 04:39:59 -0500http://ask.sagemath.org/question/41832/What is a possibility to tell Sage to turn a list into a multiset?http://ask.sagemath.org/question/41418/what-is-a-possibility-to-tell-sage-to-turn-a-list-into-a-multiset/ A well-known computer algebra package features a useful command called 'Tally', which e.g. takes a list like 2,1,2,2,3,1 and returns the list of pairs (1,2),(2,3),(3,1), where the second component of each pair equals the multiplicity of the first component of the pair in the input list. Currently, I am learning more Sage, and I need some functionality like the above.
**My question.** Is there a 'native' way to do the same in Sage? Of course, I could program something like this, but what is, in your opinion, the currently 'best' way to turn an arbitrary list into a multiset, with the multiplicities conveniently recorded?Peter HeinigWed, 07 Mar 2018 04:32:08 -0600http://ask.sagemath.org/question/41418/saving to a .csv filehttp://ask.sagemath.org/question/40137/saving-to-a-csv-file/ In my computations I got a list of strings:
vect = ['00011', '00010', '01011', '01111', '01100']
I need to save it as .csv file, each element row by row, ideally like this:
00011
00010
01011
01111
01100
I use a code:
import csv
C = vect
with open('file_path_vec.csv', 'w') as f:
c = csv.writer(f)
c.writerows(C)
But what I get in my .csv looks like this:
0,0,0,1,1
0,0,0,1,0
0,1,0,1,1
0,1,1,1,1
0,1,1,0,0
Why does it add commas in between? How can I get rid of them?XeniaWed, 13 Dec 2017 08:08:16 -0600http://ask.sagemath.org/question/40137/How to apply a function (like the sum) among all elements of a list?http://ask.sagemath.org/question/39161/how-to-apply-a-function-like-the-sum-among-all-elements-of-a-list/In magma you have the possibility of invoking
> &+[x0, x1, x2]
and that will return the sum of the elements in the array. You can also replace the sum operator by another binary operator that is associative. I'm wondering if SageMath has a similar feature, I've been looking in the documentation and apparently the best option is to use the built-in function `sum()`, but this doesn't generalize to any other binary operation.
Thanks for the help!descuderoSat, 14 Oct 2017 14:55:18 -0500http://ask.sagemath.org/question/39161/Select list element around a valuehttp://ask.sagemath.org/question/38648/select-list-element-around-a-value/ HI
I would like to show all elements of allRootsAPow2 which are around 2 + 3*I
this code below does not work ;-(
allRootsAPow2 =[2.00000000000000 + 3.00000000000000*I,
2.00000000000000 - 3.00000000000000*I,
-1.05087254532372e-32,
11.2111025509280 - 6.86482042695334e-16*I,
2.00000000000000 - 3.00000000000000*I,
2.00000000000000 + 3.00000000000000*I,
11.2111025509280 - 6.86482042695334e-16*I,
-1.05087254532372e-32,
2.00000000000000 + 3.00000000000000*I,
2.00000000000000 - 3.00000000000000*I,
-1.05087254532372e-32,
11.2111025509280 - 6.86482042695334e-16*I,
2.00000000000000 - 3.00000000000000*I,
2.00000000000000 + 3.00000000000000*I,
11.2111025509280 - 6.86482042695334e-16*I,
-1.05087254532372e-32,
-3.21110255092798 + 1.96623323036392e-16*I,
3.00992653992793e-33,
2.00000000000000 - 3.00000000000000*I,
2.00000000000000 + 3.00000000000000*I,
3.00992653992793e-33,
-3.21110255092798 + 1.96623323036392e-16*I,
2.00000000000000 + 3.00000000000000*I,
2.00000000000000 - 3.00000000000000*I,
-3.21110255092798 + 1.96623323036392e-16*I,
3.00992653992793e-33,
2.00000000000000 - 3.00000000000000*I,
2.00000000000000 + 3.00000000000000*I,
3.00992653992793e-33,
-3.21110255092798 + 1.96623323036392e-16*I,
2.00000000000000 + 3.00000000000000*I,
2.00000000000000 - 3.00000000000000*I]
for el in allRootsAPow2 :
if (math.ceil(el.real_part()*10)/10)== 2 and (math.ceil(el.imag_part()*10)/10)== 3 :
#if (math.ceil(el.real_part()*10)/10)== 2 :
#if (math.ceil(el.imag_part()*10)/10)== 3 :
show(el)
ortolljThu, 24 Aug 2017 12:14:20 -0500http://ask.sagemath.org/question/38648/Equivalent of Polynomial.list() for expression involving generator of GaloisFieldhttp://ask.sagemath.org/question/38458/equivalent-of-polynomiallist-for-expression-involving-generator-of-galoisfield/I know that it is possible to use the method list() to get a list with the coefficients of a polynomial. For instance:
sage: S.<x> = PolynomialRing(ZZ, 'x')
sage: (1 - 5*x + 3*x**2 + 2*x**3).list()
[1, -5, 3, 2]
I would like to do something like that with an expression involving a generator of a Galois Field.
For example:
sage: q = 5
sage: m = 2
sage: F.<a> = GF(q**m)
sage: a**9
3*a + 1
So, ideally, I would like to do the following
(a**9).list()
and get
[1, 3]
Is there any simple way to that?Hilder Vítor Lima PereiraTue, 01 Aug 2017 17:43:08 -0500http://ask.sagemath.org/question/38458/If Comprehension in listhttp://ask.sagemath.org/question/38206/if-comprehension-in-list/Hello,
I am knew to SageMath and Python. I hope to learn Python after I finish C++.
I would like to compare two lists and place the larger value from list L2 in another list if it is greater than L3 but not in the list if less than. Here is my try:
L2 =[sum(divisors(i))-i for i in range(1,100,1)]
print L2
L3 =[i for i in range(1,100,1)]
print L3
L4 =[L2[i] if L2[i] > L3[i] for i in range(1,100,1)]
print L4
I get the following error:
File "<ipython-input-1-01c49b9c5559>", line 20
L4 =[L2[i] if L2[i] > L3[i] for i in range(Integer(1),Integer(100),Integer(1))]
^
SyntaxError: invalid syntax
happys5Sun, 09 Jul 2017 09:49:24 -0500http://ask.sagemath.org/question/38206/Creating list within an outer for loop counterhttp://ask.sagemath.org/question/38199/creating-list-within-an-outer-for-loop-counter/Hello,
I want to create one list for L. I gave an example from the list tutorial(list1) that does what I want to do. I believe I have to include the for loop inside the brackets [] but cannot figure it out. I do not know how to program in Python. I am learning C++ now and hope to learn Python next.
for i in range (1,100,1):
div = divisors(i)
length = len(div)
L = [sum(div[k] for k in range(length))-i]
print i,
print L
list1 =[j for j in range(6)]
print list1
Thankshappys5Sat, 08 Jul 2017 13:43:11 -0500http://ask.sagemath.org/question/38199/If I return a list from a function that is more than 26 elements, the list goes verticalhttp://ask.sagemath.org/question/37477/if-i-return-a-list-from-a-function-that-is-more-than-26-elements-the-list-goes-vertical/If I return a list from a function that is more than 26 elements, the list goes vertical instead of horizontal even if I turn pretty printing off. Is this normal, and can I turn it off? I'm just returning the list, not using print explicitly. i.e.
With range 26 in the testfunc it shows a horizontal list, but if I increase that to 27 it goes vertical:
def tester():
v=[]
for i in range(26):
v.append(3)
return vcybervigilanteSun, 30 Apr 2017 19:21:50 -0500http://ask.sagemath.org/question/37477/Apply Functions Iterativelyhttp://ask.sagemath.org/question/35989/apply-functions-iteratively/I have a few functions `R1,R2,R3,R4` which act on vectors. If `X = matrix(3,1,(x0,y0,r))` then I have `R2` defined as
`def R2(X):
return matrix(3,1,(-X[0,0],X[1,0],X[2,0]))`
For instance, if `v = matrix(3,1,(1,1,1))`, then applying R2 to v gives the matrix $(-1,1,1)$.
I'd like to apply about 10 "levels" of iteration of these functions and have the output as a list of vectors.
So, the list should be
$R1(v), R2(v),R3(v),R4(v),R1^2(v),R2(R1(v)),R3(R1(v)),R4(R1(v)),R1^3(v),...,R1^{10}(v)\,...,R4^{10}(v)$
(as vectors)
where $R_j^n = R_j \circ \cdots \circ R_j$ $n$ times.
How can I do this?Daniel LMon, 12 Dec 2016 13:29:49 -0600http://ask.sagemath.org/question/35989/Overwriting...?http://ask.sagemath.org/question/36845/overwriting/Hello, guys! ... First of all, I'm very new to sage and this forum, so please be generous for my question, please...
So, I've wrote in sage (between @@@@@'s):
@@@@@
p=[3,2,1];
q=p;
temporary=q[0];
q[0]=q[1];
q[1]=temporary;
@@@@@
Then, the result for p and q was
p=[2,3,1] and q=[2,3,1].
But, what I actually want is that p doesn't change; so I want to have
p=[3,2,1] and q=[2,3,1]
so that p doesn't get changed when we set 'q=p', while q is defined to be p when we set 'q=p' and then q get changed via the codes followed by 'q=p' above... In other words, is there a way to 'overwrite' q to be p, and not changing p? Thank you!!!sssageeeeMon, 06 Mar 2017 19:39:41 -0600http://ask.sagemath.org/question/36845/Finding intersection of two lists?http://ask.sagemath.org/question/36829/finding-intersection-of-two-lists/Hello, guys. First of all, I'm very new to Sage and also to this forum, so please be generous for my question...
So, suppose we have
c=[[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [1, 2, 3, 4]],
d=[[0, 1, 2, 3], [0, 1, 3, 4], [0, 2, 3, 4], [9, 8, 7, 6]]
I would like to get
[[0, 1, 2, 3], [0, 1, 3, 4], [0, 2, 3, 4]]
which is intersection of c and d. Is there a way to do this?
Thank you for any help.sssageeeeSat, 04 Mar 2017 14:48:54 -0600http://ask.sagemath.org/question/36829/Iterating over list of tupleshttp://ask.sagemath.org/question/36727/iterating-over-list-of-tuples/I am attempting to index into the y-coordinates of each tuple to count how many tuples have a y-coordinate of 0, 1, or 2 but am receiving an error message which looks like this:
Error in lines 1-1
Traceback (most recent call last):
File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 982, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
TypeError: 'sage.rings.integer.Integer' object is not iterable
My code is below:
zero_count, one_count, two_count = 0
for i in range(len([list])):
if list[i][1] == 0:
zero_count += 1
elif list[i][1] == 1:
one_count += 1
else:
two_count += 1collegesistaFri, 24 Feb 2017 18:29:42 -0600http://ask.sagemath.org/question/36727/Problem with my for-loophttp://ask.sagemath.org/question/34280/problem-with-my-for-loop/
Does someone know how to get answer to this ?
list = [x for x in range (100) if (x + 0.75) == 20]
I was experimenting with Sage when computer says that there isn´t possible answer [] to this elementary maths problem .
There is any problem with using decimals number in a list?
I also try doing this : but it still doesn´t working
list = [float(x) for x in range (100) if (x + 0.75) == 20]
Thank you so much , Excuse my bad English! :))ImproveMESun, 31 Jul 2016 08:48:47 -0500http://ask.sagemath.org/question/34280/How to return a list from a recursive function?http://ask.sagemath.org/question/34251/how-to-return-a-list-from-a-recursive-function/ Hello,
I am trying to make a recursive function that will return a list but I get a SyntaxError. Here is the code working so far (just an example):
def myfactorial(n):
if n == 1:
return 1
else:
return n * myfactorial(n-1)
myfactorial(10)
**I need to return something like this: [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]**
**I know that there is already a build in factorial function**, I created this recursive function only as an example of what I am trying to get: a list. To return a list of all values of a given recursion, the steps of it...
[myfactorial(n) for n in range(1, 10)]
[1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
Now, how to put it "inside" in the recursive function?
Thank you for your attention.LRMWed, 27 Jul 2016 18:09:54 -0500http://ask.sagemath.org/question/34251/What's a common way to save and load a list?http://ask.sagemath.org/question/33179/whats-a-common-way-to-save-and-load-a-list/I have calculated a list through a long calculation to do some other calculations with it. So I saved the list in a .txt file and in the file it looks like this:
[[[-1/10, 1.02421477975960],
[-99/1000, 1.02369404664481],
[-49/500, 1.02317986236459],
[-97/1000, 1.02267219319285],
...
Now that I want to load it again, I realized that I have to strip the `\n`'s and then get rid of the brackets and extra commas etc. While I still have to do this for the current file, I want to know what are the common ways to save a list (and other similar python objects) so that I don't have to do all of this again? In other words:
a. How can I save the each element of a list in a line of a file?
That is, to get something like:
-1/10, 1.02421477975960
-99/1000, 1.02369404664481
-49/500, 1.02317986236459
-97/1000, 1.02267219319285
...
b. How can I save a list (higher dimensional array) into a file and then read it. I tried the following but I seem to be unable to read it:
L = [ [ [1,2], [1,2] ], [ [1,2,3], [1,3], [1,2,3] ], 1 ]
out = file('out','w')
out.write(str(L))
out.close()
And then
L = open('out','r')
to only get
'[ [ [1,2], [1,2] ], [ [1,2,3], [1,3], [1,2,3] ], 1 ]'k1monfaredThu, 21 Apr 2016 22:44:32 -0500http://ask.sagemath.org/question/33179/merge lists of listshttp://ask.sagemath.org/question/32956/merge-lists-of-lists/ I realize that if I have two lists, say
l1 = [1,2,3]
l2 = [4,5,6]
then I can join them via
l1 + l2
i.e. this gives [1,2,3,4,5,6].
I want to know how to do this when my list is not a list of numbers, but a list of matrices. I imagine it would be the same for a list of lists but I don't know how to do that either.
j0equ1nnFri, 01 Apr 2016 18:42:11 -0500http://ask.sagemath.org/question/32956/Please Append 'solve' Help Documentationhttp://ask.sagemath.org/question/32387/please-append-solve-help-documentation/ Hello,
I have been using SAGE for about 2 years, and only now have I finally figured out how to get the 'solve()' function to print out its solutions in plain form (so I can save the answers as variables, which is EXTREMELY important for me).
In order to do this: I had to sift through the help pages for 'solve', Programming -- Data Types (for both Lists and Dictionaries), and Python's official documentation on Lists and Dictionaries; until I finally figured out that you need to use the code:
print( 'listname' [ ' dict # ' ] [ 'var' ])
Now this may seem very elementary to those whom are fluent in Python, but for general users (like me): there is absolutely no clear indication on how to call one or several elements of several Dictionaries inside of a List.
PLEASE append your documentation so that people can actually use the 'solve' function without having to copy and paste the answers because it isn't shown how to properly use the output when 'solution_dict=true'.
(Note: if you're thinking about the 'for' loop example in the help documentation: it's completely useless for someone who needs to select one or more of those solutions & save them as variables).
Thank you.BLU7211Sat, 30 Jan 2016 14:46:43 -0600http://ask.sagemath.org/question/32387/