Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Sage Beginner's Guide
Sage Beginner's Guide

Sage Beginner's Guide: Unlock the full potential of Sage for simplifying and automating mathematical computing with this book and eBook

eBook
$28.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Sage Beginner's Guide

Chapter 1. What Can You Do with Sage?

Sage is a powerful tool—but you don't have to take my word for it. This chapter will showcase a few of the things that Sage can do to enhance your work. At this point, don't expect to understand every aspect of the examples presented in this chapter. Everything will be explained in more detail in the later chapters. Look at the things Sage can do, and start to think about how Sage might be useful to you. In this chapter, you will see how Sage can be used for:

  • Making simple numerical calculations

  • Performing symbolic calculations

  • Solving systems of equations and ordinary differential equations

  • Making plots in two and three dimensions

  • Analysing experimental data and fitting models

Getting started


You don't have to install Sage to try it out! In this chapter, we will use the notebook interface to showcase some of the basics of Sage so that you can follow along using a public notebook server. These examples can also be run from an interactive session if you have installed Sage.

Go to http://www.sagenb.org/ and sign up for a free account. You can also browse worksheets created and shared by others. If you have already installed Sage, launch the notebook interface by following the instructions in Chapter 3. The notebook interface should look like this:

Create a new worksheet by clicking on the link called New Worksheet:

Type in a name when prompted, and click Rename. The new worksheet will look like this:

Enter an expression by clicking in an input cell and typing or pasting in an expression:

Click the evaluate link or press Shift-Enter to evaluate the contents of the cell.

A new input cell will automatically open below the results of the calculation. You can also create a new input cell by clicking in the blank space just above an existing input cell. In Chapter 3, we'll cover the notebook interface in more detail.

Using Sage as a powerful calculator


Sage has all the features of a scientific calculator—and more. If you have been trying to perform mathematical calculations with a spreadsheet or the built-in calculator in your operating system, it's time to upgrade. Sage offers all the built-in functions you would expect. Here are a few examples:

If you have to make a calculation repeatedly, you can define a function and variables to make your life easier. For example, let's say that you need to calculate the Reynolds number, which is used in fluid mechanics:

You can define a function and variables like this:

Re(velocity, length, kinematic_viscosity) = velocity * length / kinematic_viscosity

v = 0.01
L = 1e-3
nu = 1e-6
Re(v, L, nu)

When you type the code into an input cell and evaluate the cell, your screen will look like this:

Now, you can change the value of one or more variables and re-run the calculation:

Sage can also perform exact calculations with integers and rational numbers. Using the pre-defined constant pi will result in exact values from trigonometric operations. Sage will even utilize complex numbers when needed. Here are some examples:

Symbolic mathematics

Much of the difficulty of higher mathematics actually lies in the extensive algebraic manipulations that are required to obtain a result. Sage can save you many hours, and many sheets of paper, by automating some tedious tasks in mathematics. We'll start with basic calculus. For example, let's compute the derivative of the following equation:

The following code defines the equation and computes the derivative:

var('x')
f(x) = (x^2 - 1) / (x^4 + 1)
show(f)
show(derivative(f, x))

The results will look like this:

The first line defines a symbolic variable x (Sage automatically assumes that x is always a symbolic variable, but we will define it in each example for clarity). We then defined a function as a quotient of polynomials. Taking the derivative of f(x) would normally require the use of the quotient rule, which can be very tedious to calculate. Sage computes the derivative effortlessly.

Now, we'll move on to integration, which can be one of the most daunting tasks in calculus. Let's compute the following indefinite integral symbolically:

The code to compute the integral is very simple:

f(x) = e^x * cos(x)
f_int(x) = integrate(f, x)
show(f_int)

The result is as follows:

To perform this integration by hand, integration by parts would have to be done twice, which could be quite time consuming. If we want to better understand the function we just defined, we can graph it with the following code:

f(x) = e^x * cos(x)
plot(f, (x, -2, 8))

Sage will produce the following plot:

Sage can also compute definite integrals symbolically:

To compute a definite integral, we simply have to tell Sage the limits of integration:

