[sage-support] Simplification of multivariable polynomial over a polynomial ring
Hello, I want to work with multivariate polynomials over a multivariate polynomial ring (see below for the reason I want to do this). K.a,b=PolynomialRing(QQ, 2, order='lex') QM.X,Y,Z = PolynomialRing(K, 3, order='lex') However, I have problems when I want to simplify. Consider for example, F=(a*b*X^2*Y*Z + X*Y^3)/Y This is clearly a*b*X^2*Z + X*Y^2. However, I cannot automatically simplify it since : F.simplify() returns AttributeError: 'sage.rings.fraction_field_element.FractionFieldElement' object has no attribute 'simplify' whereas F.reduce() returns AttributeError: 'sage.rings.fraction_field_element.FractionFieldElement' object has no attribute 'simplify'. How can I make the simplification with Sage ? Thank you very much for your help! NB. The reason why I want to consider multivariate polynomials over a multivariate polynomial ring, and not a multivariate polynomials with more variable is the following I need to be able to detect monomials in a polynomial, For rexample, I want the monomials of (1+a+b)X^2Y+2bXY^2+ab+a to be (1+a+b)X^2Y, 2bXY^2 and ab+a instead of X^2Y, aX^2Y, bX^2Y, 2bXY^2, ab and a. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Simplification of multivariable polynomial over a polynomial ring
On Feb 18, 2013, at 1:47 PM, Emmanuel wrote: Hello, I want to work with multivariate polynomials over a multivariate polynomial ring (see below for the reason I want to do this). K.a,b=PolynomialRing(QQ, 2, order='lex') QM.X,Y,Z = PolynomialRing(K, 3, order='lex') However, I have problems when I want to simplify. Consider for example, F=(a*b*X^2*Y*Z + X*Y^3)/Y In fact, it is precisely the fact that you build a polynomial ring over a polynomial ring that causes problems. Look at this example : sage: K.a,b,X,Y,Z = QQ[] sage: F = (a*b*X^2*Y*Z + X*Y^3)/Y; F a*b*X^2*Z + X*Y^2 The simplification is done automatically. But note that the result (F) no longer lives in the polynomial ring. Since it is a quotient, it lives in the **fraction field** of the ring. This is because Sage does not know in advance whether the division is exact or not. Try : sage: parent(F) Fraction Field of Multivariate Polynomial Ring in a, b, X, Y, Z over Rational Field If you KNOW that the division is exact, you can do : sage: F = (a*b*X^2*Y*Z + X*Y^3) // Y sage: parent(F) Multivariate Polynomial Ring in a, b, X, Y, Z over Rational Field This division procedure is not available over your fancier ring-on-top-of-a-ring. (Btw, the error message is somewhat not-use-friendly). Your problems with monomials can be solved as follows : sage: R.a,b,X,Y,Z = QQ[] sage: f = (1+a+b)*X^2*Y+2*b*X*Y^2+a*b+a sage: K.a,b = QQ[] sage: QM.X,Y,Z = K[] and you can cast f into QM : sage: QM(f).monomials() [X^2*Y, X*Y^2, 1] sage: QM(f).coefficients() [a + b + 1, 2*b, a*b + a] --- Charles Bouillaguet http://www.lifl.fr/~bouillaguet/ This is clearly a*b*X^2*Z + X*Y^2. However, I cannot automatically simplify it since : F.simplify() returns AttributeError: 'sage.rings.fraction_field_element.FractionFieldElement' object has no attribute 'simplify' whereas F.reduce() returns AttributeError: 'sage.rings.fraction_field_element.FractionFieldElement' object has no attribute 'simplify'. How can I make the simplification with Sage ? Thank you very much for your help! NB. The reason why I want to consider multivariate polynomials over a multivariate polynomial ring, and not a multivariate polynomials with more variable is the following I need to be able to detect monomials in a polynomial, For rexample, I want the monomials of (1+a+b)X^2Y+2bXY^2+ab+a to be (1+a+b)X^2Y, 2bXY^2 and ab+a instead of X^2Y, aX^2Y, bX^2Y, 2bXY^2, ab and a. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Memory usage
Hi, I am wondering about the following phenomenon: I have a list interrels of polynomials in many variables and a list potential_sols of potential solutions and I am using the following code to check which are actually solutions (roots). I use the following code sols=[] for psol in potential_sols: for interrel in interrels: if interrel(*psol)!=0: break else: print(psol) sols.append(psol) I am not surprised (under my circumstances) that this takes long, though actually it wasn't that bad at first. What surprises me is that it uses huge amounts of memory. The actual data don't take that much memory and the code just linearly runs through all possibilities so it practically shouldn't need any extra memory at all (at most another copy of potential_sols). But instead it had filled the 4 GB physical memory plus 2 GB swap when I canceled it (of course by that time it also was terribly slow, just because of all the swapping). This seems to suggest memory leaks. Is there any way I could check what part of sage (and which data structures) use how much memory? Are there any known issues about memory leaks related to polynomial rings over finite fields? Is there a garbage collection I have to call manually? Thanks for any help! Best, Stefan -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] 503 Service Temporarily Unavailable
Hi, I'm running a sage notebook server for a math professor and I am getting a 503 temporarily unavailable error. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Memory usage
Hi, I found some answers myself. The memory usage can be found out with get_memory_usage() and there is a garbage collection that can be called manually via import gc gc.collect() so I could do something like import gc i=i+1 if (i%1==0): if get_memory_usage()3000: gc.collect() but shouldn't there be a more automatic way? Thanks! Best, Stefan On Monday, February 18, 2013 2:17:16 PM UTC+1, switzel wrote: Hi, I am wondering about the following phenomenon: I have a list interrels of polynomials in many variables and a list potential_sols of potential solutions and I am using the following code to check which are actually solutions (roots). I use the following code sols=[] for psol in potential_sols: for interrel in interrels: if interrel(*psol)!=0: break else: print(psol) sols.append(psol) I am not surprised (under my circumstances) that this takes long, though actually it wasn't that bad at first. What surprises me is that it uses huge amounts of memory. The actual data don't take that much memory and the code just linearly runs through all possibilities so it practically shouldn't need any extra memory at all (at most another copy of potential_sols). But instead it had filled the 4 GB physical memory plus 2 GB swap when I canceled it (of course by that time it also was terribly slow, just because of all the swapping). This seems to suggest memory leaks. Is there any way I could check what part of sage (and which data structures) use how much memory? Are there any known issues about memory leaks related to polynomial rings over finite fields? Is there a garbage collection I have to call manually? Thanks for any help! Best, Stefan -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Memory usage
Hi, On 2013-02-18, switzel stwit...@gmail.com wrote: so I could do something like import gc i=i+1 if (i%1==0): if get_memory_usage()3000: gc.collect() but shouldn't there be a more automatic way? Thanks! Garbage collection *is* automatic, and there is no need to call it manually. And actually it wouldn't help to call it manually. What Sage version are you using? Namely, the most recent version (or perhaps beta version?) contains several fixes for memory leaks that come from an over-eager cache. Best regards, Simon -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: 503 Service Temporarily Unavailable
Nathan Yeung nathan.ye...@mathematics.byu.edu writes: Hi, I'm running a sage notebook server for a math professor and I am getting a 503 temporarily unavailable error. If you're running your own sage notebook server, and not referring to sagenb.org, then that's far from enough information for anyone to be able to diagnose what's going wrong. Please elaborate. -Keshav -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Re: Boolean Variables
Thank you very much. On 16 February 2013 21:50, akhil lalwani.ak...@gmail.com wrote: On Saturday, February 16, 2013 9:38:14 AM UTC+5:30, Santanu wrote: Dear all, I have the following problem. I am working with Boolean variables. So I call the following. from sage.crypto.boolean_function import BooleanFunction R.x0,x1,x2,x3,x4,x5,x6,x7,x8,**x9=BooleanPolynomialRing(10) Suppose during run time of my code, I get three polynomials x1*x2+x3+x4, x0+x5, x4+x5. Now I want to replace last polynomial by x4=x1*x2+x3 x5=x0. However this replacement is not constant. That is next time x4 may be replaced by x0+x1. How this is possible? Hi, The subs( ) function works with symbolic variables as well. Therefore, to replace x4 by x1*x2 + x3 and x5 by x0, do the following: sage:from sage.crypto.boolean_function import BooleanFunction sage:R.x0,x1,x2,x3,x4,x5,x6,x7,x8,x9=BooleanPolynomialRing(10) sage:f = x4 + x5 sage:f.subs({x4 :x1*x2 + x3, x5:x0}) x0 + x1*x2 + x3#Answer returned by SAGE If you have a single substitution to make, e.g replace only x5 by x0, there is no need to pass a dictionary. sage:f.subs(x5 = x0) x0 + x4 I hope it is clear. Regards, AKHIL. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Error when type notebook()
Dear all, when I type notebook(), I get the following error. Will you kindly help me? sage: notebook() --- EOFError Traceback (most recent call last) /home/a/.sage/ipython console in module() /home/a/Downloads/sage-5.6-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/notebook_object.pyc in __call__(self, *args, **kwds) 221 222 def __call__(self, *args, **kwds): -- 223 return self.notebook(*args, **kwds) 224 225 notebook = run_notebook.notebook_run /home/a/Downloads/sage-5.6-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/run_notebook.pyc in notebook_run(self, directory, port, interface, port_tries, secure, reset, accounts, openid, server_pool, ulimit, timeout, upload, automatic_login, start_path, fork, quiet, server, profile, subnets, require_login, open_viewer, address) 526 # if none use defaults 527 -- 528 nb = notebook.load_notebook(directory) 529 530 directory = nb._dir /home/a/Downloads/sage-5.6-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/notebook.pyc in load_notebook(dir, interface, port, secure, user_manager) 1794 1795 dir = make_path_relative(dir) - 1796 nb = Notebook(dir) 1797 nb.interface = interface 1798 nb.port = port /home/a/Downloads/sage-5.6-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/notebook.pyc in __init__(self, dir, user_manager) 147 # Set the list of users 148 try: -- 149 S.load_users(self._user_manager) 150 except IOError: 151 pass /home/a/Downloads/sage-5.6-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/storage/filesystem_storage.pyc in load_users(self, user_manager) 265 {'admin': admin, 'wstein': wstein} 266 -- 267 for user in self._basic_to_users(self._load('users.pickle')).itervalues(): 268 user_manager.add_user_object(user, force=True) 269 user_manager.set_password(user.username(), user.password(), encrypt = False) /home/a/Downloads/sage-5.6-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/storage/filesystem_storage.pyc in _load(self, filename) 165 def _load(self, filename): 166 with open(self._abspath(filename)) as f: -- 167 result = cPickle.load(f) 168 return result 169 EOFError: sage: -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.