Ask Your Question

jipilab's profile - activity

2021-02-09 11:59:26 +0200 received badge  Popular Question (source)
2021-02-09 11:53:56 +0200 answered a question cell complexes vs simplicial complexes

I would recommend you to have a look at the documentation:

For general cell complexes For simplicial complexes

Note that they have different methods available and that they might not offer the state-of-the-art methods for what you mean, but it is worth trying!

2021-01-19 17:28:03 +0200 received badge  Necromancer (source)
2020-12-16 13:44:16 +0200 answered a question Finding certain partitions using Sage

If I adapt the problem to the comment, it is possible to use integer points in polyhedra. First, one creates the polyhedron of partitions in chamber. Then, one fixes the sum of the parts to be N in the coord_sum. Taking the intersection and then the integral points, we get at least the potential partitions. Then, one can iterate to test the inverse sum and the minimal part.

For d=1 I get:

sage: d = 1 
....: bound = 25
....: adm_part = set() 
....: for k in range(2,2*(d+1)+1): 
....:     chamber = Polyhedron(rays=[[0]*_+[1]*(k-_) for _ in range(k)],backend='normaliz') 
....:     for N in range(2*k,bound): 
....:         coord_sum = Polyhedron(eqns=[[-N]+[1]*k],backend='normaliz') 
....:         start_partitions = (chamber & coord_sum).integral_points() 
....:         for p in start_partitions: 
....:             non_zero = tuple([_ for _ in p if _ > 0]) 
....:             if min(non_zero) >= 2 and sum([1/_ for _ in non_zero]) == len(non_zero) - d - 1: 
....:                 if non_zero not in adm_part: 
....:                     adm_part.add(non_zero) 
....:                     print(non_zero) 
....:                                                                                                                                                                                                              
(3, 3, 3)
(2, 4, 4)
(2, 3, 6)
(2, 2, 2, 2)

If my code is not correct, one may still modify it to get the proper definition of admissibility...

2020-12-16 13:31:22 +0200 commented question Finding certain partitions using Sage

The partition [2,2,2,2] does not seem to be 1-admissible. The sum of the inverse gives 2 which is not 8 - 1 - 1 = 6. Is it 1-admissible when k-d-1 is the sum of the inverse of their parts?

2020-08-24 02:47:44 +0200 received badge  Nice Answer (source)
2020-08-23 21:57:21 +0200 answered a question Obtaining quotient posets of the Boolean lattice via Sage

Here is a snippet of code that can be used to produce the desired quotient poset. It is not meant to be the most optimal way, but it does return the desired object.

sage: G = PermutationGroup([[(1,2)],[(3,4)]])
sage: S = Set([1,2,3,4])
sage: GroundSet = S.subsets()
sage: Orbits = Set([Set(G.orbit(s, action = "OnSets")) for s in GroundSet])
sage: def quotient_order(a,b):
....:     for s1 in a:
....:         ss1 = set(s1)
....:         for s2 in b:
....:             ss2 = set(s2)
....:             if ss1.issubset(ss2):
....:                 return True
....:     return False
....: 
sage: QuotientPoset = Poset((Orbits,quotient_order))
sage: QuotientPoset.show()

To obtain all of the quotient posets, one should then loop over all permutation subgroups of $S_n$. These subgroups can be obtained this way:

sage: SG = SymmetricGroup(4)
sage: SG.subgroups()
2020-07-28 12:14:55 +0200 answered a question rotating polytope in 4d?

The current default viewer in Sage is now threejs.

To visualize a 4-dimensional polytope, you can do:

sage: hc = polytopes.hypercube(4)
sage: hc.plot()
Launched html viewer for Graphics3d Object

This will open a html page in the default internet browser (this might be a problem, as sometimes if the browser was updated it might not open a new tab). In there, there will be a threejs applet which you can play with with mouse-clicks.

You are probably refering to the pop up menu from the jmol viewer, which is still accessible (though likely is less maintained now as it is not the default viewer anymore):

sage: hc.plot(viewer='jmol')
Launched jmol viewer for Graphics3d Object

There, you may right-click and select "console" where you can then type commands to rotate and change the view.

As far as I know, there was no possibility to change the projection view (from 4d to 3d) once the picture of the Schlegel diagram has been produced.