f(x) = sqrt(1 - x^2)
f_integral = integrate(f, (x, 0, 1))
show(f_integral)

The result is:

This would have required the use of a substitution if computed by hand.

Have a go hero

There is actually a clever way to evaluate the integral from the previous problem without doing any calculus. If it isn't immediately apparent, plot the function f(x) from 0 to 1 and see if you recognize it. Note that the aspect ratio of the plot may not be square.

The partial fraction decomposition is another technique that Sage can do a lot faster than you. The solution to the following example covers two full pages in a calculus textbook —assuming that you don't make any mistakes in the algebra!

f(x) = (3 * x^4 + 4 * x^3 + 16 * x^2 + 20 * x + 9) / ((x + 2) * (x^2 + 3)^2)
g(x) = f.partial_fraction(x)
show(g)

The result is as follows:

We'll use partial fractions again when we talk about solving ordinary differential equations symbolically.

Linear algebra

Linear algebra is one of the most fundamental tasks in numerical computing. Sage has many facilities for performing linear algebra, both numerical and symbolic. One fundamental operation is solving a system of linear equations:

Although this is a tedious problem to solve by hand, it only requires a few lines of code in Sage:

A = Matrix(QQ, [[0, -1, -1, 1], [1, 1, 1, 1], [2, 4, 1, -2],
    [3, 1, -2, 2]])
B = vector([0, 6, -1, 3])
A.solve_right(B)

The answer is as follows:

Notice that Sage provided an exact answer with integer values. When we created matrix A, the argument QQ specified that the matrix was to contain rational values. Therefore, the result contains only rational values (which all happen to be integers for this problem). Chapter 5 describes in detail how to do linear algebra with Sage.

Solving an ordinary differential equation

Solving ordinary differential equations by hand can be time consuming. Although many differential equations can be handled with standard techniques such as the Laplace transform, other equations require special methods of solution. For example, let's try to solve the following equation:

The following code will solve the equation:

var('x, y, v')
y=function('y', x)
assume(v, 'integer')
f = desolve(x^2 * diff(y,x,2) + x*diff(y,x) + (x^2 - v^2) * y == 0,
    y, ivar=x)
show(f)

The answer is defined in terms of Bessel functions:

It turns out that the equation we solved is known as Bessel's equation. This example illustrates that Sage knows about special functions, such as Bessel and Legendre functions. It also shows that you can use the assume function to tell Sage to make specific assumptions when solving problems. In Chapter 7, we will explore Sage's powerful symbolic capabilities.

More advanced graphics


Sage has sophisticated plotting capabilities. By combining the power of the Python programming language with Sage's graphics functions, we can construct detailed illustrations. To demonstrate a few of Sage's advanced plotting features, we will solve a simple system of equations algebraically:

var('x')
f(x) = x^2
g(x) = x^3 - 2 * x^2 + 2

solutions=solve(f == g, x, solution_dict=True)

for s in solutions:
    show(s)

The result is as follows:

We used the keyword argument solution_dict=True to tell the solve function to return the solutions in the form of a Python list of Python dictionaries. We then used a for loop to iterate over the list and display the three solution dictionaries. We'll go into more detail about lists and dictionaries in Chapter 4. Let's illustrate our answers with a detailed plot:

p1 = plot(f, (x, -1, 3), color='blue', axes_labels=['x', 'y'])
p2 = plot(g, (x, -1, 3), color='red')

labels = []
lines = []
markers = []
for s in solutions:
    x_value = s[x].n(digits=3)
    y_value = f(x_value).n(digits=3)
    labels.append(text('y=' + str(y_value), (x_value+0.5, 
        y_value+0.5), color='black'))
    lines.append(line([(x_value, 0), (x_value, y_value)], 
        color='black', linestyle='--'))
    markers.append(point((x_value,y_value), color='black', size=30))

show(p1+p2+sum(labels) + sum(lines) + sum(markers))

The plot looks like this:

We created a plot of each function in a different colour, and labelled the axes. We then used another for loop to iterate through the list of solutions and annotate each one. Plotting will be covered in detail in Chapter 6.

Visualising a three-dimensional surface

