[sage-support] Re: Some bugs and some wishes
On 16 Feb., 10:43, Manuel Kauers man...@kauers.de wrote: Hi there, here are some bugs which may or may not be already known. If they are new, could you please file them wherever such bugs need to be filed? Or if they are not bugs but wrong usage, could you explain to me what I should type instead? I am still working with version 4.7.1, so some remarks might be obsolete already. (Sorry about that.) 1. When I have rational functions over a field [or over an integral domain], I expect that the denominator is made monic [or the content of numerator and denominator coprime]. This is not always happening. For example: sage: R.x = QQ[] sage: (2*x+4)/(4*x-8) (2*x + 4)/(4*x - 8) # bad sage: R.x = ZZ[] sage: (2*x+4)/(4*x-8) (x + 2)/(2*x - 4) # good Although mathematically correct, I consider this as a bug, because not bringing rational functions to normal form can easily lead to ridiculous expression swell. For example: sage: R1.x = QQ[] sage: R2.y = R1.fraction_field()[] sage: K = R2.fraction_field() sage: def canonic(rat): num, den = rat.numerator(), rat.denominator() clear = lcm(num.denominator(), den.denominator()) num, den = num*clear, den*clear clear = map(lambda p: p.numerator().coeffs(), \ num.coeffs() + den.coeffs()) clear = lcm([a.denominator() for b in clear for a in b]) num, den = num*clear, den*clear x = rat.parent().gen() t = rat.parent().base_ring().gen() return rat.parent()(ZZ[t,x](num)/ZZ[t,x](den)) sage: d = K.random_element().derivative(y).derivative(x); sage: len(str(d)) 919274 sage: len(str(canonic(d))) 8371 2. A coercion problem? sage: K = QQ[x].fraction_field() sage: R.y = K[] sage: S = QuotientRing(R, R.ideal(y^2-(x^2+1))) sage: ybar = S.gen() sage: S(y) # works ybar sage: 1/ybar # works (-1/(-x^2 - 1))*ybar sage: S(1/y) # doesn't work *** output flushed *** TypeError: denominator must be a unit 3. Another coercion problem? sage: R0 = QQ['t'].fraction_field(); t = R0.gen() sage: R1 = R0['x'].fraction_field(); x = R1.gen() sage: R2 = R1['y']; y = R2.gen() sage: R = QuotientRing(R2, R2.ideal(y^2-(x+t))) sage: ybar = R.gen() sage: ybar^2 # works x + t sage: ybar + x # works ybar + x sage: ybar * x # doesn't work *** output flushed *** NotImplementedError: sage: ybar*R(x) # works x*ybar 4. A bug in LCM: sage: u = QQ['u'].gen(); v = QQ[u].fraction_field()['v'].gen() sage: pol = ((u^2 - u - 1)/(-1/5*u^2 - u - 1))*v^2 + ((4/9*u^2 - 1/2)/(1/2*u - 2))*v + (2*u^2 - 1/2*u - 1/3)/(-2*u^2 - 5*u - 1/2) sage: lcm(pol, 1) *** output flushed *** TypeError: denominator must be a unit 5. The universe of a factorization cannot be changed if the factorization happens to be empty. sage: factor(2).base_change(ZZ['t','x']).universe() Multivariate Polynomial Ring in t, x over Integer Ring # correct sage: factor(1).base_change(ZZ['t','x']).universe() Integer Ring # incorrect 6. Resultants for elements of Quot(ZZ[t])[x,y] crash. sage: K = ZZ['t'].fraction_field(); t = K.gen() sage: R = K['x', 'y']; x,y = R.gens() sage: R.random_element().resultant(R.random_element(), y) *** Output flushed *** TypeError: denominator must be a unit 7. Nullspace for matrices over finite fields is unreasonably slow sage: M = MatrixSpace(GF(2^31-1), 1000, 1001).random_element(); sage: %time M.right_kernel(); CPU times: user 165.71 s, sys: 0.01 s, total: 165.73 s Wall time: 166.20 s Mathematica does this almost 20 times as fast: In[5]:= mat = Table[RandomInteger[{0,2^31-1}], {n,0,1000},{k,0,1001}]; In[6]:= Timing[NullSpace[mat, Modulus - 2^31-1];] Out[6]= {8.98856, Null} And here is a wish list of some things that I would find convenient to have, but didn't find. 1. a method .derivative for quotient ring elements, with which algebraic functions can be differentiated. 2. a method Factorization.square_free_part 3. a possibility to specify a variable in the method .minpoly for quotient ring elements. It is confusing that this method takes 'x' as variable for the minimal polynomial even if there is already an 'x' in the ground field. Thanks best regards, Manuel *bump* I some of those are real bugs I could copy over these examples to tickets on Sage Trac. Or do you want to create an account and file those tickets yourself which would be preferable?. -- 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: Reserved words (Sage + Cython)
Hi Oleksandr, On 17 Feb., 21:52, Oleksandr Kazymyrov vrona.aka.ham...@gmail.com wrote: Can anyone reproduce the same bug on Ubuntu? The situation somehow reminds me a problem that I once had with a wrapper of the C-MeatAxe (an implementation of matrices that I use it in an optional Sage package). There was a C-function (I think it was called matid), but in order to make it work on Solaris, I had to rename the function. It turned out that the linker was mistaking the function with another function of the same name in a totally different package. So, that should probably be called a Solaris bug, not a Sage bug. If a similar thing is happening here as well, I suggest to be practical: Rename it, if that solves the problem. 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 URL: http://www.sagemath.org
[sage-support] Re: Reserved words (Sage + Cython)
Hi Simon, Rename it, if that solves the problem. I have done it. But I wonder why has that happened after upgrade from 4.7.2 to 4.8 (5.0beta4)? Best regards, Oleksandr -- 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: finding a p-cycle of a real function
Thank you very much to both of you for your help with this, that is great, I appreciate it a lot. On Feb 11, 9:43 pm, John Cremona john.crem...@gmail.com wrote: Numerical precision issues would make it preferable (surely?) to use exact arithmetic by replacing 1.76 by 176/100. Do you know the standard trick (as used for instance in the Pollard rho method of factorization) which avoids storing lots of terms of the sequence and instead runs two variables through the sequence simultaneously, starting at the same point, but with one sequence applying the iteration twice? then you just have to check when the two values coincide. Details left to the reader, or seehttp://en.wikipedia.org/wiki/Floyd%27s_cycle-finding_algorithm#Tortoi... John On 11 February 2012 20:34, D. S. McNeil dsm...@gmail.com wrote: Warning: I haven't thought this through, but the ideas might be useful. It looks like you'd call something a 3-cycle if for some x_0 we had f(f(f(x_0))) == x_0, right? Then we should be able to do this numerically, with some caveats: # can't remember the slick way, so brute force def iter_apply(f0, n): fs = [f0()] for i in xrange(n-1): last = fs[-1] fs.append(f0(last)) return fs def find_pcycles(f0, n): fs = iter_apply(f0, n) req = fs[-1] == x # defining equation of the cycle roots = req.roots(ring=RR) for root, mult in roots: yield [fi(x=root) for fi in fs] which gives sage: f(x) = x^2-1.76 sage: sage: p1 = list(find_pcycles(f, 1)) sage: p1 [[-0.917744687875782], [1.91774468787578]] sage: f(p1[0][0]) -0.917744687875783 sage: f(p1[1][0]) 1.91774468787578 sage: list(find_pcycles(f, 2)) [[0.504987562112089, -1.50498756211209], [-0.917744687875783, -0.917744687875782], [-1.50498756211209, 0.504987562112089], [1.91774468787578, 1.91774468787578]] sage: list(find_pcycles(f, 3)) [[1.33560128916886, 0.0238308036295167, -1.75943209279837], [1.27545967679486, -0.133202612870350, -1.74225706392451], [-0.917744687875783, -0.917744687875782, -0.917744687875783], [-1.74225706392451, 1.27545967679486, -0.133202612870348], [-1.75943209279837, 1.33560128916886, 0.0238308036295143], [-0.133202612870349, -1.74225706392451, 1.27545967679486], [0.0238308036295150, -1.75943209279837, 1.33560128916886], [1.91774468787578, 1.91774468787578, 1.91774468787578]] Note that this says [-0.917744687875783, -0.917744687875782, -0.917744687875783] is a 3-cycle, which it kind of is.. Anyway, maybe playing off of something like that would help? Doug -- 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 -- 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] colouring documents about SAGE, written using sphinx
Dear all, I'd like to write a little document about using SAGE, using sphinx to write it, and host my document at readthedocs.org I'm wondering how can I get the beautiful colouring of sphinx documentation on SAGE, which I see at http://www.sagemath.org/doc/ ? As far as I can see, there is no specific 'sage' formatting available in sphinx (like there is for R, python, and many other languages), is that true? By the way, I wasn't sure if this query should go to the SAGE 'edu' mailing list, I hope I haven't sent it to the wrong one. Kind Regards, Avril Avril Coghlan Cork, Ireland -- 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 change the size of ticks ? ( use of graphs for presentations )
The following might be useful for somebody who want to get larger ticks. I discovered, that this works for sage graphs, too - when adapting the defaults for a histogram (which requires to call matplotlib directly). Put the following at the start of the Notebook: thickN = 3 #line thickness fontN = 16 #default fontsize import matplotlib from pylab import figure, show matplotlib.rcParams.update({'lines.linewidth':thickN }) matplotlib.rcParams.update({'axes.linewidth':thickN }) matplotlib.rcParams.update({'axes.labelsize':fontN}) matplotlib.rcParams.update({'xtick.major.size':6}) #length of ticks matplotlib.rcParams.update({'lines.markeredgewidth':2}) #width of ticks matplotlib.rcParams.update({'lines.markersize':6}) #size of ticks matplotlib.rcParams.update({'patch.linewidth':thickN }) #linewidth of histogram matplotlib.rcParams.update({'font.size': fontN})#fontsize of histogram Put the rest of your code, here. It seems that most of the defaults are overwritten by Sage plots. However Sage does not cover ticks yet, and it seems that the defaults from matplotlib are used for the ticks. (That is my interpretation) Obviously, some of the parameters above are not required for the ticks, but I post this here anyway, since it could be useful for somebody else. Is there a similar method to change the defaults for Sage plot? This would make my code much clearer. Thanks Goebbe -- 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] polygon graph is too small (wrong scale)
Using sage 4.8 in the notebook environment I have problems to scale polygons: For example, the following code generates a graphs that seems to be to small (not high enough): polygon2d([[0,0],[0,1],[-1,0]], rgbcolor=(1,0,1),xmin=-4, xmax=4, ymin=0, ymax=1) The final goal is to fill (non trivial) areas in plots, but when trying this the plots are much too small. here is the large example: signi = 0.1 lu = NV01.cum_distribution_function_inv(signi/2) lo = NV01.distribution_function(lu) ru = NV01.cum_distribution_function_inv(1-(signi/2)) ro = NV01.distribution_function(ru) p = NV01.plot((x,-4,4), fill='axis',fillcolor='blue',fillalpha='0.2') p += polygon([(lu,0),(lu,NV01.distribution_function(lu))] + [(x,NV01.distribution_function(x)) for x in [lu-0.1,lu-0.2,..,-2]] + [(-4,0),(lu,0)], rgbcolor=(1,0,0), alpha=0.3) p += polygon([(ru,0),(ru,NV01.distribution_function(ru))] + [(x,NV01.distribution_function(x)) for x in [ru+0.1,ru+0.2,..,2 ]] + [ (4,0),(ru,0)], rgbcolor=(1,0,0), alpha=0.3) p.show() Is this a bug? Does anybody know a workaround? Thanks in advance Goebbe -- 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: Simplification Issue Implicates Canonical Form
I appreciate that background info. I hadn't tried invoking maxima because I read somewhere that simplify() used maxima. I must've been reading outdated material. As you stated, maxima does the correct thing. Because Sage can invoke maxima, perhaps I have a work around. You're right that this issue should be considered in the context of powers. In that context, I think it is even more clear that 5^(-1/2) is simpler than (1/5) * 5^(1/2). Leaving the additional term doesn't seem like a big deal, but by preventing subsequent simplifications, and by combining and recombining with other large expressions, it can have highly undesirable effects. I took a quick look at ginsh, the GiNaC interactive shell. It converts 1/sqrt(5) to 1/5*sqrt(5) so I suspect that this issue can be traced to the GiNaC canonical form. I'm not a CAS expert but I know a fair amount about computer system interfaces and I'm sure this issue adversely impacts the user experience. Nobody would select equation obfuscation mode given the choice. I think this issue should be taken up with the GiNaC folks. Do they hang out in this group? -Mark -- 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] full_output.txt
How do I make the cell output, for example from 'print', to go _always_ in a separate document as in WARNING: Output truncated! full_output.txt? How do I make that file automatically displayed/ refreshed in a pop-up browser window? -- 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] Question about rdtsc()
Dear members Exist any function in SAGE with same goal of rdtsc() in C?. For example: tmp_ini = rdtsc() ... instructions .. ... tmp_dec = rdtsc() - tmp_ini; -- 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