It is possible to change the projection view, for this, you may proceed to play around as follows:

sage: new_pic = hc.schlegel_projection([1,1,1,2],1.5)
sage: new_pic.plot()
Launched html viewer for Graphics3d Object
2020-07-24 09:41:57 +0200 commented answer Shelling order of a simplicial polytope

Sure! If you want to keep track of the development related to polyhedral geometry in Sage visit the Polyhedral Geometry Trac Wiki. The .boundary_complex method is in Sage since version 9.0.

2020-07-24 09:30:16 +0200 answered a question Shelling order of a simplicial polytope

Dear Guillermo,

The answer to your question is yes. Here is an illustration with the octahedron:

sage: P = polytopes.octahedron()
sage: Facets = {f.ambient_V_indices():f for f in P.faces(P.dimension() - 1)}  # Create the vertices-indices-to-facets dictionary
sage: P.is_simplicial()  # Check that P is simplicial, so we can get the boundary complex
True
sage: C = P.boundary_complex()  # Create the boundary complex
sage: Order = C.is_shellable(True); Order  # Get a shelling order
((0, 1, 2),
 (1, 2, 5),
 (1, 3, 5),
 (0, 2, 4),
 (0, 1, 3),
 (0, 3, 4),
 (2, 4, 5),
 (3, 4, 5))

Finally, we can get the actual sequence of facet using our dictionary.

sage: Facet_shelling = [Facets[indices.tuple()] for indices in Order]; Facet_shelling
[A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
 A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices]
2020-07-16 06:11:05 +0200 received badge  Nice Answer (source)
2020-04-26 21:48:43 +0200 marked best answer How to literally print the output of tab completion in the command line?

Some time ago, I realized that pressing tab after a "." in the command line opens a new window where it is possible to scroll through the possible methods to call on this object.

Is it still possible to print inside the terminal all the possibilities?

Even if I modify the preferences of the command line from "readline" to "multicolumns", it still does not show much of the possibilities and sometimes seeing all of them at once is faster than scrolling.

Is it possible to get this feature back as before somehow?

2020-04-26 21:48:43 +0200 received badge  Scholar (source)
2020-04-24 09:39:58 +0200 commented answer Projection along affine hull

Perhaps you could complete this answer with the code to obtain P?

2020-04-23 09:57:24 +0200 commented question Memory leak in Polyhedron?

This memory leak in Polyhedron is fixed in this ticket.

2020-04-23 09:48:39 +0200 commented answer Compute the centroid of a polytope

... which will be accessible with the command

sage: q = polytopes.permutahedron(4)
sage: q.centroid()
2020-04-23 09:43:49 +0200 commented answer plotting 5,8,16,24,120 and 600-cells

The 120-cell is now available in the library. The 'normaliz' backend is currently the fastest way to get it.

sage: otc = polytopes.one_hundred_twenty_cell() # slow...
sage: otc = polytopes.one_hundred_twenty_cell(backend='normaliz')
sage: otc.plot()
2020-04-09 09:02:16 +0200 received badge  Good Answer (source)
2020-04-08 19:20:21 +0200 received badge  Nice Answer (source)
2020-04-08 17:08:58 +0200 answered a question PolyhedronFace

In sage 9.0, I can execute:

sage: square = polytopes.hypercube(2)
sage: fl = square.face_lattice();
sage: list(f.ambient_V_indices() for f in fl)
[(), (0,), (1,), (2,), (3,), (0, 1), (0, 2), (2, 3), (1, 3), (0, 1, 2, 3)]

Which version of sage are you using? That might be a problem as the function ambient_V_indices is available since version 8.8.

2020-03-01 11:43:48 +0200 commented answer Find sphere points in a lattice

I see. If it is in Sage I would suspect that it is closer to the number theory and quadratic forms code, but I am not aware of it...

2020-02-13 10:30:16 +0200 answered a question looping of equality function

Defining x,y,z to be variables and then using them as integers is not really appropriate. The indentation was also missing, along with an if.

You do not need to declare the variables if you use them in a range:

sage: for x in range(-100,101):
....:     for y in range(-100,101):
....:         for z in range(-100,101):
....:             if x^4+y^4 == z^3:
....:                 print(x,y,z)

