Basics |
|
|---|---|
sage: 1+1 2 sage: V = QQ^3 sage: V.[tab key] ... V.base_ring V.basis V.coordinates ... |
Sage uses the basic user interface principle of "question and answer" found in many
other software systems. You enter an expression and after pressing the Return key in the command line interface or hitting Shift+Return in the notebook interface, Sage evaluates your expression and
returns the answer. – read more
Tab-completion helps you enter commands. On the command-line, it also provides history and
reverse lookup search. – read more
|
Classes of Objects |
|
sage: R = RealIntervalField(100)
sage: R
Real Interval Field with 100 bits of precision
sage: a = R((-1,0)); a
[-1.0000000000000000000000000000000 ..
0.00000000000000000000000000000000]
sage: b = sin(a); b
[-0.84147098480789650665250232163084 ..
0.00000000000000000000000000000000]
sage: c = a*b; c.diameter()
0.84147098480789650665250232163
|
As you can see in the previous example, Sage knows about mathematical objects embedded into
the Python language. Every quantity - a real number, a polynomial, a matrix, and so on -
belongs to a parent, and this tells Sage how to perform operations on the quantity.
In the example on the left, R is defined as the class of all intervals of real values with
100 bits of precision. Then an intervals is created and stored in a, the function sin is applied and stored in
b. In the end they are multiplied and the diameter is calculated.
sin is a function that "knows" about intervals, as well
as the multiplication does, and diameter() is a method of an
interval instance object.
|
Interactive Help |
|
sage: c.diameter?
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in method diameter ...>
Namespace: Interactive
Docstring:
If (0 in self), returns self.absolute_diameter(),
otherwise self.relative_diameter().
EXAMPLES:
sage: RIF(1, 2).diameter()
0.666666666666667
...
|
The example above shows that there are thousands of functions and methods. Sage comes with
a built-in help system and you don't have to memorize them all.
Entering a question mark after a method shows the description and additional information
about that method. The example on the left shows the documentation for the diameter method from the previous example.
|