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 – calling functions


We've already seen many simple examples of calling functions. Now, we'll use the plot function to illustrate more advanced ways to call functions. Evaluate the following code:

var('x')
sinc(x) = sin(x) / x

plot(sinc, (x, -10, 10))

The result should look like this:

Now, let's customize our plot:

plot(sinc, x, xmin=-15, xmax=15, thickness=2, color='red', 
    legend_label='sinc')

The customized plot should look like this:

What just happened?

In the first part of the example, we defined a callable symbolic expression that represents the sinc function. This function has important applications in signal processing and information theory. We plotted the function using a simple call to the plot function. When calling a function with multiple arguments, it is important to put the arguments in the right order. The first argument to plot is the callable symbolic expression. The second argument is known as a tuple, which we'll learn about in the next chapter. The tuple...