Book Image

Sage Beginner's Guide

By : Craig Finch
1 (1)
Book Image

Sage Beginner's Guide

1 (1)
By: Craig Finch

Overview of this book

Table of Contents (17 chapters)
Sage Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – PDF output from the notebook interface


Enter the following code into an input cell in a worksheet, and evaluate the cell.

var('n,x,t')
J_n(n,x) = 1/pi*integral(cos(n*t-x*sin(t)), t)
J_n
show(J_n)
view(J_n)
view(J_n, mode='display'))

You should see the following results in your worksheet:

Let's say you want to generate a PDF file. Enter the following code after evaluating the code from the first example:

restore('i'))
J_n_2(n, x) = 1 / (2 * pi) * integral(exp(-i * (n * t - x * sin(t))), t, -pi, pi)
view([J_n, J_n_2], title='Representations of the Bessel function',, sep='\hrule', viewer='pdf', mode='display')

You will not see any output in the worksheet. Instead, the external viewer should open a new window with a PDF file that contains the following content:

If you only want to output a single equation as a PDF file, rather than an entire page, try this:

view(J_n, viewer='pdf', tightpage=True, mode='display')

The results should look like this:

Now, try this:

sage.misc.latex.png(J_n...