An Introduction to SAGE Programming
eBook - ePub

An Introduction to SAGE Programming

With Applications to SAGE Interacts for Numerical Methods

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

An Introduction to SAGE Programming

With Applications to SAGE Interacts for Numerical Methods

About this book

Features a simplified presentation of numerical methods by introducing and implementing SAGE programs

An Introduction to SAGE Programming: With Applications to SAGE Interacts for Numerical Methods emphasizes how to implement numerical methods using SAGE Math and SAGE Interacts and also addresses the fundamentals of computer programming, including if statements, loops, functions, and interacts. The book also provides a unique introduction to SAGE and its computer algebra system capabilities; discusses second and higher order equations and estimate limits; and determines derivatives, integrals, and summations. Providing critical resources for developing successful interactive SAGE numerical computations, the book is accessible without delving into the mathematical rigor of numerical methods.

The author illustrates the benefits of utilizing the SAGE language for calculus and the numerical analysis of various methods such as bisection methods, numerical integration, Taylor's expansions, and Newton's iterations. Providing an introduction to the terminology and concepts involved, An Introduction to SAGE Programming: With Applications to SAGE Interacts for Numerical Methods also features:

  • An introduction to computer programming using SAGE
  • Many practical examples throughout to illustrate the application of SAGE Interacts for various numerical methods
  • Discussions on how to use SAGE Interacts and SAGE Cloud in order to create mathematical demonstrations
  • Numerous homework problems and exercises that allow readers to practice their programming skillset
  • A companion website that includes related SAGE programming code and select solutions to the homework problems and exercises

An Introduction to SAGE Programming: With Applications to SAGE Interacts for Numerical Methods is an ideal reference for applied mathematicians who need to employ SAGE for the study of numerical methods and analysis. The book is also an appropriate supplemental textbook for upper-undergraduate and graduate-level courses in numerical methods.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access An Introduction to SAGE Programming by Razvan A. Mezei in PDF and/or ePUB format, as well as other popular books in Mathematics & Mathematical Analysis. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Wiley
Year
2015
Print ISBN
9781119122784
eBook ISBN
9781119122807

Chapter 1
Introduction

1.1 What is Sage Math?

If you got a copy of this book, you probably already know that Sage Math is a free open-source mathematics software that is a great alternative to other software such as Mathematica, Maple, Matlab, and even the TI-83/TI-84 calculators. Once you get to master Sage Math, you won't want to use anything else. It's a great tool, easy to use, and very intuitive. And if you can't find a specific function that you may need for a project, then you can easily program it yourself. You will learn how to do this as you read this book.
The official website for Sage Math is http://Sagemath.org [16]. On this website, you can find Quickstart Manuals, Official Documentation Manuals, and Official Binaries that you can use in order to install Sage Math on your own machine. Although the website is very nicely organized, you cannot overestimate the use of the ā€œSearchā€, button which is also available. The source code is obtainable there too.
Note: As of February 2015, Sage announced that it will add ā€œMathā€ to its title in order to disambiguate with other ā€œSagesā€. Throughout this book, we will use both terms ā€œSageā€ and ā€œSage Mathā€ interchangeably.

1.2 Various Flavors of Sage Math

1.2.1 Sage Math on Your Machine

In order to use Sage Math, you can install it on your own computer. This way you won't need Internet connection to run Sage applications and you can also save your own work.
You can find the binaries on the official Sage Math website [16]. One can download binaries for Linux, Mac OS X, and Oracle Solaris. At the moment, the Windows machines need to install a Virtual Machine in order to use Sage Math on such systems. Detailed installation steps can be found here: http://wiki.sagemath.org/SageAppliance.
One can also download and use a Live CD with Sage.

1.2.2 Sage Cell

