Ask Your Question

jaebond's profile - activity

2020-05-01 15:32:35 -0500 received badge  Popular Question (source)
2020-01-30 18:08:50 -0500 received badge  Famous Question (source)
2019-06-27 08:06:22 -0500 received badge  Notable Question (source)
2019-06-26 10:43:24 -0500 received badge  Popular Question (source)
2019-02-10 12:00:06 -0500 received badge  Nice Question (source)
2019-01-08 10:43:34 -0500 received badge  Popular Question (source)
2018-01-06 11:16:35 -0500 answered a question Using Singular's solve.lib

Looking in src/sage/interfaces/ as suggested by @tmonteil, I noticed in some of the docstrings that the way to get at a Singular object is singular('obj_name'). Continuing the first example from the question, rlist can be accessed with singular('rlist'). Although it is still a Singular list, it can be indexed into, iterated over, etc. So something like the following will work:

sage: [[coord for coord in sol] for sol in singular('rlist')]

Again, the elements are still Singular objects, but one (perhaps rudimentary) way to convert them is

sage: [[sage_eval(coord._sage_repr()) for coord in sol] for sol in singular('rlist')]

Perhaps more robust than sage_eval and ._sage_repr() would be using .repart() and .impart() (which are the Singular functions for real and imaginary part):

sage: [[ComplexNumber(coord.repart(), coord.impart()) for coord in sol] for sol in singular('rlist')]

Note that ComplexNumber has an optional min_prec argument to control the precision of the ComplexField used to create the number, so that if the computations are performed at a high precision in Singular, the same precision can be ensured in Sage.

2018-01-06 11:03:29 -0500 commented answer Using Singular's solve.lib

When I tried I.variety(), Sage printed verbose 0 (3324:, groebner_basis) Warning: falling back to very slow toy implementation., so it looks like Sage is still using Groebner bases, just with a slower implementation. Is this accurate?

2018-01-06 09:40:29 -0500 received badge  Notable Question (source)
2018-01-06 09:19:46 -0500 received badge  Good Question (source)
2018-01-06 07:32:22 -0500 received badge  Enthusiast
2018-01-05 21:35:56 -0500 asked a question Using Singular's solve.lib

I am trying to use Singular's solve.lib from Sage, but I am running into issues with getting the result out of Singular. I tried using the Singular interface and was able to make it this far:

sage: singular.lib('solve.lib')
sage: r = singular.ring('complex', '(x,y)', 'lp')
sage: I = singular.ideal('(x-5)*y/32', 'y^2-x^3-5*x-10')
sage: R = singular.fglm_solve(I)
sage: singular.setring(R)

at which point the result is stored in a list rlist inside of R. I can do singular.eval('rlist') and see the answer, but in order to get it back into Sage I would have to parse the resulting string. Is there a better way to get rlist?

Alternatively, I tried to use libSingular as follows:

sage: from sage.libs.singular.function import singular_function, lib
sage: lib('solve.lib')
sage: fglm_solve = singular_function('fglm_solve')
sage: P = PolynomialRing(QQ,'x,y',order='lex'); x,y = P.gens()
sage: I = Ideal((x-5)*y/32, y^2-x^3-5*x-10)
sage: R = fglm_solve(I)

// 'fglm_solve' created a ring, in which a list rlist of numbers (the
// complex solutions) is stored.
// To access the list of complex solutions, type (if the name R was assigned
// to the return value):
        setring R; rlist; 

But then R is a <RingWrap> instance and this time I don't even know how to go about seeing the answer. Also, I would prefer to work over the complex field, but I couldn't get fglm_solve to accept an ideal in CC['x,y']

Any help in either direction would be greatly appreciated.

2017-12-11 21:06:39 -0500 asked a question Error when trying to import without sage.all

I am trying to import only the Sage functions needed as is done in the Sage source code, but I am running into issues. For example, (running sage -python),

>>> from import Group

results in

from sage.rings.complex_double import CDF
File "sage/rings/real_double.pxd", line 8, in init sage.rings.complex_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/complex_double.c:22654)
File "sage/rings/real_double.pyx", line 64, in init sage.rings.real_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/real_double.c:25060)
ImportError: cannot import name ZZ

(I can post the full traceback if that would be helpful.) Similar things happen for almost any import I try. I was using the import_statements to determine what to import.

Am I missing something?


I think I get the picture a little better now. The Sage source files aren't meant to be imported in Python, they are meant to be imported into Sage, which presumably runs import sage.all when it starts.

2017-12-07 23:34:33 -0500 asked a question Substituting a complex embedding for a number field element

Is there a way to take an element of a number field (or a polynomial or a number field) and replace the generator of the field by one of its complex embeddings? For example, something like

sage: K.<a> = NumberField(x^2 - 3)
sage: (3*a + 5).substitute(a=a.complex_embeddings()[1])

It's feasible to do this with sage_eval, but hopefully there is a better way.

2017-12-02 00:21:59 -0500 asked a question Import just one function from .sage file

