Table of Contents
Sage
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Time for action - heading
What just happened?
Pop quiz - heading
Have a go hero - heading
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. What Can You Do with Sage?
Getting started
Using Sage as a powerful calculator
Symbolic mathematics
Have a go hero -
Linear algebra
Solving an ordinary differential equation
More advanced graphics
Visualising a three-dimensional surface
Typesetting mathematical expressions
A practical example: analysing experimental data
Time for action - fitting the standard curve
What just happened?
Time for action - plotting experimental data
What just happened?
Time for action - fitting a growth model
What just happened?
Summary
2. Installing Sage
Before you begin
Installing a binary version of Sage on Windows
Downloading VMware Player
Installing VMWare Player
Downloading and extracting Sage
Launching the virtual machine
Start Sage
Installing a binary version of Sage on OS X
Downloading Sage
Installing Sage
Starting Sage
Installing a binary version of Sage on GNU/Linux
Downloading and decompressing Sage
Running Sage from your user account
Installing for multiple users
Building Sage from source
Prerequisites
Downloading and decompressing source tarball
Building Sage
Installation
Summary
3. Getting Started with Sage
How to get help with Sage
Starting Sage from the command line
Using the interactive shell
Time for action - doing calculations on the command line
What just happened?
Getting help
Command history
Tab completion
Interactively tracing execution
Using the notebook interface
Starting the notebook interface
Time for action - doing calculations with the notebook interface
What just happened?
Getting help in the notebook interface
Working with cells
Working with code
Closing the notebook interface
Have a go hero - using the notebook interface
Displaying results of calculations
Operators and variables
Arithmetic operators
Pop quiz - working with operators
Numerical types
Integers and rational numbers
Real numbers
Complex numbers
Symbolic expressions
Defining variables on rings
Combining types in expressions
Pop quiz - understanding types
Strings
Time for action - using strings
What just happened?
Callable symbolic expressions
Time for action - defining callable symbolic expressions
What just happened?
Automatically typesetting expressions
Functions
Time for action - calling functions
What just happened?
Have a go hero - make some more plots
Built-in functions
Numerical approximations
The reset and restore functions
Defining your own functions
Time for action - defining and using your own functions
What just happened?
Functions with keyword arguments
Time for action - defining a function with keyword arguments
What just happened?
Objects
Time for action - working with objects
What just happened?
Getting help with objects
Summary
4. Introducing Python and Sage
Python 2 and Python 3
Writing code for Sage
Long lines of code
Running scripts
Sequence types: lists, tuples, and strings
Time for action - creating lists
What just happened?
Getting and setting items in lists
Time for action - accessing items in a list
What just happened?
Pop quiz - lists and indexing
List functions and methods
Tuples: read-only lists
Time for action - returning multiple values from a function
What just happened?
Strings
Time for action - working with strings
What just happened?
Other sequence types
For loops
Time for action - iterating over lists
What just happened?
Time for action - computing a solution to the diffusion equation
What just happened?
Pop quiz - lists and for loops
Have a go hero - adding another for loop
List comprehensions
Time for action - using a list comprehension
What just happened?
While loops and text file I/O
Time for action - saving data in a text file
What just happened?
Time for action - reading data from a text file
What just happened?
While loops
Parsing strings and extracting data
Alternative approach to reading from a text file
Have a go hero - define a function for reading the text file
Have a go hero - replace a for loop with a while loop
If statements and conditional expressions
Storing data in a dictionary
Time for action - defining and accessing dictionaries
What just happened?
Lambda forms
Time for action - using lambda to create an anonymous function
What just happened?
Summary
5. Vectors, Matrices, and Linear Algebra
Vectors and vector spaces
Time for action - working with vectors
What just happened?
Creating a vector space
Creating and manipulating vectors
Time for action - manipulating elements of vectors
What just happened?
Vector operators and methods
Matrices and matrix spaces
Time for action - solving a system of linear equations
What just happened?
Creating matrices and matrix spaces
Accessing and manipulating matrices
Time for action - accessing elements and parts of a matrix
What just happened?
Manipulating matrices
Time for action - manipulating matrices
What just happened?
Pop quiz - manipulating matrices
Matrix algebra
Time for action - matrix algebra
What just happened?
Other matrix methods
Time for action - trying other matrix methods
What just happened?
Eigenvalues and eigenvectors
Time for action - computing eigenvalues and eigenvectors
What just happened?
Have a go hero - verifying the eigenvalues and eigenvectors
Decomposing matrices
Time for action - computing ...