The author's favorite way to use Sage Math is through a Sage Cell. Using a web browser, one can run Sage Math without the need to install anything on their computer. Moreover, you won't need to worry about having the latest version of Sage Math installed on your computer. One such Sage Math Cell can be found here [13]. All the examples in this book were tested using this Sage Math Cell, running the following version: ā€˜Sage Version 6.3, Release Date: 2014-08-10’. Before you start using it, be aware of the following two main limitations: you need to be connected to the Internet, in order to use Sage Cell, and you won't be able to save your work in there. On the positive side it is very easy to use. It works well on desktop/laptop computers as well as on smartphones.
Note: We recommend you to try different browsers and see which one works the best with the Sage Cell you are using. It is the author's experience that some browsers will work significantly faster with the above-mentioned Sage Cell, than others.

1.2.3 Sage Cloud

Another flavor of Sage Math is using a Sage Notebook (http://sagenb.org). As the front page of this website mentions, one can use it to ā€œcreate, collaborate on, and publish interactive worksheetsā€. Once you register and create a free account, you can create Sage code, save it, access it, and even share it.
The latest development, the collaborative web-based interface of Sage Math is the Sage Cloud (https://cloud.sagemath.com), which seems to quickly replace Sage Notebook. It adds features and capabilities such as ā€œcollaboratively work with Sage Worksheets, IPython notebooks, LaTeX documentsā€, Course Management (an example is a UCLA 400+ student Calculus course), and many others. There is even a Chrome App available that works with it. Sage Cloud is planned to replace Sage Notebook. One can even run code written in other programming languages such as C, C++, Java, and many others, inside Sage Cloud.
To create a free account, just follow the link posted on Sage Math main page (or go to https://cloud.sagemath.com/). There you will be invited to either sign in or create a free account.
To create Sage code and run it inside the Sage Cloud, you will first need to create a project. If you click on ā€œCreate New Projectā€ button, you will be invited to select a name and an optional description. Then, clicking on the link ā€œCreate or Import a File, Worksheet ...ā€, one can select Sage Worksheet, and create a new Sage Worksheet. There, one can type in Sage code and run it.
Note: All the Sage Math code given in this book was tested using Sage Cell. As such, some of the code may need to be changed/tweaked in order to run in Sage Cloud.
For example, the following code runs well in the Sage Cell, but needs some tweaking for Sage Cloud:
#Here come the "fancy" Interacts
@interact
def myInteract1(
    f = input_box(default=e^x ),
    n = slider(vmin=0, vmax=10, step_size=1, \
               default=3, label="Select the order n: "),
    x0 = input_box(default=0 ),
    simplified = selector(values = ["Yes", "No"], \
                 label = "Simplify: ",default = "No" )):
    if(simplified == "Yes"):
        print  f, " = "  , f.taylor(x, x0, n).full_simplify()
    else:
        print  f, " = "  , f.taylor(x, x0, n)
The following is a tweaked version of the previous code that runs on both Sage Cloud and Sage Cell:
@interact
def myInteract2(
    f = input_box(default=e^x ),  \
    n = slider( 0, 10, step_size=1, \
               default=3, label="Select the order n: "), \
    x0 = input_box(default=0 ),
    simplified = selector(values = ["Yes", "No"], \
                 label = "Simplify: ",default = "No" )):
    if(simplified == "Yes"):
        print  f, " = "  , f.taylor(x, x0, n).full_simplify()
    else:
        print  f, " = "  , f.taylor(x, x0, n)
The webpage https://github.com/sagemath/cloud/wiki/Teaching contains a list of links to several courses (such as Calculus, Combinatorics, Statistical Computing, Cryptography, Computer Systems Security, Experimental Gravitational Wave Physics, Linear Algebra, Differential Equations, Abstract Algebra, and many others) that are using Sage Math See also: [1], [2], and [3].
Some great references that motivated this work are: [4, 6, 11, 12, 15].

Chapter 2
Using Sage Math as a Calculator

Sage Math can easily be used as a calculator, one that has lots of ā€œfeatures.ā€ My favorite one is the fact that you can program your own algorithms in a programming language that is very easy to l...

Table of contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Dedication
  5. Preface
  6. Chapter 1: Introduction
  7. Chapter 2: Using Sage Math as a Calculator
  8. Chapter 3: Introduction to Programming in Sage
  9. Chapter 4: Sage Interacts for Numerical Methods
  10. References
  11. Index
  12. End User License Agreement