As you work on COMP 150 this week,
Let's get warmed up to the course content by launching into Chapter 1 of our Sage text. The point is to get a feel for what the the computer-algebra system (CAS) Sage can do without getting too bogged down in every little detail.
If you go to the section of our Blackboard page on "Getting Started: COMP 150," you'll see
Sage: Let's Dive In! Right Now! (Sage for Undergraduates, P. xvii) As Gregory Bard says: -- Without any hesitation whatsoever, open up a web browser at this very moment. Type in the following URL: https://sagecell.sagemath.org/ . You have now connected to "The Sage Cell Server." Now you shall see a large window (called a cell) and a big button marked "Evaluate." In that cell, type the following solve( x^2 - 16 == 0, x ), and then click "Evaluate." You should receive back the answer [x == -4, x == 4], which is clearly the correct set of two solutions to the equation x^2 - 16 = 0. You have now solved your first math problem with Sage. Congratulations. Welcome to Sage!
What do the 23 instructions below do? Try to guess! Then copy and paste (or type) the instructions below into the Sage Cell (without the 23 numbers), and either hit the evaluate button, or (equivalently) type shift-enter. Think very carefully: Why do you think these instructions do what they do?
You have given Sage a variety of instructions. You typed them into the Sage Cell and something happened.
There's a lot going on in the many experiments you've run already today. Do you have a very general feel for the commands and keystrokes? Discuss your conjectures with colleagues throughout your explorations in this course.
Can some of these calculations be done in Scratch? If so, which ones? And how?
What happens if you include multiple instructions in the cell and then hit evaluate? For example:
How do these entries in the Sage Cell compare? First try
x = 4 xNow delete the x = 4 in the Sage Cell and go back to evaluating just this:
x. Does Sage remember a value for x?
We got an error when we tried
y. But what about if the Sage Cell contains these two instructions:
y = 4 y?
Where are single equals sign (=) and double equals sign (==) used in this exploration? Which syntax (arrangement of typographic elements) corresponds to assignment of a value to a variable?
Can you explain the behavior of these instructions when evaluated together in the Sage Cell?
x = 4 2*x == 8? What about
x = 4 2*x == 9?
Sage is using different colors for the parentheses as you type out the command left to right? Sage is HELPING you to balance the parentheses.
Where are square brackets used erroneously and apparently correctly in this exploration?
You can find out what a Sage command like show means by typing
in the Sage Cell and hitting the evaluate button or typing shift-enter.
In general, type help, then the command name in parentheses to get help on any Sage command. Note that the descriptions of the commands are pretty technical. You may prefer to get a simpler and shorter definition in your textbook Appendix F (Index of Commands by Name and Section). However, note that the definition of show on P. 329 does not appear to be relevant to the examples here!
Unfortunately, the Sage Cell doesn't keep track of the commands you've given. Jot down a couple of key insights in your class notebook about commands you've tried. You'll be able to keep track of commands you've given in a Sage session when we move into the SageMathCloud.