Sage does not restrict you to making plots in two dimensions. To demonstrate the 3D capabilities of Sage, we will create a parametric plot of a mathematical surface known as the "figure 8" immersion of the Klein bottle. You will need to have Java enabled in your web browser to see the 3D plot.

var('u,v')
r = 2.0
f_x = (r + cos(u / 2) * sin(v) - sin(u / 2) 
    * sin(2 * v)) * cos(u)
f_y = (r + cos(u / 2) * sin(v) - sin(u / 2)
    * sin(2 * v)) * sin(u)
f_z = sin(u / 2) * sin(v) + cos(u / 2) * sin(2 * v)
parametric_plot3d([f_x, f_y, f_z], (u, 0, 2 * pi), 
    (v, 0, 2 * pi), color="red")

In the Sage notebook interface, the 3D plot is fully interactive. Clicking and dragging with the mouse over the image changes the viewpoint. The scroll wheel zooms in and out, and right-clicking on the image brings up a menu with further options.

Typesetting mathematical expressions

Sage can be used in conjunction with the LaTeX typesetting system to create publication-quality typeset mathematical expressions. In fact, all of the mathematical expressions in this chapter were typeset using Sage and exported as graphics. Chapter 10 explains how to use LaTeX and Sage together.

A practical example: analysing experimental data


One of the most common tasks for an engineer or scientist is analysing data from an experiment. Sage provides a set of tools for loading, exploring, and plotting data. The following series of examples shows how a scientist might analyse data from a population of bacteria that are growing in a fermentation tank. Someone has measured the optical density (abbreviated OD) of the liquid in the tank over time as the bacteria are multiplying. We want to analyse the data to see how the size of the population of bacteria varies over time. Please note that the examples in this section must be run in order, since the later examples depend upon results from the earlier ones.

Time for action – fitting the standard curve


The optical density is correlated to the concentration of bacteria in the liquid. To quantify this correlation, someone has measured the optical density of a number of calibration standards of known concentration. In this example, we will fit a "standard curve" to the calibration data that we can use to determine the concentration of bacteria from optical density readings:

import numpy
var('OD, slope, intercept')

def standard_curve(OD, slope, intercept):
    """Apply a linear standard curve to optical density data"""
    return OD * slope + intercept

# Enter data to define standard curve
CFU = numpy.array([2.60E+08, 3.14E+08, 3.70E+08, 4.62E+08, 
    8.56E+08, 1.39E+09, 1.84E+09])
optical_density = numpy.array([0.083, 0.125, 0.213, 0.234,
    0.604, 1.092, 1.141])
OD_vs_CFU = zip(optical_density, CFU)

# Fit linear standard
std_params = find_fit(OD_vs_CFU, standard_curve, 
    parameters=[slope, intercept], 
    variables=[OD], initial_guess=[1e9, 3e8],
    solution_dict = True)

for param, value in std_params.iteritems():
    print(str(param) + ' = %e' % value)

# Plot
data_plot = scatter_plot(OD_vs_CFU, markersize=20,
    facecolor='red', axes_labels=['OD at 600nm', 'CFU/ml'])

fit_plot = plot(standard_curve(OD, std_params[slope],
    std_params[intercept]), (OD, 0, 1.2))

show(data_plot+fit_plot)

The results are as follows:

What just happened?

We introduced some new concepts in this example. On the first line, the statement import numpy allows us to access functions and classes from a module called NumPy. NumPy is based upon a fast, efficient array class, which we will use to store our data. We created a NumPy array and hard-coded the data values for OD, and created another array to store values of concentration (in practice, we would read these values from a file) We then defined a Python function called standard_curve, which we will use to convert optical density values to concentrations. We used the find_fit function to fit the slope and intercept parameters to the experimental data points. Finally, we plotted the data points with the scatter_plot function and the plotted the fitted line with the plot function. Note that we had to use a function called zip to combine the two NumPy arrays into a single list of points before we could plot them with scatter_plot. We'll learn all about Python functions in Chapter 4, and Chapter 8 will explain more about fitting routines and other numerical methods in Sage.

Time for action – plotting experimental data