I have a .sage file that has a single function I want to import. If it were a .py file, I would obviously use from temp import myfun, but as far as I know, .sage files have to be imported with either load('temp.sage') or attach('temp.sage') (or preparsed, but this gets tiresome). Is there a way to import just one function from a .sage file?

2017-08-02 10:25:06 -0500 received badge  Nice Answer (source)
2017-07-13 17:45:01 -0500 received badge  Nice Question (source)
2017-07-02 09:44:02 -0500 asked a question Loading a module causes the __name__ == '__main__' block to execute

I have a module that can also be run from the command line:

def func()

if __name__ == '__main__':

When I try to load it in Sage, the main block is executed:

sage: load('module.sage')

The bigger problem is that the main block parses command line arguments and Sage aborts the load with an error because it didn't receive any command line arguments. Is there any way to handle this? I can preparse module.sage and import it as a Python module, but its so much easier to attach('module.sage') than having to reload(module) every time I change it when I'm editing.

2017-06-27 11:57:59 -0500 commented question Accessing GAP's in function through the C Interface

Edited to clarify that I wanted to call this from Sage.

2017-02-12 19:12:31 -0500 asked a question Is there a way to relabel the domain of a permutation group?

Suppose I have a permutation group on the domain {1,2,3,4,5}, but instead I wanted this permutation group to be on the domain {a,b,c,d,e}. Is there a way to achieve this? Hopefully something like the relabel method for graphs...

2017-02-06 13:22:46 -0500 asked a question How to increase GAP's recursion limit

Is there a way to increase the recursion limit of (lib)GAP processes? I am hitting a recursion limit when computing a double coset:

--> 531 coset_space = libgap.DoubleCosets(G, C_G_s0, C_G_s1)

ValueError: libGAP: Error, recursion depth trap (5000)

2017-02-05 10:24:58 -0500 asked a question Accessing GAP's in function through the C Interface

Is there a way to access GAP's in function through Sage's C Interface to GAP?

gap> Identity(G) in G;


I was wondering how to call this from Sage:

sage: G = libgap.SymmetricGroup(5)
sage: g = libgap.eval('(1,2,3)(4,5)')

How do I test if g is in G?

2016-11-28 23:16:15 -0500 answered a question using GAP: Group Theory

Here is the problem:

sage: parent(gens)
C library interface to GAP

Just coerce them to GAP:

sage: parent(gap(gens))
sage: PermutationGroup(gap(gens))
Permutation Group with generators [(3,4), (2,3)]
2016-11-11 15:24:18 -0500 asked a question Is there a way to draw a graph using a specific embedding?

It is possible to set the embedding of a graph (set_embedding), but plot() doesn't seem to respect it. Is there a way to plot the graph using the specified embedding?

Here is an example showing that faces() respects the embedding, although plotting each gives the same output:

sage: G = Graph({0:[1,2,3], 2:[3], 3:[4]})
sage: G.faces()
[[(0, 1), (1, 0), (0, 2), (2, 3), (3, 4), (4, 3), (3, 0)],
 [(2, 0), (0, 3), (3, 2)]]
sage: G.set_embedding({0:[2,1,3], 1:[0], 2:[0,3], 3:[0,2,4], 4:[3]})
sage: G.faces()
[[(0, 1), (1, 0), (0, 3), (3, 2), (2, 0)],
 [(3, 0), (0, 2), (2, 3), (3, 4), (4, 3)]]
2016-08-26 12:02:19 -0500 asked a question Installing an spkg hangs on "Setting up build directory for gcc-4.9.3.p1"

I have tried installing a few Sage packages (gap_packages and boost), but in both cases, the installation hangs on

Setting up build directory for gcc-4.9.3.p1

Are there any suggestions on how to fix this?

The log is just

Found local metadata for gcc-4.9.3.p1
Using cached file /var/host/media/removable/sd/SageMath/upstream/gcc-4.9.3.tar.bz2
Setting up build directory for gcc-4.9.3.p1
2016-07-28 02:36:16 -0500 received badge  Nice Question (source)
2016-07-26 20:46:35 -0500 received badge  Teacher (source)
2016-07-26 13:47:27 -0500 commented question how to run a sage file

You can set it up just like any Python file and then call sage file.sage from the command line (assuming sage is in your path).

2016-07-26 13:46:34 -0500 commented answer Can I create a sage file, and import it as a Python module?

For the syntax, you can run sage -preparse file.sage from the command line and it will do all of the syntax conversions for you. It will also add the line from sage.all import * at the top, though you have to then run this with Sage's version of Python (or tell Python where to find sage.all).

2016-07-25 22:22:10 -0500 commented question second degree irreducible polynomial over extension field

I don't follow what you are asking for. Could you please clarify?

2016-07-25 11:50:19 -0500 received badge  Popular Question (source)
2016-07-25 11:49:42 -0500 asked a question Faster function for working with cosets

I would like to get the cosets of a non-normal subgroup and in the documentation for the .cosets() method here:


there is a Note: that says

Sage and GAP provide more sophisticated functions for working quickly with cosets of larger groups.

but doesn't mention what these functions are. I was hoping that someone could point me to these functions.

If it makes a difference, I want to iterate over a set of coset representatives and it will all be done in a permutation group.