You can also use more advanced iterators and shorten the code:

sage: import itertools
sage: for x,y,z in itertools.product(srange(-100,101),repeat=3):
....:     if x^4 + y^4 == z^3:
....:         print(x,y,z)
2020-02-11 08:35:23 +0200 received badge  Good Answer (source)
2020-02-10 22:30:56 +0200 received badge  Nice Answer (source)
2020-02-10 19:00:08 +0200 answered a question Find sphere points in a lattice

Here is a snippet of code that should do:

sage: Q = RootSystem('E8').weight_lattice()
sage: B = Q.basis()
sage: the_set = set()
sage: finished = False
sage: i = 1
sage: value = 4
sage: while not finished:
....:     smaller_or_eq_values = False
....:     int_vectors = IntegerVectors(n=i,k=8)
....:     for vect in int_vectors:
....:         weight = sum(vect[j]*B[j+1] for j in range(8)) # Create the weight
....:         wns = weight.norm_squared()
....:         if wns <= value:
....:             smaller_or_eq_values = True
....:             if wns == value:
....:                 print(weight)
....:                 the_set.add(weight)
....:     if not smaller_or_eq_values:
....:         finished = True
....:     i += 1

You will get a set the_set which above contains all the (positive) weights that have the norm squared to be equal to value=4.

The norm squared seem to deliver the same as the symmetric form:

sage: B[1]+B[2]
Lambda[1] + Lambda[2]
sage: a_weight = B[1]+B[2]
sage: a_weight.symmetric_form(a_weight)
22
sage: a_weight.norm_squared()
22
2020-02-10 13:47:43 +0200 answered a question VoronoiDiagram returns empty regions

This looks like a bug. I have reported it on trac: ticket 29176

Thanks for reporting this!

2020-02-10 13:41:12 +0200 answered a question Typo in Sage documentation (no. 2)

This is now a ticket: ticket 29175

2020-02-07 19:08:19 +0200 commented answer Intersection of a Cube with two planes and resulting polyhedron

In a more recent version you can do:

sage: cube = polytopes.cube()
sage: plane1 = Polyhedron(eqns=[(0,1,0,0)])
sage: plane2 = Polyhedron(eqns=[(1,0,0,-1)])
sage: intersec = cube & plane1 & plane2
2020-02-07 18:59:29 +0200 commented question hyperplane arrangements raises error on regions

I would also try to use rational numbers instead of floats, this might facilitate the computations. You probably do not need floats, as the size of the input is reasonable.

say 83/100 instead of 0.83 ...

2020-02-07 18:52:55 +0200 commented question Find sphere points in a lattice

Could you explain what is meant by "canonical bilinear form", the one coming from the geometric representation?

This will affect how to give you a better answer.

2020-02-07 18:44:42 +0200 commented question Sage notebook only runs when a browser is already open

With the notebook, it is also useful to restart the browser once in a while if an update was made (I rarely restart my browser and I was getting similar problems with start-up, restarting the browser did the thing...)

Maybe try with have a freshly updated firefox, that does not run, and moving the .sage folder to another location and then so what happens?

2020-01-09 22:33:56 +0200 received badge  Nice Answer (source)
2020-01-08 17:41:03 +0200 answered a question Lattices via sage

Here is a first attempt to answer your questions.

1) The comment should be addressed in order to give an instructive answer.

2) Assuming you want to consider only _linear_ subspace, the following code does the thing:

sage: dim = 2
sage: FF = FiniteField(3)
sage: VS = VectorSpace(FF,2)
sage: SS = {}
sage: SS[0] = set([VS.subspace([])])
sage: for dim in range(1,dim+1):
....:     new_subspaces = set()
....:     for v in VS:
....:         for ss in SS[dim-1]:
....:             new_ss = ss + VS.subspace([v])
....:             if new_ss.dimension() == dim:
....:                 new_subspaces.add(new_ss)
....:     SS[dim] = new_subspaces
....:     
sage: ground_set = reduce(lambda x,y:x.union(y),SS.values())
sage: the_lattice = LatticePoset((ground_set,lambda x,y: x.is_subspace(y)))

