Ask Your Question

Jernej's profile - activity

2021-11-14 11:03:33 +0200 received badge  Notable Question (source)
2021-11-14 11:03:33 +0200 received badge  Popular Question (source)
2021-03-12 02:10:04 +0200 received badge  Popular Question (source)
2018-10-12 11:38:45 +0200 received badge  Famous Question (source)
2018-10-12 11:38:45 +0200 received badge  Notable Question (source)
2017-12-15 06:29:47 +0200 received badge  Popular Question (source)
2017-05-04 13:18:19 +0200 received badge  Nice Question (source)
2016-03-21 11:13:27 +0200 commented answer Performing substitutions on powers of a variable

Thanks. Just out of curiosity - is there a reason in the different behavior of substitute on symbolic expressions and polynomials?

2016-03-20 21:03:35 +0200 asked a question Performing substitutions on powers of a variable

I have some polynomials of degree $d$ and I would like to obtain the monomial where all exponents greater than $1$ are reduced to $1$. For example $x_1^2 x_3^4 x_2 + x_1^7x_3^3 x_2^8 + \cdots$ would become $2x_1 x_3 x_2 + \cdots $

Naively, I thought an approach along the following lines would work:

sage: x = PolynomialRing(QQ, 1, 'x').objgens()[1][0]
sage: s = 2*x^2
sage: s.substitute({x^2:x})
2*x^2

Unfortunately, this does not give the proper result. Hence I am wondering

What is the proper way to perform the described substitution on the powers of a given monomial?

Edit. It seems that I can do ss = symbolic_expression(s).substitute({x^2:x}) and then convert ss to a polynomial. However, this seems to be extremely inefficient.

2016-03-20 19:28:11 +0200 commented answer Correct way to compute the modulus of a polynomial

@Bruno Is there a way to use this when the variables in question are given in a list V of the form V = [var('x'+str(i)) for i in xrange(n)] ?

2016-03-20 14:47:17 +0200 asked a question Correct way to compute the modulus of a polynomial

I am dealing with a large list of monomials of degree 1. One such (small) example would be

x0x2x3x4 + x1x2x3x4 - x0x2x3 - x1x2x3 - x0x3x4 - x1x3x4 + x2x3x4 + x0x3 + x1x3 - x2x3 - x3x4 + x3

I need to create a dict that, encodes each of the above summands (recording the respective variable indices) and the respective value of the coefficient. So for the above expression I'd like to make the dictionary:

{'0,2,3': -1, '0,2,3,4': 1, '0,3': 1, '0,3,4': -1, '1,2,3': -1, '1,2,3,4': 1, '1,3': 1, '1,3,4': -1, '2,3': -1, '2,3,4': 1, '3': 1, '3,4': -1}

I would like this to be as efficient as possible. As far as I understand it is not possible to use coefficients() to return this and the only way I see how to accomplish this is by converting the expression to a string and parse it. Given that this is quite inefficient and ugly I was wondering

What would be an efficient way to extract the described dictionary from a given monomial expression?

2015-03-25 22:03:38 +0200 received badge  Famous Question (source)
2014-12-14 16:33:08 +0200 received badge  Notable Question (source)
2014-10-27 19:05:26 +0200 received badge  Nice Question (source)
2014-10-08 15:33:16 +0200 asked a question Polynomial decomposition

We say that a polynomial $f$ is decomposable if there are (not linear) polynomials $g,h$ such that $f = g \circ h.$

Is there a function in Sage doing this?

As far as I can see the function is present in Mathematica under the name Decompose http://reference.wolfram.com/language....

2014-09-09 22:45:53 +0200 received badge  Famous Question (source)
2014-07-23 01:46:10 +0200 received badge  Popular Question (source)
2014-06-29 03:15:18 +0200 marked best answer Iterating over all non isomorphic connected graphs of given order

Hello!

I would like to iterate over all connected non isomorphic graphs and test some properties. For all the graphs on less than 11 vertices I've used the data available in graph6 format here.

Now I would like to test the results on at least all connected graphs on 11 vertices.

Looking at the documentation I've found that there is a graph database in sage. However, trying just the first example resulted in some errors :

RuntimeError
Traceback (most recent call last)

/home/a/<ipython console=""> in <module>()

