Ask Your Question

rburing's profile - activity

2018-12-09 16:51:13 -0600 asked a question Free nilpotent Lie algebra of step 3 with 11 generators

This works:

S = LieAlgebra(QQ, 10, step=3, names='X', naming='linear')

and this works:

S = LieAlgebra(QQ, 11, step=2, names='X', naming='linear')

but this doesn't work:

S = LieAlgebra(QQ, 11, step=3, names='X', naming='linear')

though it should?

Traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-79-8672234ea66b> in <module>()
----> 1 S = LieAlgebra(QQ, Integer(11), step=Integer(3), names='X', naming='linear')

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyx in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (build/cythonized/sage/misc/classcall_metaclass.c:1640)()
    327         """
    328         if cls.classcall is not None:
--> 329             return cls.classcall(cls, *args, **kwds)
    330         else:
    331             # Fast version of type.__call__(cls, *args, **kwds)

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/algebras/lie_algebras/lie_algebra.pyc in __classcall_private__(cls, R, arg0, arg1, names, index_set, abelian, nilpotent, category, **kwds)
    439                 from sage.algebras.lie_algebras.nilpotent_lie_algebra import FreeNilpotentLieAlgebra
    440                 del kwds["step"]
--> 441                 return FreeNilpotentLieAlgebra(R, arg1, step, names=names, **kwds)
    442             elif nilpotent:
    443                 raise ValueError("free nilpotent Lie algebras must have a"

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyx in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (build/cythonized/sage/misc/classcall_metaclass.c:1640)()
    327         """
    328         if cls.classcall is not None:
--> 329             return cls.classcall(cls, *args, **kwds)
    330         else:
    331             # Fast version of type.__call__(cls, *args, **kwds)

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/algebras/lie_algebras/nilpotent_lie_algebra.pyc in __classcall_private__(cls, R, r, s, names, naming, category, **kwds)
    325         return super(FreeNilpotentLieAlgebra, cls).__classcall__(
    326             cls, R,r, s, names=tuple(names), naming=naming,
--> 327             category=category, **kwds)
    328 
    329     def __init__(self, R, r, s, names, naming, category, **kwds):

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:6301)()
   1003                 return self.cache[k]
   1004         except KeyError:
-> 1005             w = self.f(*args, **kwds)
   1006             self.cache[k] = w
   1007             return w

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/structure/unique_representation.py in __classcall__(cls, *args, **options)
   1025             True
   1026         """
-> 1027         instance = typecall(cls, *args, **options)
   1028         assert isinstance( instance, cls )
   1029         if instance.__class__.__reduce__ == CachedRepresentation.__reduce__:

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyx in sage.misc.classcall_metaclass.typecall (build/cythonized/sage/misc/classcall_metaclass.c:2090)()
    494             TypeError: Argument 'cls' has incorrect type (expected type, got classobj)
    495     """
--> 496     return (<PyTypeObject*>type).tp_call(cls, args, kwds)
    497 
    498 # Class for timing::

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/algebras/lie_algebras/nilpotent_lie_algebra.pyc in __init__(self, R, r, s, names, naming, category, **kwds)
    398                     for X_ind, X in basis_by_deg[dx]:
    399                         for Y_ind, Y in basis_by_deg[dy]:
--> 400                             Z = L[X, Y]
    401                             if not Z.is_zero():
    402                                 s_coeff[(X_ind, Y_ind)] = {W_ind: Z[W.leading_support()]

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/algebras/lie_algebras/lie_algebra.pyc in __getitem__(self, x)
    573                 return x[1].ideal(x[0])
    574             # Otherwise it is the bracket of two elements
--> 575             return self(x[0])._bracket_(self(x[1]))
    576         return super(LieAlgebra, self).__getitem__(x)
    577 

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/algebras/lie_algebras/lie_algebra_element.pyx in sage.algebras.lie_algebras.lie_algebra_element.FreeLieAlgebraElement._bracket_ (build/cythonized/sage/algebras/lie_algebras/lie_algebra_element.c:19132)()
   1452                     a, b = mr, ml
   1453                     cr = -cr
-> 1454                 for b_elt, coeff in self.parent()._rewrite_bracket(a, b).iteritems():
   1455                     d[b_elt] = d.get(b_elt, zero) + cl * cr * coeff
   1456                     if d[b_elt] == zero:

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10824)()
   1951                 return cache[k]
   1952         except KeyError:
-> 1953             w = self._instance_call(*args, **kwds)
   1954             cache[k] = w
   1955             return w

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:10280)()
   1827             True
   1828         """
-> 1829         return self.f(self._instance, *args, **kwds)
   1830 
   1831     cdef fix_args_kwds(self, tuple args, dict kwds):

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/algebras/lie_algebras/free_lie_algebra.pyc in _rewrite_bracket(self, l, r)
    690             # For a similar reason, we have b >= c.
    691             # Compute the left summand
--> 692             for m, inner_coeff in iteritems(self._rewrite_bracket(l._right, r)):
    693                 if l._left == m:
    694                     continue

AttributeError: 'sage.algebras.lie_algebras.lie_algebra_element.Lie' object has no attribute '_right'
2018-12-06 11:17:59 -0600 received badge  Nice Answer (source)
2018-12-05 12:42:54 -0600 answered a question Understanding Output in SageMath Regarding Dirichlet Characters

Armed with some knowledge of the general structure of Sage, you can find it out:

sage: c1(3)
zeta6 - 1
sage: K = c1(3).parent(); K
Cyclotomic Field of order 6 and degree 2
sage: K.gens()
(zeta6,)
sage: zeta6 = K.gens()[0]
sage: zeta6.minpoly()
x^2 - x + 1
sage: cyclotomic_polynomial(6)
x^2 - x + 1
sage: c1(3).minpoly()
x^2 + x + 1
sage: UK = K.unit_group()
Unit group with structure C6 of Cyclotomic Field of order 6 and degree 2
sage: UK.gens_values()
[zeta6]
sage: c1(3) in UK
True
sage: UK.log(c1(3))
(2,)
sage: zeta6^2
zeta6 - 1
2018-12-04 10:34:20 -0600 answered a question numerical_approx()

Sage's and SymPy's expressions and numbers have different types, but you can convert between them as explained in A Sample Session using SymPy.

In your case:

sage: C[0]._sage_().numerical_approx()
134.810810810811
sage: numerical_approx(C[0]._sage_())
134.810810810811
2018-12-04 03:58:55 -0600 commented question Sagemanifold - Connection components from a tensor (not a metric)

This is not my field so I'm not sure: what generalization do you need exactly? What do you want to do (in code) that you can't? A code sample (e.g. of how you wish it would work) would help.

2018-12-04 03:05:53 -0600 received badge  Good Answer (source)
2018-12-04 03:05:19 -0600 received badge  Good Answer (source)
2018-12-03 15:14:56 -0600 received badge  Nice Answer (source)
2018-12-03 15:13:30 -0600 received badge  Nice Answer (source)
2018-12-03 12:33:43 -0600 commented question Trying to get the right inverse, not possible

I don't know. Maybe try asking the author.

2018-12-03 12:05:20 -0600 answered a question Sagemanifold - `only_nonredundant = True` by default

That would be nice to have as an option indeed. As a workaround, you could define something like

nrcomps = lambda t, **kwargs: t.display_comp(only_nonredundant=True, **kwargs)

so you can do nrcomps(Ric) but also pass extra arguments like nrcomps(Ric, only_nonzero=True).

2018-12-03 11:49:32 -0600 answered a question Subtitute functions - in a differential equation - Sagemanifold

It works the same way as last time, by using .expr():

Ric[0,0].expr().substitute({xi:0, diff(xi, t):0})
2018-12-02 17:39:12 -0600 commented answer Error in finding the closest vector in a sublattice of Z^n

The algorithm was originally implemented by Jan Pöschko in 2012 based on the paper Computing the Voronoi Cell of a Lattice: The Diamond-Cutting Algorithm by Emanuele Viterbo and Ezio Biglieri (1996). I don't have the time for it now, but the way to fix the code can probably be found by reading and understanding these resources.

2018-12-02 16:46:29 -0600 commented answer Error in finding the closest vector in a sublattice of Z^n

This time the problem is in the function diamond_cut in the same file, namely in the line Z = sqrt(T[i] / q[i][i]): the argument of sqrt becomes negative and very tiny (for your example input) at some point in the algorithm. This function is being called from calculate_voronoi_cell as V = diamond_cut(Q, basis, radius, verbose=verbose). To get some more debug information, you can change verbose=verbose in this line to verbose=True. I'm not sure what the algorithm is doing, so I don't know how to fix it.

2018-12-02 13:52:42 -0600 commented answer Error in finding the closest vector in a sublattice of Z^n

In your local installation you can find the code I mentioned in src/sage/modules/diamond_cutting.py; search for calculate_voronoi_celland in there you can make the change I proposed. Here is the offending line: https://github.com/sagemath/sage/blob... Run sage -br to rebuild, for the change to take effect.

2018-12-02 12:39:33 -0600 answered a question Error in finding the closest vector in a sublattice of Z^n

You're not doing anything wrong; it is Sage that is wrong.

Here L.closest_vector(u) causes L.voronoi_cell() to be called, which calls (if L._basis_is_LLL_reduced is False, first L.LLL()) the function calculate_voronoi_cell(basis=L.reduced_basis, radius=None) which is located in sage.modules.diamond_cutting. Here we find the problem:

max(abs(v) for v in basis).ceil()

This code assumes that the result of max(abs(v) for v in basis) has a method called ceil(). This would be true for ordinary numbers as in your first example, but not for symbolic expressions such as sqrt(2) which appears in your second example.

The solution is to fix this part of Sage's code, e.g. replace the expression by:

max(abs(v).n() for v in basis).ceil()

To get this fix into Sage (for everyone to enjoy) a trac ticket should be opened for this problem and solution.

2018-11-29 12:07:33 -0600 commented question Trying to get the right inverse, not possible

If "the paper" is not secret then please share it; it would make it easier to help you.

2018-11-28 12:35:50 -0600 commented question Sagemanifold: autoparallel curve equations

Please show what you have done, by sharing the code. Hypothetical code is hard to debug.

2018-11-25 15:33:47 -0600 commented answer Extended Euclidean Algorithm for Univariate Polynomials with Coefficients in a Finite Field

Ah yes, I missed that. Nice find.

2018-11-24 10:39:16 -0600 commented answer Finding the Groebner Basis of the following Ring. Is it possible? How could I make it work with multivariate polynomials?

You're welcome :) I added a remark about how it is related to Groebner bases.

2018-11-24 09:39:54 -0600 commented answer Finding the Groebner Basis of the following Ring. Is it possible? How could I make it work with multivariate polynomials?

Every element of the finite field $\mathbb{F}_{2^e}$ can be written (for a fixed modulus) as a polynomial of degree less than $e$ in a unique way; I added code to achieve this.

2018-11-24 09:20:50 -0600 answered a question Finding the Groebner Basis of the following Ring. Is it possible? How could I make it work with multivariate polynomials?

I'm not sure what you're trying to do here. Groebner bases make sense for ideals in polynomial rings over a field. Your R is not a polynomial ring, but is itself a field, so I is either the zero ideal $(0)$ (if all random elements happen to be zero) or the unit ideal $(1) = R$. Maybe you intended to define

R.<x> = PolynomialRing(PolynomialRing(GF(2),name="a").quotient(p))

Or with more variables (when Groebner bases are more interesting):

R.<x,y,z> = PolynomialRing(PolynomialRing(GF(2),name="a").quotient(p), 3)

Since the quotient $\mathbb{F}_2[r]/(p)$ is a field $\cong \mathbb{F}_{2^e}$, it is more efficient to construct it as follows:

R.<x,y,z> = PolynomialRing(GF(2^e, name='a', modulus=p), 3)

An element y of GF(2^e) can be written as a polynomial of degree less than $e$ as follows:

K.<a> = GF(2^e, modulus=p)
R.<x> = PolynomialRing(GF(2))
y = a^48 + a^27 + 1
vy = vector(y)
sum(vy[d]*x^d for d in range(e))

By the way, this can be done with a Groebner basis of $(p) \subset \mathbb{F}_2[x]$ as well. Namely, the normal form of a polynomial w.r.t. the Groebner basis $[p]$ of $(p)$ is the one of degree less than $e$ as well:

R.ideal(p).reduce(x^48 + x^27 + 1)

In this one-variable situation, the normal form is just the remainder after polynomial division.

2018-11-22 13:55:38 -0600 commented question Eigenvectors of matrices over finite fields

Please add an example and the error you get.

2018-11-22 07:26:40 -0600 answered a question Extended Euclidean Algorithm for Univariate Polynomials with Coefficients in a Finite Field

See Wikipedia - Polynomial extended Euclidean algorithm:

A third difference is that, in the polynomial case, the greatest common divisor is defined only up to the multiplication by a non zero constant. There are several ways to define the greatest common divisor unambiguously. In mathematics, it is common to require that the greatest common divisor be a monic polynomial. To get this, it suffices to divide every element of the output by the leading coefficient of $r_k$. This allows that, if a and b are coprime, one gets 1 in the right-hand side of Bézout's inequality. Otherwise, one may get any non-zero constant.

So e.g. at the end you can do

lc = r0.lc()
return r0/lc, s0/lc, t0/lc
2018-11-22 03:34:26 -0600 commented question Assignation of components of a differential form (or multivector field) in sagemanifold

Please add an example of what is tedious.

2018-11-22 03:11:38 -0600 commented question Tensor density in sagemanifolds?

I don't think this is implemented yet. To implement tensor densities I guess TensorField should become a subclass of TensorDensity (or TensorDensityField?) with weight zero, and probably much functionality could be moved to TensorDensity with the appropriate generalization (taking the weight into account).

2018-11-20 10:25:10 -0600 commented question `Fraction must have unit denominator`when using polynomial.numerator()

You should learn to debug a little better, at least to pin down where the error comes from. In this instance e.g. search for division / in your code. Here it seems the error comes when you try to convert g/h to a polynomial with integer coefficients. This would work if h was a factor of g, but it seems in your example not to be the case, so you are calculating h in a wrong way.

2018-11-18 14:53:13 -0600 commented answer Computing the basis of the Frobenius function fixed point space

Well done. Note that vector2poly uses x from global scope (which may cause problems if you use different polynomial rings); you might want to pass x as an argument instead. Also reduce(lambda a,b: a+b, ...) is usually denoted sum(...).

2018-11-18 13:29:41 -0600 commented question Computing the basis of the Frobenius function fixed point space

By trying basic debugging you see the big scary error comes from GFX(h). Here you are expecting GFX to understand that the element you passed belongs to a quotient and you want to lift it, which is kind of a tall order. Instead what works is h.lift(). Furthermore note that by computing images of basis vectors you construct the columns of the matrix, so you want to either add a .transpose() somewhere or construct the matrix differently. When you get it working, feel free to post it as an answer.

2018-11-18 09:40:25 -0600 commented question Computing the basis of the Frobenius function fixed point space

Technical hints: x = GFX.gen(), q = GFX.base_ring().cardinality(); then you can do basic_image = GFX_quo_f(x^(q*k) - x^k) and such an element in the quotient can be converted to a list or a vector (try vector(basic_image)), which you can use to construct a matrix, on which you can call the method right_kernel().

2018-11-18 07:56:34 -0600 commented question Computing the basis of the Frobenius function fixed point space

Hint: a basis of $\mathbb{F}_q[x]/(f)$ is $1, x, \ldots, x^{\deg(f)-1}$ and you can write the linear map as a matrix, so you just have to do linear algebra over $\mathbb{F}_q$. For reference, this is part of Berlekamp's algorithm and $W$ is called the Berlekamp subalgebra.