3) See https://ask.sagemath.org/question/389... and https://ask.sagemath.org/question/389...

2020-01-08 13:53:33 +0200 commented question Lattices via sage

Could you clarify which lattice you mean? A lattice can be a subgroup of the additive group R^n which is isomorphic to Z^n or a poset with a join and meet operations.

2019-10-26 11:49:16 +0200 commented question LattE problem: Executable 'count' not found on PATH.

I also get 39 for the command q1.integral_points_count() on sage 8.9.

As mentioned in the documentation obtained by typing q1.integral_points_count?, there is a threshold for when sage will use latte for the computations. The import statement from sage.interfaces.latte import * does not affect anything here. As tmonteil said, it requires that either you have latte integrale installed on your system of you install it via sage -i latte_int.

I suspect that you are interested in the Ehrhart polynomial. It is important to know that counting the lattice points in a lattice polytope and obtaining the Ehrhart polynomial are two completely different tasks, although they are obviously related.

2019-10-26 00:19:36 +0200 commented answer How to find the vertices a a polyhedron define by inequalities ,

It is also possible to get the full V-representation using the Vrepresentation method.

2019-10-26 00:17:43 +0200 answered a question Computing projection of a polyhedron

One possibility is the following.

First create the desired transformation as a matrix.

sage: nf = QuadraticField(2)
sage: sqrt2 = nf.gen()
sage: proj_mat = matrix(nf,[[sqrt2/2,sqrt2/2],[sqrt2/2,sqrt2/2]])

Then, create your polyhedron

sage: P = Polyhedron(vertices=[(-1,-1), (1,3), (5,-2)])

One then just need to apply the transformation on each vertices of the polyhedron and take the result back to a polyhedron.

sage: Pproj = Polyhedron(vertices = (proj_mat*P.vertices_matrix()).columns())
sage: Pproj
A 1-dimensional polyhedron in (Number Field in a with defining polynomial x^2 - 2)^2 defined as the convex hull of 2 vertices
sage: Pproj.vertices_list()
[[-a, -a], [2*a, 2*a]]

Currently, projections (or other linear transformations) are not implemented better than as above...

2019-10-25 20:12:07 +0200 answered a question About algorithm for testing whether a point is in a V-polyhedron

You can access the algorithm for containment by doing the following:

sage: p = polytopes.cube()
sage: p.contains??

This will show you the source code for this function. The containment check is independent of the backend. Currently, when you create a polyhedron object in Sage, it computes the other representation (H- to V-, or V- to H-) automatically (this may change in the future, but for now, it is so). Then, checking containment is obtained directly from the H-representation by matrix multiplication and checking the equality or inequality of Ax<=B. This is then done in the arithmetic of the appropriate ring (ZZ, QQ, RDF, NumberField, etc).

There is absolutely no difference between bounded vs unbounded polyhedron.

To know if the function depends on the backend, you can look next to the 1-to-last line in the output of p.contains?? it will mention the file in which this function is. If this file contains ppl, normaliz, polymake, cdd, field, then this function is implemented specifically for that backend. Otherwise, if it is in say base.py, it is a generic function that is used in general...

2019-09-14 07:56:10 +0200 commented answer jmol stuck at "Initializing 3D display"

Thanks! That explains why it was stuck indeed. I did create a dummy worksheet to execute my snippet of code and jsmol does work inside jupyter notebooks.

2019-09-12 10:49:13 +0200 asked a question jmol stuck at "Initializing 3D display"

I have a freshly compiled version of sage 8.9.rc0. jmol used to work fine until I got it stuck at "Initializing 3D display"

sage: h = polytopes.regular_polygon(6)
sage: w = h.wedge(h.facets()[0])
sage: w.plot()
Launched jmol viewer for Graphics3d Object

The pop out window opens and then is stuck for eternity. This is annoying. I know that I could use a different viewer like threejs but it does not open a window in my browser (which is another unrelated issue). So I would really like jmol to just work as I expect it to...

(I also upgraded my debian from stretch to buster, but I do not think it is the problem since jmol starts fine outside of sage)

How to fix this?

2019-08-29 10:29:23 +0200 received badge  Good Answer (source)
2019-08-29 10:28:22 +0200 received badge  Nice Answer (source)