Now that we've defined the relationship between the optical density and the concentration of bacteria, let's look at a series of data points taken over the span of an hour. We will convert from optical density to concentration units, and plot the data.

sample_times = numpy.array([0, 20, 40, 60, 80, 100, 120, 
    140, 160, 180, 200, 220, 240, 280, 360, 380, 400, 420,
    440, 460, 500, 520, 540, 560, 580, 600, 620, 640, 660,
    680, 700, 720, 760, 1240, 1440, 1460, 1500, 1560])

OD_readings = numpy.array([0.083, 0.087, 0.116, 0.119, 0.122,
    0.123, 0.125, 0.131, 0.138, 0.142, 0.158, 0.177, 0.213,
    0.234, 0.424, 0.604, 0.674, 0.726, 0.758, 0.828, 0.919, 
    0.996, 1.024, 1.066, 1.092, 1.107, 1.113, 1.116, 1.12, 
    1.129, 1.132, 1.135, 1.141, 1.109, 1.004, 0.984, 0.972, 0.952])

concentrations = standard_curve(OD_readings, std_params[slope],
     std_params[intercept])
exp_data = zip(sample_times, concentrations)

data_plot = scatter_plot(exp_data, markersize=20, facecolor='red', 
    axes_labels=['time (sec)', 'CFU/ml'])
show(data_plot)

The scatter plot looks like this:

What just happened?

We defined one NumPy array of sample times, and another NumPy array of optical density values. As in the previous example, these values could easily be read from a file. We used the standard_curve function and the fitted parameter values from the previous example to convert the optical density to concentration. We then plotted the data points using the scatter_plot function.

Time for action – fitting a growth model


Now, let's fit a growth model to this data. The model we will use is based on the Gompertz function, and it has four parameters:

var('t, max_rate, lag_time, y_max, y0')

def gompertz(t, max_rate, lag_time, y_max, y0):
    """Define a growth model based upon the Gompertz growth curve"""
    return y0 + (y_max - y0) * numpy.exp(-numpy.exp(1.0 + 
    max_rate * numpy.exp(1) * (lag_time - t) / (y_max - y0)))

# Estimated parameter values for initial guess
max_rate_est = (1.4e9 - 5e8)/200.0
lag_time_est = 100
y_max_est = 1.7e9
y0_est = 2e8

gompertz_params = find_fit(exp_data, gompertz, 
    parameters=[max_rate, lag_time, y_max, y0],
    variables=[t], 
    initial_guess=[max_rate_est, lag_time_est, y_max_est, y0_est],
    solution_dict = True)

for param,value in gompertz_params.iteritems():
    print(str(param) + ' = %e' % value)

The fitted parameter values are displayed:

Finally, let's plot the fitted model and the experimental data points on the same axes:

gompertz_model_plot = plot(gompertz(t, gompertz_params[max_rate],
    gompertz_params[lag_time], gompertz_params[y_max],
    gompertz_params[y0]), (t, 0, sample_times.max()))

show(gompertz_model_plot + data_plot)

The plot looks like this:

What just happened?

We defined another Python function called gompertz to model the growth of bacteria in the presence of limited resources. Based on the data plot from the previous example, we estimated values for the parameters of the model to use an initial guess for the fitting routine. We used the find_fit function again to fit the model to the experimental data, and displayed the fitted values. Finally, we plotted the fitted model and the experimental data on the same axes.

Summary


This chapter has given you a quick, high-level overview of some of the many things that Sage can do for you. Don't worry if you feel a little lost, or if you had trouble trying to modify the examples. Everything you need to know will be covered in detail in later chapters.

Specifically, we looked at:

  • Using Sage as a sophisticated scientific and graphing calculator

  • Speeding up tedious tasks in symbolic mathematics

  • Solving a system of linear equations, a system of algebraic equations, and an ordinary differential equation

  • Making publication-quality plots in two and three dimensions

  • Using Sage for data analysis and model fitting in a practical setting

Hopefully, you are convinced that Sage will be the right tool to assist you in your work, and you are ready to install Sage on your computer. In the next chapter, you will learn how to install Sage on various platforms.

