Section 1.1 Using Sage
Sage cells allow us to evaluate expressions within the webpage we are reading, as long as we are online, and Sage cells can be found throughout this booklet. You can return here as often as you like to access Sage cells in order to help with your geometry work.
Sage uses the standard operators +, , *, /, and ^ for addition, subtraction, multiplication, division, and exponentiation. A common user error (of mine) is to omit the multiplication symbol. To input the expression \(3x+7\) into Sage, type “3*x+7”. For insance, we can ask Sage to evaluate
by typing the following into the Sage cell below and hitting the Evaluate button (or typing shiftreturn).
We will be interested in computing with complex numbers. In Sage, represent \(i\) with the capital letter I
. Let's evaluate the following division in a sage cell:
Notice Sage prefers to output its complex numbers in Cartesian form \(bi + a\text{.}\)
Sage inputs for some important constants are:

I
for \(i\) 
pi
for \(\pi\text{,}\) and 
e
for \(e\text{.}\)
Sage uses the following commands to provide useful information about a complex number:

abs(z)
tells us the modulus of \(z\text{,}\) \(z\text{.}\) 
arg(z)
tells us the argument of \(z\text{,}\) \(\text{arg}(z)\) (in radians, between \(\pi\) and \(\pi\)). 
real_part(z)
andimag_part(z)
give the real and imaginary parts of \(z\text{.}\) 
conjugate(z)
tells us the conjugate of \(z\text{,}\) \(\overline{z}\text{.}\)  For a numerical approximation to a number, such \(\text{arg}(3+2i)\text{,}\) type
n(arg(3+2*I,digits=4))
.
Displaying Sage Output.
We can give names to quantities, and we can create new lines in a Sage cell by pressing Return
(or Enter
) and then typing additional commands. Consider the following Sage cell, which defines two points \(z\) and \(w\text{,}\) their product, which we call \(u\text{,}\) and their quotient, which we call \(v\text{.}\) What happens when you evaluate the cell?
Nothing! Well, Sage evaluated \(u\) and \(v\text{,}\) but did not display the results. If you're in a hurry and want to know the value of \(u\text{,}\) you can add a line at the bottom of the above cell that is simply u
. When you evaluate again, the output should read 11*I + 3. This is \(zw\text{.}\)
Once \(u\) and \(v\) are defined (and evaluated in the cell above), subsequent cells on your page, such as the one below, will use those values until these variables are assigned differernt values. We note that if you reload this webpage, work you've done in Sage cells will be lost.
One can use the print()
command to create nice output: