售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Sage
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 the QR factorization
What just happened?
Time for action - computing the singular value decomposition
What just happened?
An introduction to NumPy
Time for action - creating NumPy arrays
What just happened?
Creating NumPy arrays
NumPy types
Indexing and selection with NumPy arrays
Time for action - working with NumPy arrays
What just happened?
Have a go hero - replacing lists with NumPy arrays
NumPy matrices
Time for action - creating matrices in NumPy
What just happened?
Learning more about NumPy
Summary
6. Plotting with Sage
Confusion alert: Sage plots and matplotlib
Plotting in two dimensions
Plotting symbolic expressions with Sage
Time for action - plotting symbolic expressions
What just happened?
Time for action - plotting a function with a pole
What just happened?
Time for action - plotting a parametric function
What just happened?
Time for action - making a polar plot
What just happened?
Time for action - plotting a vector field
What just happened?
Plotting data in Sage
Time for action - making a scatter plot
What just happened?
Time for action - plotting a list
What just happened?
Using graphics primitives
Time for action - plotting with graphics primitives
What just happened?
Using matplotlib
Time for action - plotting functions with matplotlib
What just happened?
Using matplotlib to "tweak" a Sage plot
Time for action - getting the matplotlib figure object
What just happened?
Time for action - improving polar plots
What just happened?
Plotting data with matplotlib
Time for action - making a bar chart
What just happened?
Time for action - making a pie chart
What just happened?
Time for action - plotting a histogram
What just happened?
Plotting in three dimensions
Time for action - make an interactive 3D plot
What just happened?
Higher quality output
Parametric 3D plotting
Time for action - parametric plots in 3D
What just happened?
Contour plots
Time for action - making some contour plots
What just happened?
Summary
7. Making Symbolic Mathematics Easy
Using the notebook interface
Defining symbolic expressions
Time for action - defining callable symbolic expressions
What just happened?
Relational expressions
Time for action - defining relational expressions
What just happened?
Time for action - relational expressions with assumptions
What just happened?
Manipulating expressions
Time for action - manipulating expressions
What just happened?
Manipulating rational functions
Time for action - working with rational functions
What just happened?
Substitutions
Time for action - substituting symbols in expressions
What just happened?
Expanding and factoring polynomials
Time for action - expanding and factoring polynomials
What just happened?
Manipulating trigonometric expressions
Time for action - manipulating trigonometric expressions
What just happened?
Logarithms, rational functions, and radicals
Time for action - simplifying expressions
What just happened?
Solving equations and finding roots
Time for action - solving equations
What just happened?
Finding roots
Time for action - finding roots
What just happened?
Differential and integral calculus
Time for action - calculating limits
What just happened?
Derivatives
Time for action - calculating derivatives
What just happened?
Integrals
Time for action - calculating integrals
What just happened?
Series and summations
Time for action - computing sums of series
What just happened?
Taylor series
Time for action - finding Taylor series
What just happened?
Have a go hero - Taylor series
Laplace transforms
Time for action - computing Laplace transforms
What just happened?
Solving ordinary differential equations
Time for action - solving an ordinary differential equation
What just happened?
Summary
8. Solving Problems Numerically
Sage and NumPy
Solving equations and finding roots numerically
Time for action - finding roots of a polynomial
What just happened?
Finding minima and maxima of functions
Time for action - minimizing a function of one variable
What just happened?
Functions of more than one variable
Time for action - minimizing a function of several variables
What just happened?
Numerical approximation of derivatives
Time for action - approximating derivatives with differences
What just happened?
Computing gradients
Time for action - computing gradients
What just happened?
Numerical integration
Time for action - numerical integration
What just happened?
Numerical integration with NumPy
Time for action - numerical integration with NumPy
What just happened?
Discrete Fourier transforms
Time for action - computing discrete Fourier transforms
What just happened?
Window functions
Time for action - plotting window functions
What just happened?
Have a go hero - using window functions
Solving ordinary differential equations
Time for action - solving a first-order ODE
What just happened?
Solving a system of ODEs
Time for action - solving a higher-order ODE
What just happened?
Solving the system using the GNU Scientific Library
Time for action - alternative method of solving a system of ODEs
What just happened?
Numerical optimization
Time for action - linear programming
What just happened?
Fitting a function to a noisy data set
Time for action - least squares fitting
What just happened?
Constrained optimization
Time for action - a constrained optimization problem
What just happened?
Probability
Time for action - accessing probability distribution functions
What just happened?
Summary
9. Learning Advanced Python Programming
How to write good software
Object-oriented programming
Time for action - defining a class that represents a tank
What just happened?
Making our tanks move
Time for action - making the tanks move
What just happened?
Have a go hero - checking the values passed to __init__
Creating a module for our classes
Time for action - creating your first module
What just happened?
Expanding our simulation to other kinds of vehicles
Time for action - creating a vehicle base class
What just happened?
Creating a package for our simulation
Time for action - creating a combat simulation package
What just happened?
Have a go hero - adding another derived class
Potential pitfalls when working with classes and instances
Time for action - using class and instance attributes
What just happened?
Time for action - more about class and instance attributes
What just happened?
Creating empty classes and functions
Time for action - creating empty classes and functions
What just happened?
Handling errors gracefully
Time for action - raising and handling exceptions
What just happened?
Exception types
Have a go hero - raising exceptions in the __init__ method of Tank
Creating your own exception types
Time for action - creating custom exception types
What just happened?
Unit testing
Time for action - creating unit tests for the Tank class
What just happened?
Strategies for unit testing
Have a go hero - creating some unit tests
Summary
10. Where to go from here
Typesetting equations with LaTeX
Installing LaTeX
Time for action - PDF output from the notebook interface
What just happened?
The view function in the interactive shell
LaTeX mark-up in the notebook interface
Time for action - working with LaTeX markup in the notebook interface
What just happened?
Time for action - putting it all together
What just happened?
Have a go hero - Bessel functions of the second kind
Speeding up execution
Time for action - detecting collisions between spheres
What just happened?
Time for action - detecting collisions: command-line version
What just happened?
Tips for measuring runtimes
Optimizing our algorithm
Time for action - faster collision detection
What just happened?
Optimizing with NumPy
Time for action - using NumPy
What just happened?
More about NumPy
Optimizing with Cython
Time for action - optimizing collision detection with Cython
What just happened?
Have a go hero - further optimization with Cython
Calling Sage from Python
Time for action - calling Sage from a Python script
What just happened?
Have a go hero - solving an ODE symbolically from Python
Introducing Python decorators
Time for action - introducing the Python decorator
What just happened?
Pop quiz - understanding function decorators
Have a go hero - improving the decorator
Have a go hero - the memoize decorator
Making interactive graphics
Time for action - making interactive controls
What just happened?
Using interactive controls
Time for action - an interactive example
What just happened?
Have a go hero - Taylor series
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