Jump to content

Sage/First Steps

From Wikibooks, open books for an open world

Installation

[edit | edit source]

Commandline Interface

[edit | edit source]

In Ubuntu terminal:

> ./sage
┌────────────────────────────────────────────────────────────────────┐
 SageMath version 8.1, Release Date: 2017-12-07                     
 Type "notebook()" for the browser-based notebook interface.        
 Type "help()" for help.                                            
└────────────────────────────────────────────────────────────────────┘
> sage:

Notebook Interface

[edit | edit source]

Inside Sage type "notebook()" for the browser-based notebook interface.

> sage: notebook()

Introduction

[edit | edit source]

Sage is based on Python. With some exceptions, all commands are regular Python syntax.

Very simple calculation

[edit | edit source]
  • Numbers
 > sage: 1+1
 > 2
  • Symbolic expression
 > sage: sqrt(2)
 > sqrt(2)
  • Evaluate a symbolic expression
 > sage: sqrt(2).n(digits=100)
 > 1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573

Arrays

[edit | edit source]
 > sage: a = [1,2,3]
 > sage: sum(a)
 > 6