[sage-support] Turning axes off
I am using SAGE, not so much as a mathematical tool, but to make art. With that in mind, I want to disable axes pretty much permanently. I am currently plotting complex functions such as sage: f(z) = z^5 + z - 1 + 1/z sage: complex_plot(f, (-3, 3), (-3, 3)) Thanks, Alec -- 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 URL: http://www.sagemath.org
Re: [sage-support] An argument for more direct axiom integration
On Mon, Jul 5, 2010 at 4:39 AM, Dr. David Kirkby david.kir...@onetel.net wrote: On 07/ 5/10 06:18 AM, William Stein wrote: Great idea - you could add an algorithm=axiom option to sage's integrate command. Personally, and I am going to dare risk argue with a mathematician, I would not have considered Axion an algorithm, but a software package. So something like method=use_axiom would seem more logical to me. The only argument for algorithm is that it's a standard idiom in Sage (though with a greatly generalized meaning). Better still if Sage behaved like Mathematica, so seamlessly switched from one method to another, if the first one fails. As far as I know, it usually does. I'm sure that maxima tries more than one algorithm (or at least has some heuristic to figure out which way to attack the problem). Switching over to a different system is a bit different. Also, note that axiom is an optional package. In other words, automatically switch to Axiom if Maxima can't solve the integral - perhaps with a message like Unable to solve with Maxima, now trying Axiom. I would still leave the option of someone just using Axiom though. One of the annoying things with Sage, is that you often need to know what bit of software to use to do something. With Mathematica, I can request a zero of a Bessel function - I don't need to know that I should be doing this using mpmath or whatever else can be used for finding zeros of Bessel functions (see recent thread on this topic) This is certainly the goal--we're just not there yet in all areas. For, e.g. (exact) linear algebra or most of number theory it chooses and uses the right components under the hood. - 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Which python for sage?
On Sun, Jul 4, 2010 at 9:47 AM, Greg Kuperberg greg.kuperb...@gmail.com wrote: On Jul 3, 8:33 am, William Stein wst...@gmail.com wrote: Sage can't switch to Python 3 until every single Python package in Sage is ported to Python 3. This is far from done. It's possible that for some packages, nobody is even working on doing a port. In such cases, our only hope is to either do the port ourselves or remove the package from Sage, which may both be incredibly difficult. I've heard Twisted may be an example of such a package, but there might be others. Even numpy hasn't been ported to Python 3 yet, though at least there work is rumored to be in progress. Of course, you understand these issues better than I do. I didn't even consider that Sage has so many third-party libraries at the Python level. So yeah, I can see that it could take a long time to do such a conversion. Even so, I would suggest a more developed policy than just that you can't do it right now. Certainly at first glance, Python 3 looks a really good idea. Maybe at second glance, the conversion cost is very high for many projects and you could estimate that it will take many years for the world to switch. (But note that the same was true of a really great editor called NEdit and Unicode, and the result in the long run was that it hurt NEdit a lot.) What advantages do you see Sage getting from Python 3? I think the Sage library is probably in better shape than many of our dependancies (and the Cython files should just work), but it's hard to know 'till we get to it. In any case the all-or-nothing answer cannot be completely true. After all, you have interface support for packages written entirely in C or whatever other language. So how could it be that if you were in Python 3, then Python 2.* would be the one language that you can't support at all? What would you do if you wanted to support a Python 3 package? We'd have to ship Python 3 as a distinct spkg, and probably call it via pexpect. - 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 URL: http://www.sagemath.org
[sage-support] Re: How to use R's untar in Sage?
Found the problem was with my system's tar command. After specifying tar=internal (meaning that it uses R's builtin tar) everything worked fine. Thanks for your consideration though. On Jul 12, 11:14 pm, kcrisman kcris...@gmail.com wrote: On Jul 12, 10:57 pm, rickhg12hs rickhg1...@gmail.com wrote: I've tried to use R's untar command a number of different ways from Sage's commandline interface and I am having trouble listing the contents of a LZMA compressed TAR file. Actually, I don't seem to get any desirable output from r.untar so I am thinking I'm not even close to using the correct syntax. Syntax with R commands is not always obvious for optional keywords. Can you give us the *exact* R command (with options) you are trying to use? Note the documentation: What options are supported will depend on the ‘tar’ used. So it is possible that the R untar in question on Sage behaves differently from a 'native' implementation. But most likely it is the use of options that is the problem. Unfortunately I can't remember offhand how I've used them in the past :( but perhaps someone else will. If I have a LZMA compressed TAR file, how can I list/read it with Sage and/or r.untar in Sage? If you are just trying to use R from within Sage, without integrating it with the rest of Sage, you can also use r_console(), or use %r in the notebook, and just do things that way. - 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 URL: http://www.sagemath.org
Re: [sage-support] An argument for more direct axiom integration
On Tue, Jul 13, 2010 at 7:46 AM, Robert Bradshaw rober...@math.washington.edu wrote: On Mon, Jul 5, 2010 at 4:39 AM, Dr. David Kirkby david.kir...@onetel.net wrote: On 07/ 5/10 06:18 AM, William Stein wrote: Great idea - you could add an algorithm=axiom option to sage's integrate command. Personally, and I am going to dare risk argue with a mathematician, I would not have considered Axion an algorithm, but a software package. So something like method=use_axiom would seem more logical to me. The only argument for algorithm is that it's a standard idiom in Sage (though with a greatly generalized meaning). Additional arguments: 1. In Python a method is a function attached to a class. Thus the word method is already in common use in exactly this context, and using method= could cause confusion. 2. In many cases in Sage, the algorithm= option is *clearly* used to signify a different implementation of a specific algorithm. This is common the linear algebra code, where there are multiple implementations of distinct recognizably named algorithms, and the algorithm= flag helps you switch between them. E.g., algorithm=multimodular. 3. The code implemented in Axiom defines an algorithm -- it's the algorithm for symbolic integration as defined by the axiom implementation. Likewise for Sympy and Maxima. William -- William Stein 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Pattern matching of a symbolic function acting on a symbolic variable
On Mon, 12 Jul 2010 08:46:16 -0700 (PDT) David Sanders dpsand...@gmail.com wrote: I also note that after reading the documentation, I am still left without an answer to my original question, which is how to do pattern matching in Sage (or if it's even possible) for something of the form f(i) ! I don't think this is supported by GiNaC expressions at the moment. If using wildcards for functions is available in GiNaC, we can wrap it easily. Implementing it would take more time though. Can you ask the GiNaC list if this is possible purely using GiNaC (from C++)? Actually, from browsing the documentation, I can't even find symbolic functions in GiNaC like f = function('f') in Sage. Does this exist in GiNaC? Does the above Sage statement reference something in GiNaC? If so, what? Ginac doesn't support creating new symbolic functions at runtime. This was one of the first things we worked on when we started integrating GiNaC in Sage. (I tried to answer this question myself using function? function?? in Sage, but this just said that it was a built-in function, and gave me neither the name of a file, nor the source code. Is there another way of getting information about this?) This is also helpful sometimes: sage: function.__module__ 'sage.calculus.var' After chasing things around a little, you'll see that the relevant code is in sage/symbolic/function.pyx. Cheers, Burcin -- 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 URL: http://www.sagemath.org
[sage-support] Using ipython (magic) shell commands in notebook interface
Hi there, I'm a newbie Sage user and my question is related to using its notebook interface in a more convenient ipython-like way in my single machine (be it a laptop or desktop), if possible. What I mean, explicitly, for example, is being able to type: cd ~orca/research and being able to change to my research directory under my account. This works under the command line prompt of Sage (before launching the notebook) interface and I wonder whether it would be possible under the notebook as well. Another example was trying to use the ls shell command: ls I tried !ls and $ls, without success... Any help is appreciated! -- 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 URL: http://www.sagemath.org
Re: [sage-support] Using ipython (magic) shell commands in notebook interface
Hi, You can use: {{{ %sh cd ~/foobar ls echo Blah }}}, but any directory changes are limited to the cell only (due to architectural reasons). Otherwise, os.listdir('.') and and os.chdir('~/foo') are your best choices. On Tue, Jul 13, 2010 at 5:53 PM, orca mocal...@gmail.com wrote: Hi there, I'm a newbie Sage user and my question is related to using its notebook interface in a more convenient ipython-like way in my single machine (be it a laptop or desktop), if possible. What I mean, explicitly, for example, is being able to type: cd ~orca/research and being able to change to my research directory under my account. This works under the command line prompt of Sage (before launching the notebook) interface and I wonder whether it would be possible under the notebook as well. Another example was trying to use the ls shell command: ls I tried !ls and $ls, without success... Any help is appreciated! -- 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 URL: http://www.sagemath.org -- Tim Joseph Dumol tim (at) timdumol (dot) com http://timdumol.com -- 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 URL: http://www.sagemath.org
[sage-support] Superimpose various region_plot's
Hi, I need to superimpose several region_plot's. These have regions colored in different colors which may or may not overlap. However, if I do something like var('p q') plot1 = region_plot([p+q1, p+q-1], (p,-2,2), (q,-2,2), incol='red') plot2 = region_plot([p-q1, p-q-1], (p,-2,2), (q,-2,2), incol='blue') show(plot1+plot2) then I see at most the outline of the first plot. It seems that the second plot covers up the first plot, since the default value of outcol is 'white'. Is there any way to make these plots transparent (i.e. with an alpha value less than 1), or at least not opaque? I tried putting the option outcol=None but this is not accepted. This would seem to me to be the first way of solving the issue. I had a look at the code for region_plot, which I at least understand the idea of. It uses matplotlib for the graphics, so perhaps the question of transparency is a matplotlib question. Nonetheless, I believe that matplotlib does have this capability, so this should be possible...! Thanks and best wishes, David. -- 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 URL: http://www.sagemath.org
[sage-support] sage.numerical.optimize.minimize() returns without returning a value
I am trying to minimize numerically (over the reals) a polynomial S with rational coefficients. The function sage.numerical.optimize.minimize() returns without returning a value. Here's the relevant fragment of Sage code (executed using the menu item 'evaluate all') = BEGIN CODE FRAGMENT = N 44 # RQ = PolynomialRing(QQ, N, 'x', sparse=True); # this was executed earlier S in RQ True print 'S is a polynomial over Q in', len(S.variables()), 'variables'; print 'S is a quartic polynomial'; print 'S contains', len(S.coefficients()), 'terms'; S is a polynomial over Q in 44 variables S is a quartic polynomial S contains 55188 terms S_exp =SR(S); init_values = [0] * len(S_exp.variables()); soln=sage.numerical.optimize.minimize(S_exp,init_values); soln Traceback (click to the left of this block for traceback) ... NameError: name 'soln' is not defined = END OF CODE FRAGMENT = This does not happen for a smaller problem: S is a polynomial over Q in 40 variables S is a quartic polynomial S contains 34766 terms i.e., minimize() does successfully return a value. I'm running Sage Version 4.4.4 under OS X 10.6.4 on a macbookpro with 4GB RAM, acquired in the form sage-4.4.4-OSX-64bit-10.6-i386-Darwin.dmg I would attach the worksheet itself to this posting, if I saw a way to do so. Any help would be much appreciated. Also any pointers towards a more efficient method to minimize such polynomials. I'm just starting to learn Sage and Python. At the moment, the bottlenecks appear to be the conversion to a symbolic expression, 'S_exp =SR(S); ' and the execution of minimize(). The polynomial algebra used to construct S executes relatively quickly. The number of variables is of the form N=4mn where m and n are positive integers. I'd like to take N slightly larger, though I don't expect that my computing resources will allow taking N much larger, even if I use a more efficient method to minimize S. thanks, Daniel Friedan -- 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 URL: http://www.sagemath.org
[sage-support] Re: sage.numerical.optimize.minimize() returns without returning a value
On Jul 13, 3:07 pm, 8fjm39j dfrie...@gmail.com wrote: Any help would be much appreciated. I'm not sure if problems of this size work. Also, you should add the gradient to the minimize method. Here is a snippet that might help you. You do not need the SR as far as i can see. sage: RQ = PolynomialRing(QQ, 30, 'x', sparse=True) sage: RQ.inject_variables() Defining x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29 sage: eq = sum([ (v + random())^2 for v in RQ.gens() ]) sage: req = eq.change_ring(RDF) sage: import numpy as np sage: gradfun = lambda x:np.array(map(lambda f:f(*x), eq.gradient())) sage: minimize(lambda x : req(*x), [0]*req.parent().ngens(), gradient=gradfun) Optimization terminated successfully. Current function value: 0.00 Iterations: 2 Function evaluations: 4 Gradient evaluations: 4 (-0.55788239962, -0.0493798356231, -0.593303577877, -0.339802652733, -0.00394559417147, -0.178836124785, -0.343306688157, -0.126282234205, -0.642885679398, -0.27541451953, -0.689213436111, -0.41996375463, -0.602566339938, -0.626694430444, -0.771426488128, -0.0283310587547, -0.913384222525, -0.128570101865, -0.75252338794, -0.834385792852, -0.658475228648, -0.266546504385, -0.683600111652, -0.063955541513, -0.790083400019, -0.0634933885369, -0.136504640143, -0.978047564451, -0.743009613932, -0.276400559549) 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 URL: http://www.sagemath.org
[sage-support] Re: sage.numerical.optimize.minimize() returns without returning a value
Following up with another data point: Sage 4.3.4 under some version of Redhat Linux on an intel computer with 64GB RAM. The case that failed on the 4GB macbookpro succeeds here: minimize() returns a value. A larger case fails in the same manner, minimize() returning without a value: S is a polynomial over Q in 48 variables S is a quartic polynomial S contains 71138 terms. Daniel Friedan On Jul 13, 1:07 pm, 8fjm39j dfrie...@gmail.com wrote: I am trying to minimize numerically (over the reals) a polynomial S with rational coefficients. The function sage.numerical.optimize.minimize() returns without returning a value. Here's the relevant fragment of Sage code (executed using the menu item 'evaluate all') = BEGIN CODE FRAGMENT = N 44 # RQ = PolynomialRing(QQ, N, 'x', sparse=True); # this was executed earlier S in RQ True print 'S is a polynomial over Q in', len(S.variables()), 'variables'; print 'S is a quartic polynomial'; print 'S contains', len(S.coefficients()), 'terms'; S is a polynomial over Q in 44 variables S is a quartic polynomial S contains 55188 terms S_exp =SR(S); init_values = [0] * len(S_exp.variables()); soln=sage.numerical.optimize.minimize(S_exp,init_values); soln Traceback (click to the left of this block for traceback) ... NameError: name 'soln' is not defined = END OF CODE FRAGMENT = This does not happen for a smaller problem: S is a polynomial over Q in 40 variables S is a quartic polynomial S contains 34766 terms i.e., minimize() does successfully return a value. I'm running Sage Version 4.4.4 under OS X 10.6.4 on a macbookpro with 4GB RAM, acquired in the form sage-4.4.4-OSX-64bit-10.6-i386-Darwin.dmg I would attach the worksheet itself to this posting, if I saw a way to do so. Any help would be much appreciated. Also any pointers towards a more efficient method to minimize such polynomials. I'm just starting to learn Sage and Python. At the moment, the bottlenecks appear to be the conversion to a symbolic expression, 'S_exp =SR(S); ' and the execution of minimize(). The polynomial algebra used to construct S executes relatively quickly. The number of variables is of the form N=4mn where m and n are positive integers. I'd like to take N slightly larger, though I don't expect that my computing resources will allow taking N much larger, even if I use a more efficient method to minimize S. thanks, Daniel Friedan -- 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 URL: http://www.sagemath.org
[sage-support] Re: Using ipython (magic) shell commands in notebook interface
Hi Tim Thanks for the prompt reply! I have tried and, of course, confirmed your suggestions. However, I am a little concerned about the best way to streamline my experience with Sage. In fact, I find the embedding of the figures (all kinds of plots) and even Latex in the notebook quite amazing and nice; I would like to be able to merge all the convenience of ipython and the Sage notebook as well: I use to leave some data files in differente directories of my account and would like to easily and permanently change to these directories, within the Sage notebook... If I understood your reply correctly this is not possible, only for each cell of the notebook. That's frustrating; what is the rationale behind this, since, if I stick to Sage command line, I would, as far as I could tell, have all ipython;s functionality (apart from colored i/o..). How do you read or import a file from different directories, within the notebook??? Then how do you save data from within the notebook to your machine? Thanks again! On Jul 13, 6:59 am, Tim Joseph Dumol t...@timdumol.com wrote: Hi, You can use: {{{ %sh cd ~/foobar ls echo Blah }}}, but any directory changes are limited to the cell only (due to architectural reasons). Otherwise, os.listdir('.') and and os.chdir('~/foo') are your best choices. On Tue, Jul 13, 2010 at 5:53 PM, orca mocal...@gmail.com wrote: Hi there, I'm a newbie Sage user and my question is related to using its notebook interface in a more convenient ipython-like way in my single machine (be it a laptop or desktop), if possible. What I mean, explicitly, for example, is being able to type: cd ~orca/research and being able to change to my research directory under my account. This works under the command line prompt of Sage (before launching the notebook) interface and I wonder whether it would be possible under the notebook as well. Another example was trying to use the ls shell command: ls I tried !ls and $ls, without success... Any help is appreciated! -- 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 athttp://groups.google.com/group/sage-support URL:http://www.sagemath.org -- Tim Joseph Dumol tim (at) timdumol (dot) comhttp://timdumol.com -- 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 URL: http://www.sagemath.org
[sage-support] Re: Superimpose various region_plot's
On 7/13/10 4:46 AM, David Sanders wrote: Hi, I need to superimpose several region_plot's. These have regions colored in different colors which may or may not overlap. However, if I do something like var('p q') plot1 = region_plot([p+q1, p+q-1], (p,-2,2), (q,-2,2), incol='red') plot2 = region_plot([p-q1, p-q-1], (p,-2,2), (q,-2,2), incol='blue') show(plot1+plot2) then I see at most the outline of the first plot. It seems that the second plot covers up the first plot, since the default value of outcol is 'white'. Is there any way to make these plots transparent (i.e. with an alpha value less than 1), or at least not opaque? I tried putting the option outcol=None but this is not accepted. This would seem to me to be the first way of solving the issue. I had a look at the code for region_plot, which I at least understand the idea of. It uses matplotlib for the graphics, so perhaps the question of transparency is a matplotlib question. Nonetheless, I believe that matplotlib does have this capability, so this should be possible...! It seems that adding transparency is a natural way to do this. I've posted a rough patch to do this up at http://trac.sagemath.org/sage_trac/ticket/9491 I've also attached a figure resulting from: var('p q') plot1 = region_plot([p+q1, p+q-1], (p,-2,2), (q,-2,2), incol='red', opacity=0.5) plot2 = region_plot([p-q1, p-q-1], (p,-2,2), (q,-2,2), incol='blue', opacity=0.5) show(plot1+plot2) Sorry I don't have right now to finish the patch and ask for review; I'm rushing out the door. Thanks, Jason -- 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 URL: http://www.sagemath.org attachment: regionplot.png
[sage-support] Re: sage.numerical.optimize.minimize() returns without returning a value
Thanks for your suggestion. I've now running a worksheet using your method to minimize a large polynomial. So far, minimize() has not yet returned. One minor question: in your definition of the gradient function, sage: gradfun = lambda x:np.array(map(lambda f:f(*x), eq.gradient())) should that be 'eq.gradient()' or should it be 'req.gradient()' ? (recall that req = eq.change_ring(RDF)) thanks, Daniel Daniel Friedan On Jul 13, 2:05 pm, Harald Schilly harald.schi...@gmail.com wrote: On Jul 13, 3:07 pm, 8fjm39j dfrie...@gmail.com wrote: Any help would be much appreciated. I'm not sure if problems of this size work. Also, you should add the gradient to the minimize method. Here is a snippet that might help you. You do not need the SR as far as i can see. sage: RQ = PolynomialRing(QQ, 30, 'x', sparse=True) sage: RQ.inject_variables() Defining x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29 sage: eq = sum([ (v + random())^2 for v in RQ.gens() ]) sage: req = eq.change_ring(RDF) sage: import numpy as np sage: gradfun = lambda x:np.array(map(lambda f:f(*x), eq.gradient())) sage: minimize(lambda x : req(*x), [0]*req.parent().ngens(), gradient=gradfun) Optimization terminated successfully. Current function value: 0.00 Iterations: 2 Function evaluations: 4 Gradient evaluations: 4 (-0.55788239962, -0.0493798356231, -0.593303577877, -0.339802652733, -0.00394559417147, -0.178836124785, -0.343306688157, -0.126282234205, -0.642885679398, -0.27541451953, -0.689213436111, -0.41996375463, -0.602566339938, -0.626694430444, -0.771426488128, -0.0283310587547, -0.913384222525, -0.128570101865, -0.75252338794, -0.834385792852, -0.658475228648, -0.266546504385, -0.683600111652, -0.063955541513, -0.790083400019, -0.0634933885369, -0.136504640143, -0.978047564451, -0.743009613932, -0.276400559549) 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 URL: http://www.sagemath.org
[sage-support] Re: sage.numerical.optimize.minimize() returns without returning a value
On 13 Jul., 17:32, 8fjm39j dfrie...@gmail.com wrote: One minor question: in your definition of the gradient function, sage: gradfun = lambda x:np.array(map(lambda f:f(*x), eq.gradient())) should that be 'eq.gradient()' or should it be 'req.gradient()' ? (recall that req = eq.change_ring(RDF)) I only did this through a feeling, but benchmarking it revealed that it doesn't matter. You can do this via %timeit Here is an significant improvement for the gradient: sage: gradfun = lambda x:np.array(map(lambda f:f(*x), eq.gradient())) sage: grad = [fast_float(g) for g in eq.gradient() ] sage: gradfun2 = lambda x:np.array(map(lambda f:f(*x), grad)) same output: sage: all(gradfun2([1]*30) == gradfun([1]*30)) True but sage: %timeit gradfun([1]*30) 125 loops, best of 3: 4.7 ms per loop sage: %timeit gradfun2([1]*30) 625 loops, best of 3: 110 µs per loop ~ 42x faster! Maybe there is an even faster way ...? - cython Also, there are different solvers wrapped, e.g. conjugate gradients. sage: minimize(lambda x : eq(*x), [0]*eq.parent().ngens(), gradient=gradfun2, algorithm=cg) or look directly into the scipy.optimize module. 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 URL: http://www.sagemath.org
Re: [sage-support] Re: sage.numerical.optimize.minimize() returns without returning a value
cvvcv 2010/7/13 8fjm39j dfrie...@gmail.com Following up with another data point: Sage 4.3.4 under some version of Redhat Linux on an intel computer with 64GB RAM. The case that failed on the 4GB macbookpro succeeds here: minimize() returns a value. A larger case fails in the same manner, minimize() returning without a value: S is a polynomial over Q in 48 variables S is a quartic polynomial S contains 71138 terms. Daniel Friedan On Jul 13, 1:07 pm, 8fjm39j dfrie...@gmail.com wrote: I am trying to minimize numerically (over the reals) a polynomial S with rational coefficients. The function sage.numerical.optimize.minimize() returns without returning a value. Here's the relevant fragment of Sage code (executed using the menu item 'evaluate all') = BEGIN CODE FRAGMENT = N 44 # RQ = PolynomialRing(QQ, N, 'x', sparse=True); # this was executed earlier S in RQ True print 'S is a polynomial over Q in', len(S.variables()), 'variables'; print 'S is a quartic polynomial'; print 'S contains', len(S.coefficients()), 'terms'; S is a polynomial over Q in 44 variables S is a quartic polynomial S contains 55188 terms S_exp =SR(S); init_values = [0] * len(S_exp.variables()); soln=sage.numerical.optimize.minimize(S_exp,init_values); soln Traceback (click to the left of this block for traceback) ... NameError: name 'soln' is not defined = END OF CODE FRAGMENT = This does not happen for a smaller problem: S is a polynomial over Q in 40 variables S is a quartic polynomial S contains 34766 terms i.e., minimize() does successfully return a value. I'm running Sage Version 4.4.4 under OS X 10.6.4 on a macbookpro with 4GB RAM, acquired in the form sage-4.4.4-OSX-64bit-10.6-i386-Darwin.dmg I would attach the worksheet itself to this posting, if I saw a way to do so. Any help would be much appreciated. Also any pointers towards a more efficient method to minimize such polynomials. I'm just starting to learn Sage and Python. At the moment, the bottlenecks appear to be the conversion to a symbolic expression, 'S_exp =SR(S); ' and the execution of minimize(). The polynomial algebra used to construct S executes relatively quickly. The number of variables is of the form N=4mn where m and n are positive integers. I'd like to take N slightly larger, though I don't expect that my computing resources will allow taking N much larger, even if I use a more efficient method to minimize S. thanks, Daniel Friedan -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.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 URL: http://www.sagemath.org
[sage-support] adding more points to an existing polyhedron
Hi, if I have an existing polyhedron p and want to add a vertex v (that was not in p) to p, is it possible to modify it (e.g., adding new vertices v to p) instead of creating a new polyhedron p' that contains all the previous vertices of p and v ? Thanks, -- 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 URL: http://www.sagemath.org
Re: [sage-support] An argument for more direct axiom integration
On 07/13/10 08:05 AM, William Stein wrote: On Tue, Jul 13, 2010 at 7:46 AM, Robert Bradshaw rober...@math.washington.edu wrote: On Mon, Jul 5, 2010 at 4:39 AM, Dr. David Kirkby david.kir...@onetel.net wrote: On 07/ 5/10 06:18 AM, William Stein wrote: Great idea - you could add an algorithm=axiom option to sage's integrate command. Personally, and I am going to dare risk argue with a mathematician, I would not have considered Axion an algorithm, but a software package. So something like method=use_axiom would seem more logical to me. The only argument for algorithm is that it's a standard idiom in Sage (though with a greatly generalized meaning). Additional arguments: 1. In Python a method is a function attached to a class. Thus the word method is already in common use in exactly this context, and using method= could cause confusion. 'method' was only meant as an example. 'software' would all seem more logical than algorithm. 2. In many cases in Sage, the algorithm= option is *clearly* used to signify a different implementation of a specific algorithm. This is common the linear algebra code, where there are multiple implementations of distinct recognizably named algorithms, and the algorithm= flag helps you switch between them. E.g., algorithm=multimodular. In such cases, it makes sense to use 'algorithm'. I'm less convinced when you are calling a software package, and asking it to do the work. 3. The code implemented in Axiom defines an algorithm -- it's the algorithm for symbolic integration as defined by the axiom implementation. Likewise for Sympy and Maxima. William I'm a bit less convinced of that myself. I would have thought Maxima uses specific algorithms, so to refer to maxima as an algorithm is not really accurate. I personally would have thought refering to Maxima as a software package is more accurate than an 'algorithm'. Dave -- 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 URL: http://www.sagemath.org
[sage-support] Re: Superimpose various region_plot's
On Jul 13, 4:47 pm, Jason Grout jason-s...@creativetrax.com wrote: On 7/13/10 4:46 AM, David Sanders wrote: Hi, I need to superimpose several region_plot's. These have regions colored in different colors which may or may not overlap. However, if I do something like var('p q') plot1 = region_plot([p+q1, p+q-1], (p,-2,2), (q,-2,2), incol='red') plot2 = region_plot([p-q1, p-q-1], (p,-2,2), (q,-2,2), incol='blue') show(plot1+plot2) then I see at most the outline of the first plot. It seems that the second plot covers up the first plot, since the default value of outcol is 'white'. Is there any way to make these plots transparent (i.e. with an alpha value less than 1), or at least not opaque? I tried putting the option outcol=None but this is not accepted. This would seem to me to be the first way of solving the issue. I had a look at the code for region_plot, which I at least understand the idea of. It uses matplotlib for the graphics, so perhaps the question of transparency is a matplotlib question. Nonetheless, I believe that matplotlib does have this capability, so this should be possible...! It seems that adding transparency is a natural way to do this. I've posted a rough patch to do this up athttp://trac.sagemath.org/sage_trac/ticket/9491 I've also attached a figure resulting from: var('p q') plot1 = region_plot([p+q1, p+q-1], (p,-2,2), (q,-2,2), incol='red', opacity=0.5) plot2 = region_plot([p-q1, p-q-1], (p,-2,2), (q,-2,2), incol='blue', opacity=0.5) show(plot1+plot2) Exactly what I had in mind, thanks! David. Sorry I don't have right now to finish the patch and ask for review; I'm rushing out the door. Thanks, Jason regionplot.png 27KViewDownload -- 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 URL: http://www.sagemath.org
Re: [sage-support] An argument for more direct axiom integration
On Tue, Jul 13, 2010 at 7:24 PM, Dr. David Kirkby david.kir...@onetel.net wrote: On 07/13/10 08:05 AM, William Stein wrote: On Tue, Jul 13, 2010 at 7:46 AM, Robert Bradshaw rober...@math.washington.edu wrote: On Mon, Jul 5, 2010 at 4:39 AM, Dr. David Kirkby david.kir...@onetel.net wrote: On 07/ 5/10 06:18 AM, William Stein wrote: Great idea - you could add an algorithm=axiom option to sage's integrate command. Personally, and I am going to dare risk argue with a mathematician, I would not have considered Axion an algorithm, but a software package. So something like method=use_axiom would seem more logical to me. The only argument for algorithm is that it's a standard idiom in Sage (though with a greatly generalized meaning). Additional arguments: 1. In Python a method is a function attached to a class. Thus the word method is already in common use in exactly this context, and using method= could cause confusion. 'method' was only meant as an example. 'software' would all seem more logical than algorithm. 2. In many cases in Sage, the algorithm= option is *clearly* used to signify a different implementation of a specific algorithm. This is common the linear algebra code, where there are multiple implementations of distinct recognizably named algorithms, and the algorithm= flag helps you switch between them. E.g., algorithm=multimodular. In such cases, it makes sense to use 'algorithm'. I'm less convinced when you are calling a software package, and asking it to do the work. 3. The code implemented in Axiom defines an algorithm -- it's the algorithm for symbolic integration as defined by the axiom implementation. Likewise for Sympy and Maxima. William I'm a bit less convinced of that myself. I would have thought Maxima uses specific algorithms, so to refer to maxima as an algorithm is not really accurate. I personally would have thought refering to Maxima as a software package is more accurate than an 'algorithm'. Whatever Maxima (or Axiom, or whatever) does, it is an implementation of an algorithm.That algorithm builds on other algorithms. I don't think I'll pursue this thread further, since it is boring to most readers, and hardly counts as sage-support. algorithm=... -- 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 URL: http://www.sagemath.org
[sage-support] Re: adding more points to an existing polyhedron
Hi, if I have an existing polyhedron p and want to add a vertex v (that was not in p) to p, is it possible to modify it (e.g., adding new vertices v to p) instead of creating a new polyhedron p' that contains all the previous vertices of p and v ? It might be worth pointing out the docstring (type Polyhedron?). About three-quarters of the way down, there's a bullet under the section NOTES that says Once constructed, a Polyhedron object is immutable. Sorry, I don't know enough about Sage to provide any more advice :/ Kelvin -- 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 URL: http://www.sagemath.org
[sage-support] Re: adding more points to an existing polyhedron
On Jul 13, 2:16 pm, TianWei ltwis...@gmail.com wrote: Hi, if I have an existing polyhedron p and want to add a vertex v (that was not in p) to p, is it possible to modify it (e.g., adding new vertices v to p) instead of creating a new polyhedron p' that contains all the previous vertices of p and v ? It might be worth pointing out the docstring (type Polyhedron?). About three-quarters of the way down, there's a bullet under the section NOTES that says Once constructed, a Polyhedron object is immutable. I see, that's what I thought too after browsing the help files and see no functions similar to what I am looking for. Thanks ! Sorry, I don't know enough about Sage to provide any more advice :/ Kelvin -- 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 URL: http://www.sagemath.org