Left arrow icon Right arrow icon

What you will learn

  • Download and install Sage, and learn how to use the command-line and notebook interface Learn the basics of Python programming Solve problems in linear algebra with vectors and matrices Visualize functions and data sets with publication-quality graphics Define, re-arrange, and simplify symbolic expressions Calculate integrals, derivatives, and transforms symbolically and numerically Solve ordinary differential equations (ODEs) and systems of ODEs Fit functions to data using unconstrained and constrained numerical optimization Apply object-oriented principles to simplify your code Speed up calculations with Numpy arrays Learn to use Sage as a toolbox for writing Python programs
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 11, 2011
Length: 364 pages
Edition :
Language : English
ISBN-13 : 9781849514460
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : May 11, 2011
Length: 364 pages
Edition :
Language : English
ISBN-13 : 9781849514460
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 152.97
NumPy Cookbook
$48.99
GNU Octave Beginner's Guide
$48.99
Sage Beginner's Guide
$54.99
Total $ 152.97 Stars icon

Table of Contents

10 Chapters
What Can You Do with Sage? Chevron down icon Chevron up icon
Installing Sage Chevron down icon Chevron up icon
Getting Started with Sage Chevron down icon Chevron up icon
Introducing Python and Sage Chevron down icon Chevron up icon
Vectors, Matrices, and Linear Algebra Chevron down icon Chevron up icon
Plotting with Sage Chevron down icon Chevron up icon
Making Symbolic Mathematics Easy Chevron down icon Chevron up icon
Solving Problems Numerically Chevron down icon Chevron up icon
Learning Advanced Python Programming Chevron down icon Chevron up icon
Where to go from here Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9
(11 Ratings)
5 star 27.3%
4 star 54.5%
3 star 9.1%
2 star 0%
1 star 9.1%
Filter icon Filter
Top Reviews

Filter reviews by




