All published worksheets from http://sagenb.org
Image: ubuntu2004
Project MOSAIC Joint Math Meetings
Ancillary Workshop:
Sage, Calculus, and Modeling
Presenting:
Karl-Dieter Crisman, Gordon College (MA)
Abstract:
This introduction to Sage will be short and sweet. We'll talk a little bit about how to use the notebook and the range of functionality, but focus mostly on calculus and a little bit of doing modeling. I'll also show how to use R in the notebook, and perhaps a bit of collaborative functionality in the notebook.
Thank you to the organizers for inviting me to give this talk!
We'll do the following:
- Briefly show how to log in to Sage and start a worksheet
- Demonstrate a few of the basic commands and range of functionality in Sage
- Talk about calculus and a bit of modeling
- Show how to use R in the notebook
- Maybe talk about collaboration if there is time.
We'll be fairly quick about it, as it's best to learn while doing, so let's get started!
There are many Sage servers out there, and some allow anyone to create an account.
- The 'official' family of servers at the University of Washington, like sagenb.org, are a great resource.
- Two other examples I like are the clemix server at Clemson U. and the Groundhog Day one at KAIST in Seoul.
- There are also many servers at individual colleges that allow only on-campus account creation, and the dahl.calvin.edu server for this workshop.
Basically, there is not so much to do:
- First, create an account like on a million other websites, and then log in.
- Next, make a new worksheet (there should be a link for this on the upper left).
- I'll show you live how to evaluate and create a new mathematics cell.
If you're in this workshop, you should be able to do this fairly easily.
So what can you do with Sage? Well... what do you want to do?
We can do various plots, as one would expect.
There is lots of functionality in various topics. The graph editor is nice.
But allows for more advanced usage!
Interactive examples are fun. I love doing this myself, and is the primary way I use Sage in the classroom. Can you find the pattern?
Naturally, you are here to talk about calculus. Sage has the usual functionality you'd expect from a computer algebra system.
Do you remember how to calculate
We can do computations inside of the things we are trying to learn about, and typeset them correctly. (Incidentally, to get nice formulas in between the computational cells, just double click on one of the text areas!)
I might want to find help. Tabbing and the question mark are your ways to success.
We can also try to find fits for models of various types, using one of the many components of Sage - in this case, SciPy.
Because Python, the programming language Sage is based on, is a very powerful tool, we have everything we need to import data.
Now we'll make two possible models for the data from the bomb blast in the earlier talk Danny gave.
We've now found fits for each model. Now we just extract the information and plot!
Like Danny said, which one is better?
As another example of what can be done, let's see how to use R from the notebook. All I have to do is insert '%r' at the beginning of a cell, and then everything is done in R. (It's also possible to have a whole worksheet evaluate in a given system.)
Here, I'll first load the library from the MOSAIC project's R package. You'll need internet for this, of course.
also installing the dependency ‘Hmisc’
trying URL 'http://cran.r-project.org/src/contrib/Hmisc_3.9-0.tar.gz'
Content type 'application/x-gzip' length 572432 bytes (559 Kb)
opened URL
==================================================
downloaded 559 Kb
trying URL 'http://cran.r-project.org/src/contrib/mosaic_0.2-3.tar.gz'
Content type 'application/x-gzip' length 839835 bytes (820 Kb)
opened URL
==================================================
downloaded 820 Kb
* installing *source* package ‘Hmisc’ ...
** libs
gcc -std=gnu99 -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/R/include -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -fPIC -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/ -c Hmisc.c -o Hmisc.o
sage_fortran -fPIC -g -O2 -c cidxcn.f -o cidxcn.o
sage_fortran -fPIC -g -O2 -c cidxcp.f -o cidxcp.o
sage_fortran -fPIC -g -O2 -c hoeffd.f -o hoeffd.o
sage_fortran -fPIC -g -O2 -c jacklins.f -o jacklins.o
sage_fortran -fPIC -g -O2 -c largrec.f -o largrec.o
gcc -std=gnu99 -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/R/include -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -fPIC -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/ -c mChoice.c -o mChoice.o
gcc -std=gnu99 -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/R/include -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -fPIC -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/ -c nstr.c -o nstr.o
gcc -std=gnu99 -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/R/include -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -fPIC -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/ -c ranksort.c -o ranksort.o
sage_fortran -fPIC -g -O2 -c rcorr.f -o rcorr.o
gcc -std=gnu99 -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/R/include -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -fPIC -I/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/include -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/ -c string_box.c -o string_box.o
sage_fortran -fPIC -g -O2 -c wclosest.f -o wclosest.o
gcc -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/ -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64 -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/gcc/i686-apple-darwin8/4.2.3 -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/gcc -L/usr/local/lib -lgfortran -L/Users/karl-dietercrisman/Downloads/sage-4.7.2/local/lib/R//lib -lR -Wl,-framework -Wl,CoreFoundation
** R
** inst
** preparing package for lazy loading
Loading required package: splines
** help
*** installing help indices
** building package indices ...
* DONE (Hmisc)
* installing *source* package ‘mosaic’ ...
** R
** data
** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Loading required package: survival
Loading required package: splines
Hmisc library by Frank E Harrell Jr
Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
to see overall documentation.
NOTE:Hmisc no longer redefines [.factor to drop unused levels when
subsetting. To get the old behavior of Hmisc type dropUnusedLevels().
Attaching package: 'Hmisc'
The following object(s) are masked from package:survival :
untangle.specials
The following object(s) are masked from package:base :
format.pval,
round.POSIXt,
trunc.POSIXt,
units
Creating a generic for "mean" in package "mosaic"
(the supplied definition differs from and overrides the implicit generic
in package "base": Classes: "nonstandardGenericFunction", "standardGeneric")
In method for function "var": expanding the signature to include
omitted arguments in definition: data = "missing"
Creating a new generic function for "print" in "mosaic"
** help
*** installing help indices
** building package indices ...
* DONE (mosaic)
The downloaded packages are in
‘/private/var/folders/Yy/YytEJm5VEB0+pBRD7JNLe++++TQ/-Tmp-/RtmpC1m0k6/downloaded_packages’
Updating HTML index of packages in '.Library'
Loading required package: lattice
Loading required package: grid
Loading required package: Hmisc
Loading required package: survival
Loading required package: splines
Hmisc library by Frank E Harrell Jr
Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
to see overall documentation.
NOTE:Hmisc no longer redefines [.factor to drop unused levels when
subsetting. To get the old behavior of Hmisc type dropUnusedLevels().
Attaching package: 'Hmisc'
The following object(s) are masked from package:survival :
untangle.specials
The following object(s) are masked from package:base :
format.pval,
round.POSIXt,
trunc.POSIXt,
units
Attaching package: 'mosaic'
The following object(s) are masked from package:Hmisc :
do
The following object(s) are masked from package:stats :
binom.test,
D,
median,
prop.test,
sd,
var
The following object(s) are masked from package:base :
max,
mean,
min,
print,
print.function,
sample
We can use the functions from the package immediately.
Graphics work, too, if you create a graphics device. Here, I'm using the D and fplot functions from the MOSAIC project's R package.
If you want to do a whole worksheet in R (or GAP, or Octave, or even Mathematica, if you own it) that is supported as well.
Finally, how might one use Sage in terms of pedagogy? Here, the answer is just as broad as your own interests, and I'll focus on collaboration. Here are several ideas.
- Basic 'cheat sheet' of functionality for checking answers or doing computations
For example, in a calculus class, just giving a worksheet to upload with prototypes of syntax could help a lot for routine problems.
- Students working together on a project or lab can share their worksheets with each other and/or you, allowing for easy collaboration.
Just click the 'Share' button at the top and fill in the usernames of the people who should share the worksheet! Some people use this for turning in labs, for instance.
- Publishing a worksheet so others can try it.
With this option, anyone on the server can look at your worksheet, and edit a copy for themselves. This is especially effective when you want to post something for students to try out or use for homework, or to make easily available to colleagues elsewhere.
In fact, I'm going to publish THIS VERY WORKSHEET right now on the server for this workshop! And then you can download it and try it yourself.
Well, I think that's all we have time for. Please see www.sagemath.org for more discussion of download options for all platforms, places to try out Sage, and discussion forums. We value your feedback!
This talk is also available at http://www.sagenb.org/home/pub/3932 .
Questions?