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
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##################################################################
22print "This is a simple SAGE example script."
23
24print 5^10
25
26
27print '2/3 = ', 2/3
28
29print 'int(2)/int(3) = ', int(2)/int(3)
30
31print factor(2005)
32
33def foo(n):
34    return n^2
35
36print [foo(i) for i in range(10)]
37
38E = EllipticCurve('37a')
39
40print E.gens()
41
42
43def 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
55print cond(E)
56
57print "This should be true:"
58print int(gp('ellglobalred(ellinit([1, -1, 1, -29372, -1932937],0))[1]')) == 3006
59
60time factor(2^127-1)
61
62