We compute a space of modular forms with character.
sage: N = 20 sage: D = 20 sage: eps_top = fundamental_discriminant(D) sage: eps = magma.KroneckerCharacter(eps_top, RationalField()) sage: M2 = magma.ModularForms(eps) sage: print M2 Space of modular forms on Gamma_1(5) with character all conjugates of [$.1], weight 2, and dimension 2 over Integer Ring. sage: print M2.Basis() [ 1 + 10*q^2 + 20*q^3 + 20*q^5 + 60*q^7 + O(q^8), q + q^2 + 2*q^3 + 3*q^4 + 5*q^5 + 2*q^6 + 6*q^7 + O(q^8) ]
In SAGE/Python (and sort of C++) coercion of an element x into a structure S is denoted by S(x). This also works for the MAGMA interface:
sage: G = magma.DirichletGroup(20) sage: G.AssignNames(['a', 'b']) sage: (G.1).Modulus() 20 sage: e = magma.DirichletGroup(40)(G.1) sage: print e $.1 sage: print e.Modulus() 40
We coerce some polynomial rings into MAGMA:
sage: R.<y> = PolynomialRing(QQ) sage: S = magma(R) sage: print S Univariate Polynomial Ring in y over Rational Field sage: S.1 y
This example illustrates that SAGE doesn't magically extend how MAGMA implicit coercion (what there is, at least) works:
sage: R.<x> = ZZ[] sage: x * 5 5*x sage: x * 1.0 1.00000000000000*x sage: x * (2/3) 2/3*x sage: y = magma(x) sage: y * 5 5*x sage: y * 1.0 Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Magma' and 'Real Field with 53 bits of precision' sage: y * (2/3) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '*': 'Magma' and 'Rational Field'
Author Log:
Module-level Functions
| x) |
| ) |
| ) |
| ) |
Class: Magma
Type magma.[tab] for a list of all the functions available
from your Magma install. Type magma.[tab]? for Magma's
help about a given function. Type magma(...) to create
a new Magma object, and magma.eval(...) to run a string
using Magma (and get the result back as a string).
NOTE: If you do not own a local copy of MAGMA, try using the
magma_free command instead, which uses the free demo web
interface to MAGMA.
You must use nvals = 0 to call a function that doesn't return anything, otherwise you'll get an error. (nvals is the number of return values.)
sage: magma.SetDefaultRealFieldPrecision(200, nvals=0) # optional and requires MAGMA >= v2.12
sage: magma.eval('1.1') # optional
'1.100000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000'
sage: magma.SetDefaultRealFieldPrecision(30, nvals=0) # optional
| self, [maxread=10000], [script_subdirectory=None], [logfile=None], [server=None], [server_tmpdir=None], [user_config=False]) |
INPUT:
maxread -- affects buffering
script_subdirectory -- directory where scripts are read from
logfile -- output logged to this file
server -- address of remote server
user_config -- if True, then local user configuration files
will be read by MAGMA. If False (the default),
then MAGMA is started with the -n option which
supresses user configuration files.
Functions: Attach,
attach,
attach_spec,
AttachSpec,
chdir,
console,
cputime,
eval,
function_call,
get,
get_verbose,
GetVerbose,
help,
ideal,
load,
objgens,
set,
set_verbose,
SetVerbose,
trait_names,
version
| self, filename) |
Attaching a file in MAGMA makes all intrinsics defined in the
file available to the shell. Moreover, if the file doesn't
start with the freeze; command, then the file is
reloaded whenver it is changed. Note that functions and
procedures defined in the file are not available.
For only those, use magma.load(filename).
| self, filename) |
Attaching a file in MAGMA makes all intrinsics defined in the
file available to the shell. Moreover, if the file doesn't
start with the freeze; command, then the file is
reloaded whenver it is changed. Note that functions and
procedures defined in the file are not available.
For only those, use magma.load(filename).
| self, filename) |
This attaches numerous files to the running MAGMA (see the MAGMA documentation for more details).
| self, filename) |
This attaches numerous files to the running MAGMA (see the MAGMA documentation for more details).
| self, dir) |
| self, x, [strip=True]) |
INPUT:
x -- string of code
strip -- ignored
| self, var) |
| self, type) |
INPUT:
type -- string (e.g. 'Groebner'), see MAGMA documentation
| self, type) |
INPUT:
type -- string (e.g. 'Groebner'), see MAGMA documentation
NOTE: This method is provided to be consistent with the MAGMA naming convention.
| self, L) |
INPUT:
L -- a list of elements of a SAGE multivariate polynomial ring.
OUTPUT:
The magma ideal generated by the elements of L.
sage: R.<x,y> = QQ[] sage: magma.ideal([x^2, y^3*x]) # optional -- requires magma Ideal of Polynomial ring of rank 2 over Rational Field Graded Reverse Lexicographical Order Variables: x, y Basis: [ x^2, x*y^3 ]
| self, filename) |
Loading a file in MAGMA makes all the functions and procedures in the file available. The file should not contain any intrinsics (or you'll get errors).
| self, var, value) |
| self, type, level) |
INPUT:
type -- string (e.g. 'Groebner')
level -- integer >= 0
| self, type, level) |
INPUT:
type -- string (e.g. 'Groebner'), see MAGMA documentation
level -- integer >= 0
NOTE: This method is provided to be consistent with the MAGMA naming convention.
Special Functions: __call__,
__reduce__,
_assign_symbol,
_continuation_prompt,
_equality_symbol,
_false_symbol,
_greaterthan_symbol,
_left_list_delim,
_lessthan_symbol,
_next_var_name,
_object_class,
_post_process_from_file,
_read_in_file_command,
_right_list_delim,
_start,
_true_symbol
| self, x, [gens=None]) |
sage: magma(EllipticCurve('37a')) # optional
Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
sage: magma('EllipticCurve([GF(5)|1,2,3,4,1])') # optional
Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 1 over
GF(5)
sage: magma('PowerSeriesRing(Rationals())', 't') # optional
Power series ring in t over Rational Field
sage: magma('PolynomialRing(RationalField(), 3)', 'x,y,z') # optional
Polynomial ring of rank 3 over Rational Field
Lexicographical Order
Variables: x, y, z
Class: MagmaElement
Functions: assign_names,
AssignNames,
eval,
evaluate,
gens,
get_magma_attribute,
list_attributes,
methods,
set_magma_attribute,
trait_names,
x__iter__
| self, names) |
sage: G = magma.DirichletGroup(20) # optional sage: G.AssignNames(['a','b']) # optional sage: G.1 # optional a
sage: G.Elements() # optional [ 1, a, b, a*b ]
| self, names) |
sage: G = magma.DirichletGroup(20) # optional sage: G.AssignNames(['a','b']) # optional sage: G.1 # optional a
sage: G.Elements() # optional [ 1, a, b, a*b ]
| self) |
If self is named X is MAGMA, this function evaluates X.1, X.2, etc., in MAGMA until an error occurs. It then returns a SAGE list of the resulting X.i. Note - I don't think there is a MAGMA command that returns the list of valid X.i. There are numerous ad hoc functions for various classes but nothing systematic. This function gets around that problem.
Author Log:
| self, [any=False]) |
INPUT:
any -- (bool: default is False) if True, also include
signatures with <Any> as first argument.
Special Functions: __call__,
__iter__,
__len__,
_latex_,
_polynomial_
| self) |
For function calls, use self.eval(...).
sage: M = magma.RMatrixSpace(magma.IntegerRing(), 2, 2) # optional sage: A = M([1,2,3,4]); A # optional [1 2] [3 4] sage: type(A) # optional <class 'sage.interfaces.magma.MagmaElement'> sage: A.Type() # optional ModMatRngElt
| self) |
Author: Jennifer Balakrishnan (jenb@mit.edu)
Types that are nicely latex include:
IMPLEMENTATION: Calls latex.m, which is in SAGE_ROOT/data/extcode/magma/latex.m
sage: latex(magma('-2/3')) # optional
\frac{-2}{3}
sage: magma.eval('R<x> := PolynomialRing(RationalField()); f := (x-17/2)^3;') # optional
''
sage: latex(magma('f')) # optional
x^{3}-\frac{51}{2}x^{2}+\frac{867}{4}x-\frac{4913}{8}
sage: latex(magma('(MatrixAlgebra(RationalField(),3)![0,2,3,4,5,6,7,8,9])^(-1)')) # optional
\left(\begin{array}{ccc}-1\&2\&-1\\2\&-7\&4\\-1\&\frac{14}{3}\&\frac{-8}{3}
\end{array}\right)
sage: magma.eval('K<a> := CyclotomicField(11)') # optional
''
sage: latex(magma('a^3 + a - 17/3')) # optional
\frac{-17}{3}+\zeta_{11}+\zeta_{11}^{3}
sage: latex(magma('EllipticCurve([1,2/3,3/4,4/5,-5/6])')) # optional
y^2+xy+\frac{3}{4}y=x^3+\frac{2}{3}x^2+\frac{4}{5}x-\frac{5}{6}
sage: _=magma.eval('R<x> := PolynomialRing(RationalField())') # optional
sage: _=magma.eval('K<a> := NumberField(x^3+17*x+2)') # optional
sage: latex(magma('(1/3)*a^2 - 17/3*a + 2')) # optional
2-\frac{17}{3}a+\frac{1}{3}a^{2}
SAGE auto-detects the greek letters and puts backslashes in:
sage: _=magma.eval('R<x> := PolynomialRing(RationalField())') # optional
sage: _=magma.eval('K<alpha> := NumberField(x^3+17*x+2)') # optional
sage: latex(magma('(1/3)*alpha^2 - 17/3*alpha + 2')) # optional
2-\frac{17}{3}\alpha+\frac{1}{3}\alpha^{2}
sage: _=magma.eval('R<alpha> := PolynomialRing(RationalField())') # optional
sage: latex(magma('alpha^3-1/7*alpha + 3')) # optional
\alpha^{3}-\frac{1}{7}\alpha+3
Finite field elements:
sage: _=magma.eval('K<a> := GF(27)') # optional
sage: latex(magma('a^2+2')) # optional
2+a^{2}
Printing of unnamed (dollar sign) generators works correctly:
sage: latex(magma('FiniteField(81).1^2+1')) # optional
1+\$.1^{2}
Finite fields:
sage: latex(magma('FiniteField(3)')) # optional
\mathbf{F}_{{3}}
sage: latex(magma('FiniteField(27)')) # optional
\mathbf{F}_{{3}^{3}}
Power Series:
sage: _=magma.eval('R<x> := PowerSeriesRing(RationalField())') # optional
sage: latex(magma('(1/(1+x))')) # optional
1-x+x^{2}-x^{3}+x^{4}-x^{5}+x^{6}-x^{7}+x^{8}-x^{9}+x^{10}-x^{11}+x^{12}-x^
{13}+x^{14}-x^{15}+x^{16}-x^{17}+x^{18}-x^{19}+O(x^{20})
sage: _=magma.eval('R<x> := PowerSeriesRing(RationalField())') # optional
sage: latex(magma('(-1/(2+x + O(x^3)))')) # optional
\frac{-1}{2}+\frac{1}{4}x-\frac{1}{8}x^{2}+O(x^{3})
p-adic Numbers:
sage: latex(magma('pAdicField(7,4)!9333294394/49')) # optional
4\cdot{}7^{-2} + 5\cdot{}7^{-1} + 5+ 6\cdot{}7^{1} + O(7^{2})
Class: MagmaFunction
Special Functions: __call__,
_sage_doc_
Class: MagmaFunctionElement
Special Functions: __call__,
__repr__,
_sage_doc_
See About this document... for information on suggesting changes.