[sage-support] on the speed of comparing groups in 4.0
Hi, in sage 4.0 there's new code to compare subgroups which fixes problems I had earlier; http://groups.google.com/group/sage-support/browse_thread/thread/533747d48a1f29eb/958047c513936be1?lnk=gst&q=jerome+Lefebvre#958047c513936be1 Which is totally great. But, it feels much slower. For example, here is some code that will generate all subgroups of the symmetric group. in genSub1 I manually compare all the subgroup generated by comparing their list of elements. In genSub2, the comparison is done via the new code. It seems if I'm comparing only a few groups, it's much faster, but as I'm comparing more and more, things get very slow. # Here I compare all my groups by comparing their list def genSub1(n): G = SymmetricGroup(n) subgroups = [] J = [] L = G.list() # Run over all tuples of n/2 elements in the group # generate subgroups using those tuples # keep only those that are new for v in IntegerModRing(G.order())**ceil(n/2): H = G.subgroup([L[a] for a in v]) if H.list() not in J: subgroups.append(H) J.append(H.list()) return subgroups # Here I compare them using sage built in comparaison def genSub2(n): G = SymmetricGroup(n) subgroups = [] L = G.list() # Run over all tuples of n/2 elements in the group # generate subgroups using those tuples # keep only those that are new for v in IntegerModRing(G.order())**ceil(n/2): H = G.subgroup([L[a] for a in v]) if H not in subgroups: subgroups.append(H) return subgroups print "**GEN 1**" timeit('genSub1(1)') timeit('genSub1(2)') timeit('genSub1(3)') timeit('genSub1(4)',number=1) print "**GEN 2**" timeit('genSub2(1)') timeit('genSub2(2)') timeit('genSub2(3)') timeit('genSub2(4)',number=1) I will then get **GEN 1** 25 loops, best of 3: 22.9 ms per loop 5 loops, best of 3: 41.4 ms per loop 5 loops, best of 3: 672 ms per loop 1 loops, best of 3: 20.4 s per loop **GEN 2** 25 loops, best of 3: 11.5 ms per loop 25 loops, best of 3: 29.9 ms per loop 5 loops, best of 3: 1.7 s per loop 1 loops, best of 3: 153 s per loop Thank you, Jerome --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: on the speed of comparing groups in 4.0
Dear Jerome, On Jun 3, 2:28 pm, "jerome.p.lefeb...@gmail.com" wrote: > Hi, in sage 4.0 there's new code to compare subgroups which fixes > problems I had > earlier;http://groups.google.com/group/sage-support/browse_thread/thread/5337... Good. But bad that it became slower (actually I expected it to be faster). Using "prun" on your two functions, I found that in both cases the most time is spent with (1) pexpect and (2) regular expressions. The difference is: genSub2(4) requires nearly 1,290,000 interactions with pexpect and compilations of regular expressions, while genSub1(4) can do with only 151,000 pexpect interactions and 1,405,000 regular expressions (hence, *more* regular expressions, but the total time for the regular expressions is 10 times less). I will try and see how this can be improved. Thank you for your examples! Best regards, Simon --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: on the speed of comparing groups in 4.0
Hi! If you go through the code of PermutationGroup_generic.__cmp__, you see that the comparison is done via the gap interface. It turns out that the use of the gap interface requires a huge amount of regular expressions: sage: g1=gap('SymmetricGroup([1 .. 5])') sage: g2=gap('SymmetricGroup([1 .. 5])') sage: prun gap.eval(g1.name() + gap._equality_symbol() + g2.name()) ncalls tottime percall cumtime percall filename:lineno (function) 80.0000.0000.0010.000 pexpect.py:815 (compile_pattern_list) 80.0000.0000.0010.000 pexpect.py:914 (expect_list) 830.0000.0000.0010.000 re.py:227(_compile) 830.0000.0000.0010.000 re.py:186(compile) Now, in your second function, these 8 pexpect calls and 83 regular expressions (for a single comparison!!) sum up to the bad timings that you found. I don't know how to overcome this bottle neck. The problem is: 1) If one decides to compare permutation groups by comparing their list of elements (which is faster in your examples) then sooner or later one will have problems with big group orders 2) If one decides to compare the group via the gap interface then apparently one has trouble with all the regular expressions. 3) Or one may try and improve the pexpect interfaces. A partial solution for 3) might be to pre-compile certain useful regular expressions, and store them as an attribute of the interface instance. In that way, it would not be needed to do the 83 compilations of regular expressions over and over again. Probably other people can tell whether this suggestion makes sense. At least, when I worked at InfinitePolynomialRing, a similar trick improved the performance a lot! Cheers, Simon --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Creating a polynomial with symbolic coefficients
Dear sage-support group, I am completely new to computer algebra systems and to computer programming, and I hope you'll indulge the following beginner's question. I was wondering if there is a simple way to create a polynomial of degree d in x and y with symbolic coefficients in Sage. Here is what I mean: if I were at the board in class, I might write (in LaTeX transcription) something like P(x,y) = \sum_{i+j\leq d} a_{ij} x^i y^j, which I would view as an element of \mathbf{Z}[a_{ij},x,y]. I might then impose some linear conditions on the a_{ij} by insisting that P (x_t,y_t) = 0 for a list of points (x_1,y_1), (x_2,y_2), ... . Finally, I might solve the resulting system of linear equations. How would you recommend that I set up something like the a_{ij} and P (x,y) in Sage? In order to make the question more definite, I illustrate it with an example that I took from a lecture of Doron Zeilberger on experimental mathematics. He proposed the question of finding a polynomial of degree d in x and y that vanishes when x and y are specialized to consecutive Fibonacci numbers. The lines below are my attempt at a Sage version of his suggested computer search for a likely solution (originally written in Maple). The program should take the degree d as an input and then provide a parameterized family of polynomials of degree d that are likely candidates. Here is what I came up with, after an enlightening afternoon of studying computer manuals: d = 4 e = d+1 L = [] M = [] for i in range(e): for j in range(e-i): L.append('a_%s_%s' %(i,j)) M.append([i,j]) V = var(' '.join(L)) P = sum(V[j]*x^(M[j][0])*y^(M[j][1]) for j in range(len(L))) E = [P(x=fibonacci(n),y=fibonacci(n+1)) for n in range(1,len(V)+6)] P.substitute(solve(E,V,solution_dict = True)[0]) I could not figure out how to create and reference the variables a_ {ij} conveniently, and so I ended up with the strange lists V and M above. Even though I got my polynomial P and solved the original problem to my satisfaction, I still don't think I know how I would have Sage do something like sum the a_{i.i+1} for 2i+1<=d. Is there a better way to do this sort of thing? Thanks for your help and indulgence, James Parson --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
I'm not sure if this helps, but you can create a polynomial of the type you want a bit simpler: sage: var("x,y") (x, y) sage: Inds = CartesianProduct(range(5), range(4)) sage: sum([var("a"+str(i)+str(j))*x^i*y^j for i,j in Inds]) a43*x^4*y^3 + a33*x^3*y^3 + a42*x^4*y^2 + a23*x^2*y^3 + a32*x^3*y^2 + a41*x^4*y + a13*x*y^3 + a22*x^2*y^2 + a31*x^3*y + a40*x^4 + a03*y^3 + a12*x*y^2 + a21*x^2*y + a30*x^3 + a02*y^2 + a11*x*y + a20*x^2 + a01*y + a10*x + a00 Now you can reference them on the fly like this: sage: eval("a"+str(3)+str(2)) a32 On Wed, Jun 3, 2009 at 10:51 AM, James Parson wrote: > > Dear sage-support group, > > I am completely new to computer algebra systems and to computer > programming, and I hope you'll indulge the following beginner's > question. I was wondering if there is a simple way to create a > polynomial of degree d in x and y with symbolic coefficients in Sage. > Here is what I mean: if I were at the board in class, I might write > (in LaTeX transcription) something like > > P(x,y) = \sum_{i+j\leq d} a_{ij} x^i y^j, > > which I would view as an element of \mathbf{Z}[a_{ij},x,y]. I might > then impose some linear conditions on the a_{ij} by insisting that P > (x_t,y_t) = 0 for a list of points > > (x_1,y_1), (x_2,y_2), ... . > > Finally, I might solve the resulting system of linear equations. > > How would you recommend that I set up something like the a_{ij} and P > (x,y) in Sage? In order to make the question more definite, I > illustrate it with an example that I took from a lecture of Doron > Zeilberger on experimental mathematics. He proposed the question of > finding a polynomial of degree d in x and y that vanishes when x and y > are specialized to consecutive Fibonacci numbers. The lines below are > my attempt at a Sage version of his suggested computer search for a > likely solution (originally written in Maple). The program should take > the degree d as an input and then provide a parameterized family of > polynomials of degree d that are likely candidates. > > Here is what I came up with, after an enlightening afternoon of > studying computer manuals: > > d = 4 > e = d+1 > L = [] > M = [] > for i in range(e): > for j in range(e-i): > L.append('a_%s_%s' %(i,j)) > M.append([i,j]) > V = var(' '.join(L)) > P = sum(V[j]*x^(M[j][0])*y^(M[j][1]) for j in range(len(L))) > E = [P(x=fibonacci(n),y=fibonacci(n+1)) for n in range(1,len(V)+6)] > P.substitute(solve(E,V,solution_dict = True)[0]) > > I could not figure out how to create and reference the variables a_ > {ij} conveniently, and so I ended up with the strange lists V and M > above. Even though I got my polynomial P and solved the original > problem to my satisfaction, I still don't think I know how I would > have Sage do something like sum the a_{i.i+1} for 2i+1<=d. Is there a > better way to do this sort of thing? > > > Thanks for your help and indulgence, > > James Parson > > > > --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: illegal instruction with sage-sse2-3.4.2 virtual machine
I'm having the same issue with the Debian binary for sage 4.0 on my eeepc. /mnt/usb1/sage4> ./sage -- | Sage Version 4.0, Release Date: 2009-05-29 | | Type notebook() for the GUI, and license() for information.| -- The SAGE install tree may have moved. Regenerating Python.pyo and .pyc files that hardcode the install PATH (please wait at most a few minutes)... Do not interrupt this. /mnt/usb1/sage4/local/bin/sage-sage: line 198: 31050 Illegal instruction sage-ipython "$@" -i On May 17, 12:17 am, paul wrote: > Just downloaded the lastest sage for windows virtual machine as well > as the latest vmware to run it. Wow, 700Mbytes and yet no clear > instructions on how to run it! > > I tried double clicking on sage_vmx.vmx, then at the sage login prompt > I typed "login" and then "sage" for the password, and then "sage" > again at the "lo...@sage:~s" prompt. I don't know if that is the > proper way to proceed, but anyway after that I see: > > Sage Version 3.4.2, Release Date: 2009-05-05 > Type notebook() for the GUI, and license() for information. > //usr/local/sage/local/bin/sage-sage: > line 198: 3556 illegal instruction sage-ipython "s@" -i > > Does this illegal instruction indicate that it won't run on my > computer, > or have I done something wrong? > > Since this version seems to suggest that the SSE2 instruction set is > required I checked my cpu with CHKCPU32.exe which indeed reports that > my cpu does support SSE2 (although not SSE3). > > BTW, my very first attempt was just to type "notebook" at the first > prompt which was what the readme seemed to suggest. Although no > warnings were given it seems unlikely that any virtual machine was > actually started. At least firefox did not think so as it didn't > respond to the IP address that briefly flashed by the vmware window. > > Can someone guess what I might be doing wrong? Also are there any > clear instructions on how to start this mess. (And why would someone > upload 700Mbytes of stuff without installation instructions?) > > Thanks for any help you can provide. > ~Paul --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] How to define a constant function
Hello I would like to define a constant function in a script. I have the following in the terminal : = 19:43:28 ~ >$ sage -- | Sage Version 4.0, Release Date: 2009-05-29 | | Type notebook() for the GUI, and license() for information.| -- sage: var('x') x sage: f(x)= 8 sage: print f.derivative() x |--> 0 sage: type(f) = That seems quite good. But the following produce the error SyntaxError: can't assign to function call = #! /usr/bin/sage -python # -*- coding: utf8 -*- from sage.all import * var('x') f(x)= 8 print f.derivative() === If I write f=8 instead of f(x)=8, I gat the following : File "./sagess.py", line 8, in print f.derivative() AttributeError: 'int' object has no attribute 'derivative' The difference between the same lines in the terminal and in a very simple script seems strange to me. I'm using the workaround : var('x') f = 8+x-x But ... hum ... seriously ? ;) Any better idea ? Thanks a lot Laurent --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: illegal instruction with sage-sse2-3.4.2 virtual machine
On Wed, Jun 3, 2009 at 10:20 AM, tom d wrote: > > I'm having the same issue with the Debian binary for sage 4.0 on my > eeepc. Options: 1) Build from source 2) wait for sage-4.0.1 (planned to release by Sunday), which should nicely fix this issue. 3) I have a build of sage-4.0.1 on an Atom N270 netbook, which I'll post here within the next hour: http://sage.math.washington.edu/home/wstein/incoming/ You could try that. (Don't worry that it is an alpha -- it's just sage-4.0 + a few bugfixes and new code.) -- William > > /mnt/usb1/sage4> ./sage > -- > | Sage Version 4.0, Release Date: 2009-05-29 | > | Type notebook() for the GUI, and license() for information. | > -- > The SAGE install tree may have moved. > Regenerating Python.pyo and .pyc files that hardcode the install PATH > (please wait at > most a few minutes)... > Do not interrupt this. > /mnt/usb1/sage4/local/bin/sage-sage: line 198: 31050 Illegal > instruction sage-ipython "$@" -i > > > On May 17, 12:17 am, paul wrote: >> Just downloaded the lastest sage for windows virtual machine as well >> as the latest vmware to run it. Wow, 700Mbytes and yet no clear >> instructions on how to run it! >> >> I tried double clicking on sage_vmx.vmx, then at the sage login prompt >> I typed "login" and then "sage" for the password, and then "sage" >> again at the "lo...@sage:~s" prompt. I don't know if that is the >> proper way to proceed, but anyway after that I see: >> >> Sage Version 3.4.2, Release Date: 2009-05-05 >> Type notebook() for the GUI, and license() for information. >> //usr/local/sage/local/bin/sage-sage: >> line 198: 3556 illegal instruction sage-ipython "s@" -i >> >> Does this illegal instruction indicate that it won't run on my >> computer, >> or have I done something wrong? >> >> Since this version seems to suggest that the SSE2 instruction set is >> required I checked my cpu with CHKCPU32.exe which indeed reports that >> my cpu does support SSE2 (although not SSE3). >> >> BTW, my very first attempt was just to type "notebook" at the first >> prompt which was what the readme seemed to suggest. Although no >> warnings were given it seems unlikely that any virtual machine was >> actually started. At least firefox did not think so as it didn't >> respond to the IP address that briefly flashed by the vmware window. >> >> Can someone guess what I might be doing wrong? Also are there any >> clear instructions on how to start this mess. (And why would someone >> upload 700Mbytes of stuff without installation instructions?) >> >> Thanks for any help you can provide. >> ~Paul > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: How to define a constant function
On Wed, Jun 3, 2009 at 10:51 AM, moky wrote: > > Hello > > > I would like to define a constant function in a script. > > > > I have the following in the terminal : > > > = > > 19:43:28 ~ >$ sage > -- > | Sage Version 4.0, Release Date: 2009-05-29 | > | Type notebook() for the GUI, and license() for information. | > -- > sage: var('x') > x > sage: f(x)= 8 > sage: print f.derivative() > x |--> 0 > sage: type(f) > > > = > > That seems quite good. > > > > But the following produce the error > SyntaxError: can't assign to function call > = > > #! /usr/bin/sage -python > # -*- coding: utf8 -*- > > from sage.all import * > > var('x') > f(x)= 8 > print f.derivative() > > === > > If I write f=8 instead of f(x)=8, I gat the following : > File "./sagess.py", line 8, in > print f.derivative() > AttributeError: 'int' object has no attribute 'derivative' > > > The difference between the same lines in the terminal and in a very > simple script seems strange to me. > > > I'm using the workaround : > var('x') > f = 8+x-x > > But ... hum ... seriously ? > ;) Write f = SR(8) rather than f = 8+x-x. That explicitly makes 8 as an element of the symbolic ring. > > > Any better idea ? > > Thanks a lot > Laurent > > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: How to define a constant function
On Wed, Jun 3, 2009 at 10:51 AM, moky wrote: > = > > #! /usr/bin/sage -python > # -*- coding: utf8 -*- > > from sage.all import * > > var('x') > f(x)= 8 > print f.derivative() > > === This is a difference between Sage and Python -- "f(x) = 8" is not valid Python. That's why it's not working in your script. To see what "f(x)=8" really does, run the preparse command: '__tmp__=var("x"); f = symbolic_expression(Integer(8)).function(x)' Thus, you can do x = var('x') f = SR(8).function(x) and have it behave exactly the same way as before (since SR(8) and symbolic_expression(8) produce equivalent results). --Mike --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: How to define a constant function
Hi Laurent, On Thu, Jun 4, 2009 at 3:51 AM, moky wrote: > > Hello > > > I would like to define a constant function in a script. You might want to try just putting the code in a some text file whose extension is ".sage". For example, I put the following code in a file called "demo.sage", not "demo.py": [mv...@sage ~]$ cat demo.sage x = var("x") f(x)= 8 print f.derivative() type(f) Then I use Sage to execute the script like so: [mv...@sage ~]$ sage demo.sage x |--> 0 -- Regards Minh Van Nguyen --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: How to define a constant function
On Wed, Jun 3, 2009 at 11:00 AM, Minh Nguyen wrote: > You might want to try just putting the code in a some text file whose > extension is ".sage". For example, I put the following code in a file > called "demo.sage", not "demo.py": The reason why this works is that Sage preparses all .sage scripts and turns them into valid .py scripts. --Mike --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
Currently symbolic variables are un-indexable. What would people think of having indexing create new subscripted variables? sage: a = var('a') sage: a[0] a_0 sage: latex(a[1,2]) a_{1,2} - Robert On Jun 3, 2009, at 10:32 AM, David Joyner wrote: > > I'm not sure if this helps, but you can create a polynomial > of the type you want a bit simpler: > > sage: var("x,y") > (x, y) > sage: Inds = CartesianProduct(range(5), range(4)) > sage: sum([var("a"+str(i)+str(j))*x^i*y^j for i,j in Inds]) > a43*x^4*y^3 + a33*x^3*y^3 + a42*x^4*y^2 + a23*x^2*y^3 + a32*x^3*y^2 + > a41*x^4*y + a13*x*y^3 + a22*x^2*y^2 + a31*x^3*y + a40*x^4 + a03*y^3 + > a12*x*y^2 + a21*x^2*y + a30*x^3 + a02*y^2 + a11*x*y + a20*x^2 + a01*y > + a10*x + a00 > > Now you can reference them on the fly like this: > > sage: eval("a"+str(3)+str(2)) > a32 > > On Wed, Jun 3, 2009 at 10:51 AM, James Parson wrote: >> >> Dear sage-support group, >> >> I am completely new to computer algebra systems and to computer >> programming, and I hope you'll indulge the following beginner's >> question. I was wondering if there is a simple way to create a >> polynomial of degree d in x and y with symbolic coefficients in Sage. >> Here is what I mean: if I were at the board in class, I might write >> (in LaTeX transcription) something like >> >> P(x,y) = \sum_{i+j\leq d} a_{ij} x^i y^j, >> >> which I would view as an element of \mathbf{Z}[a_{ij},x,y]. I might >> then impose some linear conditions on the a_{ij} by insisting that P >> (x_t,y_t) = 0 for a list of points >> >> (x_1,y_1), (x_2,y_2), ... . >> >> Finally, I might solve the resulting system of linear equations. >> >> How would you recommend that I set up something like the a_{ij} and P >> (x,y) in Sage? In order to make the question more definite, I >> illustrate it with an example that I took from a lecture of Doron >> Zeilberger on experimental mathematics. He proposed the question of >> finding a polynomial of degree d in x and y that vanishes when x >> and y >> are specialized to consecutive Fibonacci numbers. The lines below are >> my attempt at a Sage version of his suggested computer search for a >> likely solution (originally written in Maple). The program should >> take >> the degree d as an input and then provide a parameterized family of >> polynomials of degree d that are likely candidates. >> >> Here is what I came up with, after an enlightening afternoon of >> studying computer manuals: >> >> d = 4 >> e = d+1 >> L = [] >> M = [] >> for i in range(e): >>for j in range(e-i): >> L.append('a_%s_%s' %(i,j)) >> M.append([i,j]) >> V = var(' '.join(L)) >> P = sum(V[j]*x^(M[j][0])*y^(M[j][1]) for j in range(len(L))) >> E = [P(x=fibonacci(n),y=fibonacci(n+1)) for n in range(1,len(V)+6)] >> P.substitute(solve(E,V,solution_dict = True)[0]) >> >> I could not figure out how to create and reference the variables a_ >> {ij} conveniently, and so I ended up with the strange lists V and M >> above. Even though I got my polynomial P and solved the original >> problem to my satisfaction, I still don't think I know how I would >> have Sage do something like sum the a_{i.i+1} for 2i+1<=d. Is there a >> better way to do this sort of thing? >> >> >> Thanks for your help and indulgence, >> >> James Parson >> >>> >> > > > --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: How to define a constant function
Thanks all for the answer. I keep SR solution. > You might want to try just putting the code in a some text file whose > extension is ".sage". For example, I put the following code in a file > called "demo.sage", not "demo.py": > I prefer not to use it because I'm using sage as a back-end in a personal module which is imported in my principal script ... which can itself be called from a bash script. So I prefer, as far as possible to write regular python and use Sage as a module imported. Have a nice afternoon Laurent --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 11:45 AM, Robert Bradshaw wrote: > > Currently symbolic variables are un-indexable. What would people > think of having indexing create new subscripted variables? > > sage: a = var('a') > sage: a[0] > a_0 > sage: latex(a[1,2]) > a_{1,2} That's a pretty wild and crazy idea. Cool. Does any other math software do that? Are there any obvious gotcha's? William --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 11:53 AM, William Stein wrote: >> Currently symbolic variables are un-indexable. What would people >> think of having indexing create new subscripted variables? >> >> sage: a = var('a') >> sage: a[0] >> a_0 >> sage: latex(a[1,2]) >> a_{1,2} > > That's a pretty wild and crazy idea. Cool. Does any other math > software do that? > Are there any obvious gotcha's? I think any system where things are left unevaluated can do something like this. For example, I know people who use this in Maple to have polynomials infinitely many variables. We have something like this in Sage now: sage: R. = InfinitePolynomialRing(QQ) sage: x[0] + x[100] x100 + x0 I would still like to use __getitem__ to return the operands of a symbolic expression. Since symbols have no operands, these two things aren't totally incompatible. --Mike --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Jun 3, 8:45 pm, Robert Bradshaw wrote: > Currently symbolic variables are un-indexable. What would people > think of having indexing create new subscripted variables? > > sage: a = var('a') > sage: a[0] > a_0 > sage: latex(a[1,2]) > a_{1,2} > I like it, this idea could also be expanded to vectors, like a[0:3] == vector([a_0, a_1, a_2, a_3]) # note, also a_3 and probably, the var constructor should also be more intelligent, i.e. var('a[0:3]') creates all the a_i (and avoids the unindexed 'a' you would need in your 2-step approach above) h --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
William Stein wrote: > On Wed, Jun 3, 2009 at 11:45 AM, Robert Bradshaw > wrote: >> Currently symbolic variables are un-indexable. What would people >> think of having indexing create new subscripted variables? >> >> sage: a = var('a') >> sage: a[0] >> a_0 >> sage: latex(a[1,2]) >> a_{1,2} > > That's a pretty wild and crazy idea. Cool. Does any other math > software do that? > Are there any obvious gotcha's? So as far as printing, a[0] would look the same as a0 would look the same as a_0? Would a[0] actually be the variable a_0 or a0? Do we ever want to make symbolic expressions indexable? If so, it would be confusing to have: (x+1)[0] have totally different behavior than (x)[0]. Jason P.S. It seems like Maple did something like this---Maple experts can comment on it, though. -- Jason Grout --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
Harald Schilly wrote: > On Jun 3, 8:45 pm, Robert Bradshaw > wrote: >> Currently symbolic variables are un-indexable. What would people >> think of having indexing create new subscripted variables? >> >> sage: a = var('a') >> sage: a[0] >> a_0 >> sage: latex(a[1,2]) >> a_{1,2} >> > > I like it, this idea could also be expanded to vectors, like > a[0:3] == vector([a_0, a_1, a_2, a_3]) # note, also a_3 -1 to the a_3. That goes against all of the slicing conventions in Python. It is kind of a cool idea, though. I'd like some time to try it out before committing one way or the other. What about having a "experiment mode" in Sage that turns on things like this? Some variable in some module somewhere that people can set to switch on some experimental behavior so they can test it out and give feedback. In other words, setting sage.misc.misc.EXPERIMENT_MODE=True turns it on. Jason -- Jason Grout --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Jun 3, 2009, at 12:11 PM, Jason Grout wrote: > William Stein wrote: >> On Wed, Jun 3, 2009 at 11:45 AM, Robert Bradshaw >> wrote: >>> Currently symbolic variables are un-indexable. What would people >>> think of having indexing create new subscripted variables? >>> >>> sage: a = var('a') >>> sage: a[0] >>> a_0 >>> sage: latex(a[1,2]) >>> a_{1,2} >> >> That's a pretty wild and crazy idea. Cool. Does any other math >> software do that? >> Are there any obvious gotcha's? > > So as far as printing, a[0] would look the same as a0 would look the > same as a_0? Would a[0] actually be the variable a_0 or a0? I'm not sure. My first intent was that a[0] would actually be a0, but it's unclear how to format multiple indices (I'd want a[1, 23] != a [12, 3]). Also, should we support a[i]? Then I'd want a[i].subs(i=5) == a[5]. What about v[5].subs(v=vector(range(10)))? > Do we ever want to make symbolic expressions indexable? If so, it > would > be confusing to have: > > (x+1)[0] > > have totally different behavior than > > (x)[0]. They're not now. Having both would be confusing. I'd vote for the latter--if (x+1)[0] worked, would it be the same as (1+x)[0], or (x+1- x)[0]? Answering your question about experimental mode, you're talking about something easier and more permanent than applying a patch from trac? Would people start depending on it, meaning we can't remove it without sacrificing backwards compatibility (despite the name "experimental")? - Robert --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Memleak help?
Dear Support, I apologize if this is really a Python question, I'm not sure. I have a Mac running X.4 on G4 PPC. A couple of weeks ago, I created an object in Sage which is a list of about 2.8 million lists with 18 elements each. That saved and loaded fine - thanks, Sage! Now, I rewrote the code to make the object a list of lists which have three lists of 6 elements each (3x6=18), but otherwise it is IDENTICAL. Now when I try to save it, my computer uses all available virtual memory and things grind to a halt. What's worse, Ctrl-C does not do anything at all; the only way to exit the command sage: save(object,'object') is to actually force close the Terminal window. When I looked at the output of top, it seems like the amount of virtual memory allocated to the Python process that is Sage is slowly increasing during the save. The previous object was about 20MB, so I assume that this new nearly-identical object is not anywhere near 1GB in size, yet the virtual memory allocation crept slowly up from 1.25GB, 1.26GB,... - when I quit the last time I tried this (the behavior repeated, didn't matter what filename I tried to save it to) it got up to 1.35GB. I had worked up to 45 million pageins and 13 million pageouts, though that is over doing this several times. That sounds like a memory leak, though I am not exactly sure what they are. Is there anything that comes immediately to mind as to what I might have done wrong to make save behave this way? Alternately, is there any way for me to see (in the terminal) what files are using all that memory? The .sobj file is never actually created, as far as I can tell. I apologize for being vague, but what I hope are the germane details is that the object itself is just a long list of lists (of length three) of lists (of length six), so hopefully that will be enough. I am using 4.0.rc0 for this computation. Thanks, - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Conjugate of newform
Hello, I'm wondering if someone knows of a clever way of calculate the Galois conjugate of a newform (given an embedding of the Hecke field, i.e., the field generated by all the coefficients in the q-expansion). I can't find any built in function that does this and I'm to lazy right now to think of a way to program this. /Daniel --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Conjugate of newform
On Wed, Jun 3, 2009 at 12:27 PM, Daniel Larsson wrote: > > Hello, > > I'm wondering if someone knows of a clever way of calculate the Galois > conjugate of a newform (given an embedding of the Hecke field, i.e., > the field generated by all the coefficients in the q-expansion). > > I can't find any built in function that does this and I'm to lazy > right now to think of a way to program this. Could you please be way more precise about this question. What are you embedding into? How? etc. Give some code. Also, I've cross-posted this to the sage-nt Google group, which is where it belongs. > > /Daniel > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Jun 3, 12:16 pm, Jason Grout wrote: > What about having a "experiment mode" in Sage that turns on things like > this? Some variable in some module somewhere that people can set to > switch on some experimental behavior so they can test it out and give > feedback. In other words, setting sage.misc.misc.EXPERIMENT_MODE=True > turns it on. It seems better to me to turn individual experimental features on or off. So what about an argument to var, just like "ns"? var(a, index=True) for example. ("index" doesn't sound right to me, but I hope you get the idea.) John --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 4:38 PM, John H Palmieri wrote: > > On Jun 3, 12:16 pm, Jason Grout wrote: >> What about having a "experiment mode" in Sage that turns on things like >> this? Some variable in some module somewhere that people can set to >> switch on some experimental behavior so they can test it out and give >> feedback. In other words, setting sage.misc.misc.EXPERIMENT_MODE=True >> turns it on. > > It seems better to me to turn individual experimental features on or > off. So what about an argument to var, just like "ns"? > > var(a, index=True) > > for example. ("index" doesn't sound right to me, but I hope you get > the idea.) +1 Is this possible? sage: J = CartesianProduct(range(3),range(4)) sage var(a, index_set = J) > > John > > > > --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Memleak help?
I should point out that simply starting from scratch and creating this object uses 1.19GB of virtual memory (primarily because I use an entire permutation generator), so it's not like the memory is small and then gets large (though it does get consistently larger while saving). But I don't understand why the process of saving should never end. Thanks for any ideas. - kcrisman On Jun 3, 3:37 pm, kcrisman wrote: > Dear Support, > > I apologize if this is really a Python question, I'm not sure. I have > a Mac running X.4 on G4 PPC. > > A couple of weeks ago, I created an object in Sage which is a list of > about 2.8 million lists with 18 elements each. That saved and loaded > fine - thanks, Sage! > > Now, I rewrote the code to make the object a list of lists which have > three lists of 6 elements each (3x6=18), but otherwise it is > IDENTICAL. Now when I try to save it, my computer uses all available > virtual memory and things grind to a halt. What's worse, Ctrl-C does > not do anything at all; the only way to exit the command > sage: save(object,'object') > is to actually force close the Terminal window. > > When I looked at the output of top, it seems like the amount of > virtual memory allocated to the Python process that is Sage is slowly > increasing during the save. The previous object was about 20MB, so I > assume that this new nearly-identical object is not anywhere near 1GB > in size, yet the virtual memory allocation crept slowly up from > 1.25GB, 1.26GB,... - when I quit the last time I tried this (the > behavior repeated, didn't matter what filename I tried to save it to) > it got up to 1.35GB. I had worked up to 45 million pageins and 13 > million pageouts, though that is over doing this several times. That > sounds like a memory leak, though I am not exactly sure what they are. > > Is there anything that comes immediately to mind as to what I might > have done wrong to make save behave this way? Alternately, is there > any way for me to see (in the terminal) what files are using all that > memory? The .sobj file is never actually created, as far as I can > tell. > > I apologize for being vague, but what I hope are the germane details > is that the object itself is just a long list of lists (of length > three) of lists (of length six), so hopefully that will be enough. I > am using 4.0.rc0 for this computation. > > Thanks, > - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Memleak help?
> I should point out that simply starting from scratch and creating this > object uses 1.19GB of virtual memory (primarily because I use an > entire permutation generator), so it's not like the memory is small > and then gets large (though it does get consistently larger while > saving). But I don't understand why the process of saving should > never end. Thanks for any ideas. > Can you post some code that generates this (or better yet, a smaller example of the same ilk) so that we can all play around? -cc --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
Thanks to David Joyner for his response to my original question. His method worked nicely. Incidentally, here is the original Maple code from the lecture of Doron Zeilberger that I was trying to translate into Sage: with(combinat): P:=(d,x,y)->add(add(a[i,j]*x**i*y**j,i=0..d- j),j=0..d); V:=d->fseq(seq(a[i,j],i=0..d-j),j=0..d)g; E:=d->fseq(P(d,fibonacci(n),fibonacci(n+1)),n=1..nops(V(d))+5) g: Q:=(d,x,y)->subs(solve(E(d),V(d)),P(d,x,y)); These lines feature the sort of indexed variables a[i,j] discussed above. (The full lecture from which I took these lines can be found at http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimhtml/em.html.) Here is a variant on the original question: suppose I wanted to write a line that creates a polynomial ring whose variables are a_{ij} for i +j<=d. How should I do it? I might want to set this up, for example, so that I could tell Sage about an algebraic group action on the space of polynomials of degree <=d. For a simpler variant: is there a convenient way to construct QQ[x_{ij}] with 1\leq i,j\leq n? I am a overwhelmed with the various ways to construct a polynomial ring, and so I cannot tell if one of them would be appropriate for this purpose. I can see how to make a polynomial ring in n^2 variables, but I do not know how to name them x_{ij}. Thanks again for your help, James Parson --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 5:54 PM, James Parson wrote: > > Thanks to David Joyner for his response to my original question. His > method worked nicely. Incidentally, here is the original Maple code > from the lecture of Doron Zeilberger that I was trying to translate > into Sage: BTW I think the more of Zeilberger's stuff that is translated into Sage the better! Please consider publishing your translation as a sagemath.org notebook worksheet. > > with(combinat): P:=(d,x,y)->add(add(a[i,j]*x**i*y**j,i=0..d- > j),j=0..d); > V:=d->fseq(seq(a[i,j],i=0..d-j),j=0..d)g; > E:=d->fseq(P(d,fibonacci(n),fibonacci(n+1)),n=1..nops(V(d))+5) g: > Q:=(d,x,y)->subs(solve(E(d),V(d)),P(d,x,y)); > > These lines feature the sort of indexed variables a[i,j] discussed > above. > > (The full lecture from which I took these lines can be found at > http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimhtml/em.html.) > > Here is a variant on the original question: suppose I wanted to write > a line that creates a polynomial ring whose variables are a_{ij} for i > +j<=d. How should I do it? I might want to set this up, for example, sage: Inds = CartesianProduct(range(5), range(5)) sage: vars = ["a"+str(i)+str(j) for i,j in Inds] sage: PolynomialRing(QQ,25,vars) Multivariate Polynomial Ring in a00, a01, a02, a03, a04, a10, a11, a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, a41, a42, a43, a44 over Rational Field > so that I could tell Sage about an algebraic group action on the space > of polynomials of degree <=d. For a simpler variant: is there a > convenient way to construct QQ[x_{ij}] with 1\leq i,j\leq n? I am a > overwhelmed with the various ways to construct a polynomial ring, and > so I cannot tell if one of them would be appropriate for this purpose. > I can see how to make a polynomial ring in n^2 variables, but I do not > know how to name them x_{ij}. > > > Thanks again for your help, > > James Parson > > > --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
> > > Here is a variant on the original question: suppose I wanted to write > > a line that creates a polynomial ring whose variables are a_{ij} for i > > +j<=d. How should I do it? I might want to set this up, for example, > > sage: Inds = CartesianProduct(range(5), range(5)) > sage: vars = ["a"+str(i)+str(j) for i,j in Inds] I think it would actually be something like sage: vars = ["a"+str(i)+str(j) for i,j in Inds if i+j<5] Of course you'd have to change 25 below. Actually, I think the number of variables is optional, though if you include it you need to calculate the correct number of them :) > sage: PolynomialRing(QQ,25,vars) > Multivariate Polynomial Ring in a00, a01, a02, a03, a04, a10, a11, > a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, > a41, a42, a43, a44 over Rational Field - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 5:54 PM, James Parson wrote: > > Thanks to David Joyner for his response to my original question. His > method worked nicely. Incidentally, here is the original Maple code > from the lecture of Doron Zeilberger that I was trying to translate > into Sage: > > with(combinat): P:=(d,x,y)->add(add(a[i,j]*x**i*y**j,i=0..d- > j),j=0..d); > V:=d->fseq(seq(a[i,j],i=0..d-j),j=0..d)g; > E:=d->fseq(P(d,fibonacci(n),fibonacci(n+1)),n=1..nops(V(d))+5) g: > Q:=(d,x,y)->subs(solve(E(d),V(d)),P(d,x,y)); > > These lines feature the sort of indexed variables a[i,j] discussed > above. > > (The full lecture from which I took these lines can be found at > http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimhtml/em.html.) > There is some pdf cut-and-paste corruption of the example above. The correct Maple code is: with(combinat): P:=(d,x,y)->add(add(a[i,j]*x**i*y**j,i=0..d-j),j=0..d); V:=d->{seq(seq(a[i,j],i=0..d-j),j=0..d)}; E:=d->{seq(P(d,fibonacci(n),fibonacci(n+1)),n=1..nops(V(d))+5) }; Q:=(d,x,y)->subs(solve(E(d),V(d)),P(d,x,y)); A more direct translation to Sage might be something like this: sage: P=lambda d,x,y: sum([ sum([ var("a"+str(i)+str(j))*x^i*y^j for i in [0..d-j]]) for j in [0..d]]) sage: V=lambda d:sum([[var("a"+str(i)+str(j)) for i in [0..d-j]] for j in [0..d]],[]) sage: E=lambda d: [ P(d,fibonacci(n),fibonacci(n+1)) for n in [1..len(V(d))+5] ] sage: Q=lambda d,x,y:P(d,x,y).subs_expr(solve(E(d),V(d),solution_dict=True)[0]) sage: Q(1,x,y) 0 sage: Q(2,x,y) 0 sage: Q(3,x,y) 0 sage: Q(4,x,y).factor() r21*(-y^2 + x*y + x^2 - 1)*(-y^2 + x*y + x^2 + 1) Regards, Bill Page. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
> > Here is a variant on the original question: suppose I wanted to write > > a line that creates a polynomial ring whose variables are a_{ij} for i > > +j<=d. How should I do it? I might want to set this up, for example, > > sage: Inds = CartesianProduct(range(5), range(5)) > sage: vars = ["a"+str(i)+str(j) for i,j in Inds] > sage: PolynomialRing(QQ,25,vars) > Multivariate Polynomial Ring in a00, a01, a02, a03, a04, a10, a11, > a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, > a41, a42, a43, a44 over Rational Field Thanks again for the suggestions. I have one more foolish question about this sort of construction: if I type those lines into Sage and then type something like a00 + a11, I get an error NameError: name 'a00' is not defined. I read about this sort of thing in the Sage Tutorial, but I couldn't understand it well enough to figure out how to name the variables what I wanted. Is there any easy way to do this? Regards, James Parson --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Memleak help?
On Jun 3, 5:06 pm, Craig Citro wrote: > > I should point out that simply starting from scratch and creating this > > object uses 1.19GB of virtual memory (primarily because I use an > > entire permutation generator), so it's not like the memory is small > > and then gets large (though it does get consistently larger while > > saving). But I don't understand why the process of saving should > > never end. Thanks for any ideas. > > Can you post some code that generates this (or better yet, a smaller > example of the same ilk) so that we can all play around? sage: L=[] sage: P=Permutations(some number greater than 9, depending on your computer's memory) sage: for p in P: sage: ... L.append(p) sage: ... sage: save(L,'L') But I am now thinking it's my machine. What is the expected behavior if an object nearly maxes out your memory and you then try to save it (and if you try to interrupt it when it takes a while)? That is the situation here. Also, is there any way to access the size or any other (non- mathematical) attributes of any unsaved Sage object while the session is running? I'm thinking of something like the du command but for a Sage session. Presumably the object must have some existence in RAM, but on the other hand it doesn't live in a file so I can't just look for it and then click for information. Maybe that's a naive question. Sorry if this turns out to be noise. - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 9:20 PM, James Parson wrote: > >> > Here is a variant on the original question: suppose I wanted to write >> > a line that creates a polynomial ring whose variables are a_{ij} for i >> > +j<=d. How should I do it? I might want to set this up, for example, >> >> sage: Inds = CartesianProduct(range(5), range(5)) >> sage: vars = ["a"+str(i)+str(j) for i,j in Inds] >> sage: PolynomialRing(QQ,25,vars) >> Multivariate Polynomial Ring in a00, a01, a02, a03, a04, a10, a11, >> a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, >> a41, a42, a43, a44 over Rational Field > > Thanks again for the suggestions. I have one more foolish question > about this sort of construction: if I type those lines into Sage and > then type something like > > a00 + a11, > > I get an error > > NameError: name 'a00' is not defined. > > I read about this sort of thing in the Sage Tutorial, but I couldn't > understand it well enough to figure out how to name the variables what > I wanted. Is there any easy way to do this? Sorry, I'm stuck here too. Can you just write R("a00")+R("a11") instead? > > > Regards, > > James Parson > > > --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
On Wed, Jun 3, 2009 at 7:03 PM, David Joyner wrote: > > On Wed, Jun 3, 2009 at 9:20 PM, James Parson wrote: >> >>> > Here is a variant on the original question: suppose I wanted to write >>> > a line that creates a polynomial ring whose variables are a_{ij} for i >>> > +j<=d. How should I do it? I might want to set this up, for example, >>> >>> sage: Inds = CartesianProduct(range(5), range(5)) >>> sage: vars = ["a"+str(i)+str(j) for i,j in Inds] >>> sage: PolynomialRing(QQ,25,vars) >>> Multivariate Polynomial Ring in a00, a01, a02, a03, a04, a10, a11, >>> a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, >>> a41, a42, a43, a44 over Rational Field >> >> Thanks again for the suggestions. I have one more foolish question >> about this sort of construction: if I type those lines into Sage and >> then type something like >> >> a00 + a11, >> >> I get an error >> >> NameError: name 'a00' is not defined. >> >> I read about this sort of thing in the Sage Tutorial, but I couldn't >> understand it well enough to figure out how to name the variables what >> I wanted. Is there any easy way to do this? > > > Sorry, I'm stuck here too. Can you just write R("a00")+R("a11") instead? > > Two options: (1) Just type inject_on() and then aij will be defined: sage: inject_on() Redefining: FiniteField Frac FractionField FreeMonoid GF LaurentSeriesRing NumberField PolynomialRing quo quotient sage: Inds = CartesianProduct(range(5), range(5)) sage: vars = ["a"+str(i)+str(j) for i,j in Inds] sage: PolynomialRing(QQ,25,vars) Defining a00, a01, a02, a03, a04, a10, a11, a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, a41, a42, a43, a44 Multivariate Polynomial Ring in a00, a01, a02, a03, a04, a10, a11, a12, a13, a14, a20, a21, a22, a23, a24, a30, a31, a32, a33, a34, a40, a41, a42, a43, a44 over Rational Field sage: a00 + a01 a00 + a01 sage: (a00 + a01)^3 a00^3 + 3*a00^2*a01 + 3*a00*a01^2 + a01^3 (2) Edit the globals dictionary: sage: Inds = CartesianProduct(range(5), range(5)) sage: vars = ["a"+str(i)+str(j) for i,j in Inds] sage: R = PolynomialRing(QQ,25,vars) sage: for v in R.gens(): globals()[str(v)] = v : sage: (a00 + a01)^3 a00^3 + 3*a00^2*a01 + 3*a00*a01^2 + a01^3 --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Creating a polynomial with symbolic coefficients
William Stein wrote: > On Wed, Jun 3, 2009 at 11:45 AM, Robert Bradshaw > wrote: > > > > Currently symbolic variables are un-indexable. What would people > > think of having indexing create new subscripted variables? > That's a pretty wild and crazy idea. Cool. Does any other math > software do that? For the record, Maxima treats subscripted variables somewhat the same as simple variables. (They should be the same but Maxima is less than entirely consistent ) A subscripted variable x[0] is distinct from x_0 and x0. Subscripted variables are the same as unevaluated function-like expressions except that they have an extra flag which shows that it's a subscript instead of a function argument. I think it's useful to consider subscripted variables as a subset of functional expressions; after all a subscripted variable is function which maps its set of indices to whatever. > Are there any obvious gotcha's? I think of two general shortcomings of Maxima's scheme. One is that x[m] and x[n] have no known relation when m and n are different; there isn't any way to apply some property across all of the subscripted variables x[foo]. The other is that x[foo] could be any of several things --- could be a list element, a matrix row, an array element, a hash table element, as well as a subscripted variable. This multitude of interpretations of x[foo] can lead to confusion. FWIW Robert Dodier --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---