/usr/lib/sage/local/lib/python2.7/site-packages/sage/databases/sql_db.pyc in show(self, **kwds) 664 cur.execute(self.__query_string__, self.__param_tuple__) 665 except: --> 666 raise RuntimeError('Failure to fetch query.') 667 668 print _create_print_table(cur, [des[0] for des in cur.description], \

RuntimeError: Failure to fetch query.

What I would like to ask is the following:

  1. Is there a way to iterate over all connected (nonisomorphic) graphs of order 11?

  2. Is there a databse for these graphs already present in sage?

  3. Has anyone considered integrating (and extending) the data from McKay's site into sage?

2014-01-03 10:24:52 +0200 received badge  Editor (source)
2014-01-03 08:51:53 +0200 asked a question Testing if a group has a subgroup acting regularly

I am given a PermuationGroup $G$ and would like to find out if $G$ has a subgroup $H$ that acts regularly. The insane way to do it is of course to iterate over all subgroups of $G$ of size of the acting set and testing for regularity.

My question is - is there a more efficient way to do this?

Best,

Jernej

2013-12-29 17:10:17 +0200 received badge  Popular Question (source)
2013-10-30 12:38:46 +0200 marked best answer Drawing a graph - fixing its layout

With g.plot(save_pos = True) the layout used by Sage in the plot is saved in g. You can obtain it by doing g.get_pos() and give them to another graph with h.set_pos(g.get_pos()).

sage: g = graphs.KneserGraph(5,2)                   
sage: g.show(save_pos=True)                         
sage: g2 = g.complement()
sage: g2.set_pos(g.get_pos())
sage: g2.show()
2013-10-30 12:29:11 +0200 asked a question Drawing a graph - fixing its layout

Hello!

I would like to draw a simple graph $G$ and its complement $\overline{G}.$ I was asked to make the drawing such that it is evident that the drawings are complementary. More precisely I was advised to draw $G$ and $\overline{G}$ such that the coordinates of the vertices of $G$ are the same as the one for $\overline{G}.$

What would be an easy way to accomplish this in Sage?

Thank you

2013-08-27 13:06:21 +0200 received badge  Notable Question (source)
2013-07-01 11:20:32 +0200 received badge  Student (source)
2013-03-26 10:18:59 +0200 received badge  Popular Question (source)
2012-12-29 11:16:56 +0200 commented question Stackexchange

Right, but what about closing this one and having just the non-open source?

2012-12-29 09:50:33 +0200 asked a question Stackexchange

Has anyone considered creating a stackexchange site for Sage?

It appears to me that stackexchange is the most popular site for such things and would definitely not hurt to Sage popularity. In addition stackexchange community is larger and the software in question is much more flexible and readable.

I'd definitely be more motivated to use stackexchange than ASKBOT.

2012-12-29 09:44:09 +0200 asked a question A faster way to obtain orbits of a partition of the verrtex set

I am given a graph $G$ a set $S \subseteq V(G)$ and a vertex $v.$ I want to compute the representatives for the orbits of the stabilizer of $v$ of $\rm{Aut}(G)$ whose equivalence classes contain elements of $S.$ Currently what I am doing is the following:

def compute_valid_orbit_reps(G,S,v):
    ret = []
    O = G.automorphism_group(return_group=False, orbits=True, 
    partition=[ [v], [el for el in G.vertices() if el != v]])

    for el in O:
        if S.intersection(set(el)):
            nb = el[0]
            G.add_edge(nb,v)
            if G.girth() >= 5:
                ret += [nb]
            G.delete_edge(nb,v)
    return ret

I am wondering if there is a more efficient way to do the same, perhaps using GAP directly?

Best,

Jernej

2012-06-26 13:53:48 +0200 commented answer Iterating over all non isomorphic connected graphs of given order

I am running Sage Version 5.0, Release Date: 2012-05-14.

2012-06-26 12:27:06 +0200 received badge  Scholar (source)
2012-06-26 12:27:06 +0200 marked best answer Iterating over all non isomorphic connected graphs of given order

Hellooooooo !!

I can't answer for the graph database problem (no Sage installed on my computer), but there is a way for you to use Nauty through Sage !

If you have not installed the spkg already, you can do it by typing sage -i nauty in a console, or something like install_package("nauty") from the inside of Sage.

Afterwards you will bd able to use the nauty_geng method, with a "-c" flag that probably interests you.

http://www.sagemath.org/doc/reference...

Note that 11 is probably the limit of graphs that you can enumerate from within Sage, where most of the time is spent converting Nauty's graphs to Sage objects :-)

Nathann

2012-06-26 12:27:06 +0200 commented answer Iterating over all non isomorphic connected graphs of given order

That was very helpful, thank you!