ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 27 Sep 2020 10:49:22 -0500Segmentation fault in magma interfacehttps://ask.sagemath.org/question/53622/segmentation-fault-in-magma-interface/ I'm trying to use the Magma computational algebra interface to do polynomial interpolation for large lists of size 2^18. My code has the following:
p = magma("Interpolation(%s,%s)" % (I,V)).sage()
where I and V are lists each with 2^18 elements. This works just fine for smaller lists but for this size it looks like magma gets a segfault with the following error:
> File "/SageMath/local/lib/python3.7/site-packages/sage/interfaces/magma.py", line 631, in set
raise TypeError("Error executing Magma code:\n%s" % out)
> TypeError: Error executing Magma code:
> Magma: Internal error
> Machine type: intel64-linux
> Memory usage: 49264.41MB
> Segmentation fault
I know that Magma by itself can do the computation, but I would like to get it working using the Sage interface. Is this just not possible or am I doing something wrong? dennySun, 27 Sep 2020 10:49:22 -0500https://ask.sagemath.org/question/53622/Polynomial ring indexed over an abelian group (magma).https://ask.sagemath.org/question/50799/polynomial-ring-indexed-over-an-abelian-group-magma/Hi, I wonder if currently there's a cleaner way to do $x^v \cdot x^w = x^{v+w}$ in Sage, where $v, w$ are some vectors in a vector space?
Once a basis $\{v_1, \cdots v_n\}$ for the vector space is chosen, this can be done by identifying $x_i$ with $x^{v_i}$, and use the multivariate ring $R[x_1, \cdots, x_n]$. However, I would like to do this in an intrinsic manner, i.e. not choosing a basis.
More generally, I think for any element $m$ in any magma $M$, we should be able to define an algebra $R[x^m|m\in M]$ over any given ring $R$. Notice that this is not the same as `FreeAbelianMonoid` generated over $M$, as in this case $x^m x^{n}$ is not the same as $x^{mn}$.
### Question
Is $R[x^m|m\in M$$ currently doable? If not, I might work on writing it.
### Application
A reason why I think it would be helpful: it can help calculating generalized characters of representations of quantum groups.jinThu, 16 Apr 2020 12:27:57 -0500https://ask.sagemath.org/question/50799/How to create a subgroup with MAGMA inside SAGE of a group created with MAGMA inside SAGE?https://ask.sagemath.org/question/48678/how-to-create-a-subgroup-with-magma-inside-sage-of-a-group-created-with-magma-inside-sage/Dear SAGE team,
I would like to let MAGMA inside SAGE create a subgroup of a group (which was also created with MAGMA inside SAGE), but an error message was returned.
Unfortunately, I don't know ho to resolve this.
I would be thankful for any help.
Here's the code (only an example):
>> sage: GG=gap.SymmetricGroup(4)
>> sage: gensGG = gap.GeneratorsOfGroup(GG)
>> sage: m=gap.LargestMovedPoint(gensGG)
>> sage: GGG=magma.Sym(m)
>> sage: GG_MAGMA=magma.new('sub< GGG | [(1,2)] > ')
The error message is as follows:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-da9ee2cf66f9> in <module>()
----> 1 GG_MAGMA=magma.new('sub<GGG|[(1,2)]>')
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in new(self, code)
351
352 def new(self, code):
--> 353 return self(code)
354
355 ###################################################################
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in __call__(self, x, gens)
792 pass
793
--> 794 A = Expect.__call__(self, x)
795 if has_cache:
796 x._magma_cache[self] = A
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
286
287 if isinstance(x, string_types):
--> 288 return cls(self, x, name=name)
289 try:
290 return self._coerce_from_special_method(x)
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
1441 except (RuntimeError, ValueError) as x:
1442 self._session_number = -1
-> 1443 raise_(TypeError, TypeError(*x.args), sys.exc_info()[2])
1444 except BaseException:
1445 self._session_number = -1
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
1436 else:
1437 try:
-> 1438 self._name = parent._create(value, name=name)
1439 # Convert ValueError and RuntimeError to TypeError for
1440 # coercion to work properly.
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _create(self, value, name)
482 def _create(self, value, name=None):
483 name = self._next_var_name() if name is None else name
--> 484 self.set(name, value)
485 return name
486
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in set(self, var, value)
627 13/5
628 """
--> 629 out = self.eval("%s:=%s" % (var, value))
630 if out.lower().find("error") != -1:
631 raise TypeError("Error executing Magma code:\n%s" % out)
/var/autofs/nfs/scratch/hannes/sage-8.8/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in eval(self, x, strip, **kwds)
561 ans = Expect.eval(self, x, **kwds).replace('\\\n', '')
562 if 'Runtime error' in ans or 'User error' in ans:
--> 563 raise RuntimeError("Error evaluating Magma code.\nIN:%s\nOUT:%s" % (x, ans))
564 return ans
565
TypeError: Error evaluating Magma code.
IN:_sage_[3]:=sub<GGG|[(1,2)]>;
OUT:
>> _sage_[3]:=sub<GGG|[(1,2)]>;
^
User error: Identifier 'GGG' has not been declared or assigned
BernFri, 08 Nov 2019 12:14:46 -0600https://ask.sagemath.org/question/48678/Matrix transformation of a LLL reduced basishttps://ask.sagemath.org/question/48163/matrix-transformation-of-a-lll-reduced-basis/Dear Sage Community,
I am trying the way to obtain the matrix transformation of a LLL reduced basis, that is a matrix that gives the expression of the new lattice basis in terms of the old.
In particular, I have a matrix X and the LLL reduced base Y (obtain by the LLL function of Sage: Y=X.LLL()) and I want a matrix T such that TX=Y.
I try to solve the problem using solve.left() but the result is different from Magma.
With a matrix X=[5 2]
[1 4]
[2 3],
the T matrix in Sage is [ 0 0 0]
[ 2/9 -1/9 0]
[ 1/18 -5/18 0] while in Magma is [ -3 -6 10]
[ -3 -7 11]
[ -5 -11 18]
Please could anyone help me to understand a way to have in SAGE the same result of Magma?A.CioThu, 03 Oct 2019 04:39:10 -0500https://ask.sagemath.org/question/48163/How to connect Magma_free, SAGE and GAP (problem concerning a MAGMA string not readable by GAP)?https://ask.sagemath.org/question/45267/how-to-connect-magma_free-sage-and-gap-problem-concerning-a-magma-string-not-readable-by-gap/ Hi,
I'd like to ask the following:
I'd like to use SAGE in order to compute something with the free magma online calculator and then convert it into a GAP object. Unfortunately, there occurs an error, and I don't know, how to fix this. Any help is very much appreciated.
I followed the example on page 91 of http://www.math.rwth-aachen.de/~Thomas.Breuer/ctbllib/doc/manual.pdf
Here is what I did:
sage: gap.LoadPackage('"ctbllib"');
sage: ct=magma_free("G:=Alt(5);ct:=CharacterTable(G);ct;")
sage: tmpdir = gap.DirectoryTemporary()
sage: file=gap.Filename(tmpdir, '"magmatable"')
sage: gap.FileString(file,ct)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-fd546564c72c> in <module>()
----> 1 gap.FileString(file,ct)
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, *args, **kwds)
627
628 def __call__(self, *args, **kwds):
--> 629 return self._parent.function_call(self._name, list(args), kwds)
630
631 def _instancedoc_(self):
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in function_call(self, function, args, kwds)
921
922 """
--> 923 args, kwds = self._convert_args_kwds(args, kwds)
924 self._check_valid_function_name(function)
925
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _convert_args_kwds(self, args, kwds)
530 for i, arg in enumerate(args):
531 if not isinstance(arg, InterfaceElement) or arg.parent() is not self:
--> 532 args[i] = self(arg)
533 for key, value in iteritems(kwds):
534 if not isinstance(value, InterfaceElement) or value.parent() is not self:
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
278
279 if isinstance(x, string_types):
--> 280 return cls(self, x, name=name)
281 try:
282 return self._coerce_from_special_method(x)
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
1443 except (RuntimeError, ValueError) as x:
1444 self._session_number = -1
-> 1445 raise_(TypeError, TypeError(*x.args), sys.exc_info()[2])
1446 except BaseException:
1447 self._session_number = -1
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
1438 else:
1439 try:
-> 1440 self._name = parent._create(value, name=name)
1441 # Convert ValueError and RuntimeError to TypeError for
1442 # coercion to work properly.
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _create(self, value, name)
474 def _create(self, value, name=None):
475 name = self._next_var_name() if name is None else name
--> 476 self.set(name, value)
477 return name
478
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in set(self, var, value)
1387 """
1388 cmd = ('%s:=%s;;' % (var, value)).replace('\n','')
-> 1389 self._eval_line(cmd, allow_use_file=True)
1390
1391 def get(self, var, use_file=False):
/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in _eval_line(self, line, allow_use_file,
wait_for_prompt, restart_if_needed)
787 return ''
788 else:
--> 789 raise RuntimeError(message)
790
791 except KeyboardInterrupt:
TypeError: Gap terminated unexpectedly while reading in a large line:
Gap produced error output
Syntax error: ; expected in /home/boehmler/.sage/temp/mahlzahn/8255/interface/\
tmp8325 line 1
\$sage2:=Character Table of Group G-------------------------------------------\
----------Class | 1 2 3 4 5Size | 1 15 20 12 12Order | 1 2\
3 5 5---------------------------p = 2 1 1 3 5 4p = 3 1\
2 1 5 4p = 5 1 2 3 1 1---------------------------X.1 + \
1 1 1 1 1X.2 + 3 -1 0 Z1 Z1#2X.3 + 3 -1 0 Z1#2 Z1X.4 \
+ 4 0 1 -1 -1X.5 + 5 1 -1 0 0Explanation of Character Valu\
e Symbols--------------------------------------# denotes algebraic conjugation\
, that is,#k indicates replacing the root of unity w by w^kZ1 = (Cyclotomi\
cField(5: Sparse := true)) ! [ RationalField() | 0, 0, -1, -1 ];;
^
executing Read("/home/boehmler/.sage/temp/mahlzahn/8255/interface/tmp8325");
sage:
BernFri, 01 Feb 2019 10:23:52 -0600https://ask.sagemath.org/question/45267/Rewriting number field related Magma code in Sagehttps://ask.sagemath.org/question/41224/rewriting-number-field-related-magma-code-in-sage/I have the following Magma code, which I want to rewrite in Sage:
G := Sz(8);
T := CharacterTable(G);
M := GModule(T[2]:SparseCyclo := false);
N := AbsoluteModuleOverMinimalField(M);
Currently, I have something like this:
from sage.all import *
proof.arithmetic(False)
G = SuzukiGroup(8)
T = gap(G).CharacterTable()
print(gap.eval("Display(%s)"%T.name()))
Though, I do not know how to rewrite the rest in Sage. `Sz` in Magma is Suzuki group. The result of `M` here is `GModule M of dimension 14 over Cyclotomic Field of order 52 and degree 24`. Also, the result of `T[2]` in Magma is `T[2] = ( 14, -2, 2*zeta(4)_4, -2*zeta(4)_4, -1, 0, 0, 0, 1, 1, 1 )`. `AbsoluteModuleOverMinimalField` is defined [here](https://magma.maths.usyd.edu.au/magma/handbook/text/1038#11747).ninhoWed, 21 Feb 2018 14:39:53 -0600https://ask.sagemath.org/question/41224/Inconsistent result between Sage and Magma for sqrthttps://ask.sagemath.org/question/39670/inconsistent-result-between-sage-and-magma-for-sqrt/I have the following Magma code:
N2t := 625;
D := 84100;
tau:= Sqrt(-IntegerRing(N2t)!D);
tau
It basically creates a ring of integers modulo 625, evaluated it for the value of `D` with negation, and finally applies a square root calculation. Now, the result produced is `280`. When, I convert the code to Sage such as this:
N2t = 625
D = 84100
Z = Integers(N2t)
tau = sqrt(-Z(D))
tau
I get a result of `30`. Any ideas why this is the case?whateverMon, 20 Nov 2017 08:57:39 -0600https://ask.sagemath.org/question/39670/Lattices in Sagehttps://ask.sagemath.org/question/39542/lattices-in-sage/I have the following Magma code, and I want to rewrite it in Sage.
L:=Lattice(Matrix(Rationals(),2,2,[N2t,0,tau,1]), Matrix(Rationals(),2,2,[1,0,0,D]));
"Lattice:\n",L;
"\nBasis matrix:\n",LLLBasisMatrix(L);
In Sage I have something like this:
M = Matrix(QQ, [(N2t,0,tau,1), (1,0,0,D)])
M.LLL()
Whose output is not exactly the same thing produced by the above Magma code. I think the main problem is that I use a matrix and just apply the LLL algorithm to it in the Sage part. Whereas, in Magma there a lattice created, and then the `LLLBasisMatrix` function (https://magma.maths.usyd.edu.au/magma/handbook/text/312#2964) called. Roughly speaking that function does this:
> Given a lattice L with basis matrix B,
> return the LLL basis matrix B' of L,
> together with the transformation
> matrix T such that B'=TB. The LLL
> basis matrix B' is simply defined to
> be a LLL-reduced form of B; it is
> stored in L when computed and
> subsequently used internally by many
> lattice functions. The LLL basis
> matrix will be created automatically
> internally as needed with δ=0.999 by
> default (note that this is different
> from the usual default of 0.75); by
> the use of parameters to this function
> one can ensure that the LLL basis
> matrix is created in a way which is
> different to the default.
How does one create a lattice in Sage? And does Sage have a function similar to `LLLBasisMatrix` above? If not, how can I achieve the same functionality in Sage?
As for numeric example, I have the following values:
N2t = 1136868377216160297393798828125
D = 53364935730486508893809772233249725927747397616650814998641
tau = 954690521650617175389887577728
and if I call the above Magma code with these values, I get the following result for the basis matrix:
[-182177855565543122003911250397 1]
[ 772512666085074053385976327331 2]
whereas if I call the above Sage code with the above values, I get the following result:
[1136868377216160297393798828125 0 954690521650617175389887577728 1]
[1 0 0 53364935730486508893809772233249725927747397616650814998641]whateverTue, 14 Nov 2017 09:44:25 -0600https://ask.sagemath.org/question/39542/Magma coercion equivalent in Sage?https://ask.sagemath.org/question/39521/magma-coercion-equivalent-in-sage/I'm working on converting a code written in Magma to Sage. I have something like this in Magma:
Fp;=FiniteField(p);
if (p mod 4) eq 3 then
q:=1;
else
q:=3;
while IsSquare(-Fp!q) do
q:=q+4;
end while;
end if;
Now there is the `!` operator used, which is called coercion in Magma. Is there an equivalent operator in Sage? I mean how would one conver the `IsSquare(-Fp!q)` part valid Sage?whateverMon, 13 Nov 2017 16:23:49 -0600https://ask.sagemath.org/question/39521/help Sage find Magmahttps://ask.sagemath.org/question/36969/help-sage-find-magma/I have both Sage and Magma installed in my machine, but when type
sage: magma_console()
I get this error message
/Applications/Sage-6.5.app/Contents/Resources/sage/local/bin/sage-native\
-execute: line 8: magma: command not found
How do help Sage find Magma?ha55555Fri, 17 Mar 2017 17:01:13 -0500https://ask.sagemath.org/question/36969/why sage help not give out a function'name Directory by subjects?https://ask.sagemath.org/question/10820/why-sage-help-not-give-out-a-functionname-directory-by-subjects/index is too big,not differentiate between by different subjects
like magma/maple/mathematica,all numberfield'function name get together, all group'function name get together, all autoform'function name get together,every function link to DocumentationcjshTue, 10 Dec 2013 19:59:59 -0600https://ask.sagemath.org/question/10820/why sage help not give out a function'name Directory by subjects?https://ask.sagemath.org/question/10814/why-sage-help-not-give-out-a-functionname-directory-by-subjects/index is too big,not differentiate between by different subjects
like magma/maple/mathematica,all numberfield'function name get together, all group'function name get together, all autoform'function name get together,every function link to DocumentationcjshTue, 10 Dec 2013 20:00:02 -0600https://ask.sagemath.org/question/10814/Computing maximal orders in relative extensionshttps://ask.sagemath.org/question/9203/computing-maximal-orders-in-relative-extensions/As part of a project, I am translating some MAGMA code to SAGE. The relevant piece of code computes the maximal order of the relative extension of `Qa12`, a number field of degree 20, by the polynomial `y^2 - kappa12`:
subOrderK:=ext<OO | y^2-kappa12>;
subOrderK:=AbsoluteOrder(subOrderK);
D:=Discriminant(subOrderK);
for p in PrimeDivisors(D) do
subOrderK:=pMaximalOrder(subOrderK,p);
end for;
OOK:=subOrderK;
Here `OO` is the ring of integers (i.e. the maximal order) of `Qa12`.
As I did not see a way to translate this word for word (if I am missing something, please point it out), I tried a different approach. Here is my code (in SAGE):
L.<c> = Qa12.extension(y^2-kappa12)
L.<alpha> = L.absolute_field()
subOrderK = L.order(alpha)
D = subOrderK.discriminant()
for p in factor(D):
subOrderK = L.maximal_order(p[0])
OOK = subOrderK
Note that `y^2-kappa12` has coefficients coerced in `Qa12` and we make sure that it is indeed irreducible in `Qa12` (i.e. we make sure that `kappa12` is not the square of an element of `Qa12`).
You may notice immediately that my for-loop is a rather clumsy translation of the corresponding loop in the MAGMA code. I was hoping that SAGE would "remember" the previous value of `subOrderK`, thus having the same effect as the MAGMA-command `pMaximalOrder(subOrderK,p)`. However, my problem arises even earlier than that:
the number computed by `subOrderK.discriminant()` is absurdly huge - too big, in fact, for there to be any hope to factorise it in any reasonable amount of time.
The obvious alternative of simply writing
L.<c> = Qa12.extension(y^2-kappa12)
L.<alpha> = L.absolute_field()
OOK = L.maximal_order()
is also extremely time-intensive; I have not yet seen this finish.
I was hoping someone could help either with improving my code, or with a radically different approach to the problem.
NOTE: Though I have tried to make this question understandable, if some parts remain opaque, please do say so. I'll do my best to correct it. Leonhard MoosbruggerSat, 04 Aug 2012 04:33:43 -0500https://ask.sagemath.org/question/9203/Does sage have analog of magma function IsIsomorphic?https://ask.sagemath.org/question/9651/does-sage-have-analog-of-magma-function-isisomorphic/Does Sage have analog of magma function [IsIsomorphic for curves](http://magma.maths.usyd.edu.au/magma/handbook/text/1253#13614)
> IsIsomorphic(C, D) : Crv, Crv -> BoolElt,MapSch
> Given irreducible curves C and D this
> function returns true is C and D are
> isomorphic over their common base
> field. If so, it also returns a scheme
> map giving an isomorphism between
> them. The curves C and D must be
> reduced. Currently the function
> requires that the curves are not both
> genus 0 nor both genus 1 unless the
> base field is finite.
or [IsIsomorphic for hyperelliptic curves](http://magma.maths.usyd.edu.au/magma/handbook/text/1391#15274)?
> IsIsomorphic(C1, C2) : CrvHyp, CrvHyp
> -> BoolElt, MapIsoSch
>
> SetVerbose("CrvHypIso", n): Maximum: 3
>
> This function returns true if and only if the hyperelliptic curves C1
> and C2 are isomorphic over their
> common base field. If the curves are
> isomorphic, an isomorphism is
> returned.petRUShkaWed, 26 Dec 2012 00:56:53 -0600https://ask.sagemath.org/question/9651/Analogue of PointsOverSplittingField in SAGEhttps://ask.sagemath.org/question/8690/analogue-of-pointsoversplittingfield-in-sage/Does anyone know if SAGE has an analogue of MAGMA's function PointsOverSplittingField, or something that does Groebner basis computations/polynomial system solutions over an algebraically closed field.
I am trying to verify the results that MAGMA gives me, so please don't point me to SAGE's interface to MAGMA.arsenelkinThu, 02 Feb 2012 06:10:38 -0600https://ask.sagemath.org/question/8690/Magma object from magma.eval()?https://ask.sagemath.org/question/8185/magma-object-from-magmaeval/How can I get a Magma object to use inside of Sage from something created in Magma through magma.eval()? Is this possible?CodyThu, 23 Jun 2011 08:13:33 -0500https://ask.sagemath.org/question/8185/Word wrap in magma interfacehttps://ask.sagemath.org/question/8078/word-wrap-in-magma-interface/Hi all,
I'm experiencing a strange phenomenon when using the sage interface to magma, through the notebook interface (in firefox and chrome browsers, on separate computers). If I enter a command that is long enough to require word-wrapping in the standard input window, it causes the magma interpreter to throw an error. As best I can tell, it is passing the newline to magma erroneously. That is, I don't intend to have a newline there, but it's still causing an error. I was baffled what was causing the error, but then I broke the code (a long sum) into two shorter lines, each a command for half of the code for the sum.
Can anyone offer advice how to work with long lines of code in the sage magma interface, without having to awkwardly break them up? Thanks, DavidDavid JordanSun, 17 Apr 2011 17:33:18 -0500https://ask.sagemath.org/question/8078/Reseting magma tab completion datahttps://ask.sagemath.org/question/7941/reseting-magma-tab-completion-data/Hello,
I have been attempting to use the magma interface functionality in the notebook() web interface. It seems to work (our school has a magma license, and it is able to connect). However, the first time I attempted tab completion in the notebook GUI, it seemed to freeze. Not knowing any better, I stopped evaluation; afterwards I received an error message indicating that I needed to wait awhile for a cache with all the tab completion data to be compiled. However, this was too late, and somehow it seems to have written a blank tab completion cache.
I don't know where this cache is stored, or how to trigger the interface to remake the cache. Can anyone offer assistance?David JordanFri, 11 Feb 2011 11:22:32 -0600https://ask.sagemath.org/question/7941/