Sharedwww / old_sage_examples / example.sageOpen in CoCalc
Author: William A. Stein
1
#!/usr/bin/env sage
2
##################################################################
3
#
4
# example.sage -- an example SAGE script.
5
#
6
# Example SAGE script. You can use this example script in many
7
# different ways.
8
#
9
# (*) sage example.sg
10
# (*) ./example.sg (assuming the SAGE directory is in your path)
11
# (*) From within sage type
12
# load 'example.sg'
13
# (*) From within sage type
14
# attach 'example.sg'
15
# With attach, when you enter a blank line in SAGE, if
16
# example.sg has changed it is reloaded.
17
#
18
# As a tutorial and test of your install, you might want to
19
# try all these now.
20
#
21
##################################################################
22
print "This is a simple SAGE example script."
23
24
print 5^10
25
26
27
print '2/3 = ', 2/3
28
29
print 'int(2)/int(3) = ', int(2)/int(3)
30
31
print factor(2005)
32
33
def foo(n):
34
return n^2
35
36
print [foo(i) for i in range(10)]
37
38
E = EllipticCurve('37a')
39
40
print E.gens()
41
42
43
def cond(E):
44
"""
45
Return the conductor of an elliptic curve.
46
47
EXAMPLES:
48
sage: cond(EllipticCurve('37a'))
49
37
50
sage: cond(EllipticCurve([1, -1, 1, -29372, -1932937]))
51
3006
52
"""
53
return E.conductor()
54
55
print cond(E)
56
57
print "This should be true:"
58
print int(gp('ellglobalred(ellinit([1, -1, 1, -29372, -1932937],0))[1]')) == 3006
59
60
time factor(2^127-1)
61
62