Ask Your Question

Revision history [back]

Here is the problem: if you look at the Traceback, you can see that the problem is in hemmeckeFiberAdjacency, when you compute the diagonal_matrix. You can also see that this function tries to find a common ring for the elements you give them.

So let us add some bugtracking in your code by replacing:

M += diagonal_matrix(vector([1]*2^(k+1))-rowsums);

by:

try:
    M += diagonal_matrix(vector([1]*2^(k+1))-rowsums);
except Exception:
    print "bug", p1, p1.parent()

so that when the error will appear, we will be able to see which p1 caused the problem.

Indeed, we get another error : AttributeError: 'numpy.float64' object has no attribute 'parent'. Here is the explanation : when you call sage.numerical.optimize.find_local_minimum, Sage uses scipy.optimize which uses numpy.float64 floating point numbers. Those numbers have no parent (a ring to live in) in Sage.

To fix your problem, you can just ensure that the p1 that is given to hemmeckeFiberAdjacency can be correctly handled by Sage. It suffice to transform it into an element of the Real Double Field (which are Sage floating point numbers with the same precision as numpy.float64 elements) by adding the following line at the beginning of your function hemmeckeFiberAdjacency.

p1 = RDF(p1)

Now you will get:

sage: sage.numerical.optimize.find_local_minimum(slem4, 0,1/16)
(0.993614695234, 0.042890047690081409)

Which corresponds to what you saw on the picture.