Skip to main content
\( \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section1.5How to Use Computation

This text is advertised as having interactive computation, but so far any computation has been your own. How does it fit in? We'll skip ahead slightly here to see how this will work.

In the interactive version of this text, the areas below are called Sage cells, or cells for short. Assuming you're connected to the internet, this very first cell will use SageMath (usually just called Sage) to check whether this number leaves a fraction when reduced, or whether it reduces to an integer. Click “Evaluate” to try it out.

Go ahead, try changing the numbers and clicking the evaluate button again.

As we go through the text, you'll see lots of opportunities to use Sage. Sometimes I'll give you the opportunity to learn a little bit about how to use it in Sage notes, such as the following one.

Sage note1.5.1About Sage notes

Sage notes will teach you useful things about basic programming, or more general facts about Sage and Python, the language Sage is based on.

Let's try another computational cell. We haven't defined prime numbers yet (see Chapter 6), but I figure you know what they are. Here you can check whether an integer is prime.

Sage note1.5.2Using commands in Sage cells

Assuming you are using this online, you can put any legitimate Sage command in the cells above. (Try integrate(x^3,x) if you know some calculus.) Or you use these commands in your own Sage worksheet at your local Sage server or in the SageMathCloud, so that you can save your work!

If you are using an offline or hard copy version, I still highly recommend sifting through some of the code and commands; much of it will enlighten the reader. (Then try it out online or on your local computer!)

Finally, let's test some conductor ideas using technology. In the cell below, Sage will automatically list all the nonnegative numbers up to \(n\) that can be written as \(n=ax+by\) for nonnegative integers \(x\) and \(y\). The default values are the \(a=3,b=4\) combination.

Notice that with the one tried above we definitely are getting the same answers. Also notice that the algorithm I used in the code is very naive – I just listed all possible combinations under a certain size. It would be interesting to use this to try to verify patterns you may have noticed about the precise size of the conductor, and when it exists.