David Joyner Jun 16, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book under review is a book on Sage, an open source mathematical software package started by William Stein, a mathematician at the University of Washington. It is very carefully written (either that, or very carefully reviewed by the Technical Reviewers!) and aimed, as the title suggests, at the beginner. However, it is assumed that the reader knows some undergraduate mathematics, say the level one obtains from getting an engineering degree. In fact, it has a bit of an applied slant with many examples from physics and engineering mathematics. This is a welcome contrast to the excellent Sage Tutorial (available free from the Sage website, sagemath.org) which has a more of a pure slant. It's nice to see a publisher like Packt Publishing take the risk of publishing a book like this on an open source software program which already has free documentation (in pdf or html form).There are 10 chapters and it's about 350 pages. Although Sage of course has color plotting, all figures in this book are in black and white, so the reader really must try out the Sage code given in the book to get the full effect. Each chapter features many "Time for action" Sage code examples (also conveniently listed in the table of contents at the front of the book), followed by a "What just happened?" section explaining in detail (and without computer code) what the example did. These make the book more useful to the beginner as well as for someone wanting a quick reference for one of the examples. All these examples use the command-line version of Sage (typing your commands into a terminal window at a sage: prompt) but there are several sections explaining the GUI version of Sage (typing your commands into a Mathematica-like "notebook cell") as well.Here is a chapter-by-chapter summary:The first chapter, "What can you do with Sage?", is a survey of some of Sage`s most commonly used capabilities. Examples such as solving a differential equations, plotting experimental data, and some simple example matrix computations are presented.The second chapter is "Installing Sage". This covers the steps you go though for a Mac OS, Windows, and Linux installation of Sage. Since this is scary for a number of users who are not very computer-savvy, it is nice an entire chapter is devoted to this.The third chapter, "Getting started with Sage", introduces the new Sage user to the user interface, basic Sage syntax, user-defined functions, and some of the available data types (such as strings and real number types)."Introducing Python and Sage", the fourth chapter, introduces syntax for Python lists, dictionaries, for loops, if-then statements, and also reading and writing to files. Sage is based on Python, a popular language used extensively in industry (at google among other places). This chapter introduces some very useful stuff, but is pretty basic if you know Python already.The 5th chapter is "Vectors, matrices and linear algebra". Sage has very wide functionality in linear algebra, with specialized packages for numerical computations for real and complex matrices, matrices over a finite field, or matrices having symbolic coefficients, such as functions of a variable x.Sage`s functionality in two-dimensional and three-dimensional plotting is described in the 6th chapter, "Plotting with Sage". There is 3-d "live-view" (i.e., you can use the mouse to rotate a plot of a surface or solid in 3-space), histogram plots, as well as simpler plots using Sage`s 2-d plotting package, matplotlib.Chapter 7 is "Making symbolic mathematics easy". Various topics are covered, from various calculus operations, such as limits, derivatives, integrals, and Laplace transforms, to exactsolutions to equations with variable coefficients, to infinite sums such as power series, to solving ordinary differential equations."Solving problems numerically" is the next chapter. This is the meat-and-potatoes for an applied mathematician. Sage includes many packages which have been developed to solve optimization problems, linear programming problems, numerical solutions of ordinary differential equations, numerical integration, and probability and statistics. These are introduced briefly in this chapter.The 9th chapter is "Learning advanced python programming". Here object-oriented programming is introduced by means of examples, and it is shown how Python handles errors and imports.The last chapter "Where to go from here" discusses selected miscellaneous advanced topics.Topics covered include: LaTeX, interactive plotting using the Sage notebook, as well as a fairly detailed example of analyzing colliding spheres in Sage from several different approaches.The book has a very good index and, overall I believe is a very welcomed addition to the literature of Sage books. Maybe it's just my generation, but to me it is a little expensive for a paperback. Because of that, and the fact that it is not as well-rounded as it could be, I'd rate it as 4.5 stars.
Amazon Verified review Amazon
Matthieu Brucher Jul 06, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I heard about Sage when I started learning Python, but I never quite gotten in the bandwagon. Now, this Beginner's Guide seems a good place to start.As with a lot of (all?) Packt Publishing Beginner's Guide, the book with a small introduction of what you can expect of the piece of software and its installation process on the three major platforms. Although for Windows the process is more complicated, the author gives the whole explanation, even on why the process is so complicated for this platform.Sage consists of several layers, Python being one of them, but there are many others. The book tries to dig a little bit further each time. The first "real" (i.e. outside the introductory and installation) chapter tackles the two main ways of using Sage, the interactive shell and the notebook. The different options and the basic usage are explained and illustrated with a lot of examples. The next step is mastering basic Python, which also done with the same efficiency as before.As Sage is mostly about math stuff, the book spends several chapters on the different APIs it offers to handle data. First, linear algebra and the different vectors and matrices are introduced, with a final reference to Numpy and its special arrays. Here is perhaps something lacking in this book: a reference to scipy. Indeed, scipy has a lot to offer in terms of linear algebgra, and it works with Numpy arrays. That being said, the common linear algebra issues will be solved by the Sage interface directly.A huge topic is graphics and scientific plots. The book exposes the different aspects of graphical Sage and also its main support package matplotlib. 3D graphics are also tackled, also they are only very recent in their current form in Matplotlib. It's a good surprise to see some examples here.From my point of view, the purpose of the whole book is the seventh chapter with the subject of symbolic math. The mathematical kernel can handle a lot of different input, rational numbers, trignometric expression, algebraic expressions, derivatives, integrals... Everything the Sage framework can handle is exposed. Also, if there is something it cannot directly handle, Sage can use numerical expressions to solve the issue (the eightth and final math chapter).The last two chapters are not on Sage directly, but more on Python and scientific publications. The Python programming chapter uses a war metaphor, and I guess there might have been another better and more adequate subject for Python programming. If you are used to Python, you may skip this one. The last one is about scientific publication, and eventually the optimization. This last topic is only touched, but it is given the necessary attention given the depth of Sage capabilities.Sometimes the book feels like a giant dictionnary of all the things you can do with Sage, and it actually is. And to find something, you may only have to browse the table of contents and get to the part you sought.Sage is an extraordinary beast, with pieces coming from a lot of different projects, and it's always difficult to know which project you are actually using. Sage acts like a wrapper for most applications, but once you need more, you can tap into the power of each subpackage. The book helps this process, with a good overview of Sage and a lot of real examples. There are some typos inside the book, but they are easily spotted if you mastered the previous chapter.
Amazon Verified review Amazon
Jerry L. Kreps Mar 03, 2012
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The latest release of the SAGE Math Engine was Jan 30, 2012, version 4.8.0. It has 11 PDF files documenting various aspects, but the primary documentation, "Reference.PDF" is 7,084 pages long. Composed of more than 100 Open Source math tools Integrated together seamlessly with a smooth and uniform user interface, written in Python, it is a dream to use. Its power and functionality is enhanced because it is free and freely updated. Although I've never used it, it has been reported that the user support community is pretty good as well.If you have FireFox running when you start SAGE FireFox will show a SAGE Notebook() tab, ready to create a new Notebook, or open an old one. There are plenty of video and graphical examples at the SAGE site that will give you examples of the power of the tool, and its ease of use.
Amazon Verified review Amazon
Marshall Hampton Jul 29, 2011
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I was asked by the publisher to review this book. They sent me a free copy; I have no other conflicts of interest. I am generally biased towards Sage itself ([...]), as an avid user and minor developer.Here on Amazon you can browse the table of contents, which gives a pretty good idea of the strengths of the book, namely basic computation and plotting, numerical calculations, and data analysis. The focus was an excellent choice considering what is already available. The current free Sage Tutorial ([...]) is oriented much more towards pure mathematicians. There is a Numerical Computing With Sage ([...]) as part of the standard documentation ([...]), but at the moment its quite short and nowhere near as helpful as Finch's book.I liked the style of the book a lot. There are many code examples that illustrate how to accomplish concrete tasks, along with good explanations of what they are doing. Many of these are things that are unfortunately far from obvious to a beginner (or even intermediate) Sage user. Despite using Sage heavily for the last five years, I learned some new things. The book is particularly strong in showing how to use Numpy, Scipy, and Matplotlib. Sage wraps a lot of the functionality of these projects, but if you want to do something that isn't included in the standard interfaces it can be quite mystifying.Chapter 9, "Learning Advanced Python Programming", might have been a little ambitious. There's nothing wrong with it, but its too short to provide enough. Fortunately there are a lot of good books, some of them free, that cover Python programming in much more depth. I would have preferred some of this space and effort to be devoted to using Cython and the @interact command, which are covered very briefly in Chapter 10.I teach several classes using Sage and I will definitely advertise this text as a useful optional supplement (I consider it a little too expensive to add on as a mandatory second text). It would be nice if some institutions considered using Sage instead of its commercial competitors such as Maple, Matlab, and Mathematica - you could probably give every student a copy of this book for the money saved from license fees!The only thing I disliked about the book was the quality of the illustrations. Sage output that was in LaTeX was not typeset, but instead looks as if a PNG was copied from a screenshot. Some of the examples would have benefited from being in color. The quality of the plots is also somewhat poor. This is not too big a deal if one is following along with Sage, since you can reproduce the figures. None of them are bad enough to obscure the content.Overall this is a very impressive and useful introduction to Sage that should help any beginning user a great deal.
Amazon Verified review Amazon
tama_mononoke Feb 24, 2012
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
SageはPythonをベースとしたフリーの数式処理システムです。仕事でSageを使うこととなり、Sageのチュートリアルとマニュアルはホームページからダウンロードしました。これらのドキュメントはPythonを使ったことがない私にとっては分かりにくいものでした。そのため、手頃な入門書がないか探したところ、「Sage -- Beginner's guide」を見つけることができました。(それ以外の本は見つけることができませんでした。) 「Sage -- Beginner's guide」は、その名の通り、今までSageの名前も聞いたことのない初学者向けに書かれています。行列/ベクトル演算・数式処理・数値計算・グラフ描画等のSageの基本機能はもちろんのこと、配列(リスト)・ハッシュの使い方や、クラス定義の方法などのPythonに関する説明も丁寧に書かれています。 ただ、出力例・コード例に2,3ヶ所の間違いがあります。校正の不備だと思います。
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela