Calc II. College of the Atlantic. 2011.
This is based on a similar worksheet written by Professor Dana Ernst of Plymouth State University for his Calc II students.
The point to this worksheet is to introduce you to some of the basic commands in Sage. Often a good way to learn how to use things like Sage is to copy examples from someone else, and then change them to fit what you need.
Throughout this worksheet I have included some blank "Sage cells" in which you can type examples and try new things. To evaluate a cell, just click on the cell and then click "evaluate." You should work through this worksheet and try evaluating the cells that I've made. Explore and experiment.
There are also a few specific things that I'd like you to do as you work through this worksheet. These tasks are highlighted in purple.
{{{id=51| /// }}}
Sage can do basic (and some not-so-basic) calculations. Here are some examples. Try evaluating these cells, and try changing values to see what happens.
{{{id=40| 4*4 /// 16 }}} {{{id=96| 7^3 /// 343 }}} {{{id=97| 3+4+5 /// 12 }}} {{{id=98| sin(1) /// sin(1) }}}Hmm.... Note that sage just told us that sin(1) is sin(1). This is true, but might not be useful if you're looking for a numerical answer. You can force a numerical answer as follows:
{{{id=100| n(sin(1)) /// 0.841470984807897 }}} {{{id=108| n(pi) /// 3.14159265358979 }}} {{{id=109| n(pi,digits=100) /// 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 }}}Some Editing Basics
Inserting new Sage cells
You can insert a new cell above or below any existing cell or block of text. To insert a new cell, put your cursor above (respectively, below) the cell or block of text where you want to insert a new cell until you see a purple horizontal line pop up. Click on this horizontal line to produce a new Sage cell. Try that just below right now and then type in some other complicated expression of numbers and then click "evaluate."
Inserting a new block of text
You can also insert a new block of text (also called an "html cell") above or below any existing Sage cell or other block of text. To insert a new html cell, you Shift+click the purple horizontal line that pops up instead of just clicking on it. This will pop open a tiny text editor for you to type in. There are lots of things you can do inside an html block, but for now, we will keep it simple. You can always edit an existing html cell by simply double-clicking on the corresponding cell. After you are done editing an html cell, click "Save changes."
Add an html cell at the very top of this worksheet and type in your names.
Add a new cell below this block of text, and have sage determine the numerical value of log(7)
Sage can also plot functions. Here are some examples:
{{{id=103| plot( x^2, (x,0,4) ) ///Note in the above example that sage knows what "pi" is. Note also that I needed to use a * between the 2 and the pi so that sage knows that I want to multiply pi by 2. If I don't have the *, it will give an error. (Try it and see.)
When making plots it sometimes takes a little bit of work to adjust ranges so that the key behavior of the function is evident.
{{{id=43| plot(x*e^-x, (x,-5,5)) ///This function explodes downward for negative x. This makes the scale such that we can't see what's going on for positive x. Let's change the x range.
{{{id=63| plot( x*e^-x, (x,-1,5) ) ///This looks better.
Let's try another example:
{{{id=106| plot( (x^2 - 2*x + 4)/(x-2) , (x,-10,15) ) ///The problem here is that there is a vertical asymptote at x=2, since the function divides by zero. We can make the plot look better and be more useful by limiting the vertical range as follows:
{{{id=44| plot( (x^2 - 2*x + 4)/(x-2) , (x,-10,15), ymin=-15,ymax=15,) ///Create some new cells below and make nice plots of the following two functions:
By "nice," I mean that the ranges should be chosen so that the key behavior of the functions is clear.
{{{id=94| /// }}}
Sage also knows how to take derivatives. Here are some examples:
{{{id=24| diff( x^3, x) /// 3*x^2 }}} {{{id=25| diff( sin(x^2), x ) /// 2*x*cos(x^2) }}} {{{id=26| diff( x^3 + 4*x^2 - 7, x ) /// 3*x^2 + 8*x }}}Use sage to find the derivative of the following functions:
{{{id=84| /// }}} {{{id=85| /// }}}
Sage can do lots more than plot and take derivatives, as we will see in the upcoming weeks. If you aren't impressed yet, you will be soon.
When you are done, you should click "Save" at the top right of the worksheet. If you click "Save & quit", the worksheet will close and you will be returned to your "home" directory. Just click "Save" for now.
Please email me a copy of this worksheet. To this, you should select "File..." at the top left of the worksheet. Select "Save worksheet to file..." and save the worksheet some place on your computer (and remember where you put it). Name the file something like, "Lab 1 (your names)" (without the quotes). Send that file to me as an attachment to an email. I only need one worksheet per group.
When you are done, click on "save and quit" on the top of the page.
{{{id=95| /// }}} {{{id=107| /// }}}