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
8+4⋅525
by typing the following into the Sage cell below and hitting the Evaluate button (or typing shift-return).
xxxxxxxxxx
(3+4*5^2)/2
I
. Let's evaluate the following division in a sage cell:
3+2i4+i.
xxxxxxxxxx
(3+2*I)/(4+I)
-
I
for i -
pi
for π, and -
e
for e.
-
abs(z)
tells us the modulus of z, |z|. -
arg(z)
tells us the argument of z, arg(z) (in radians, between −π and π). -
real_part(z)
andimag_part(z)
give the real and imaginary parts of z. -
conjugate(z)
tells us the conjugate of z, ¯z. - For a numerical approximation to a number, such arg(3+2i), 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 pressingReturn
(or Enter
) and then typing additional commands. Consider the following Sage cell, which defines two points z and w, their product, which we call u, and their quotient, which we call v. What happens when you evaluate the cell?
xxxxxxxxxx
z=3+I
w=2+3*I
u=z*w
v=z/w
u
. When you evaluate again, the output should read 11*I + 3. This is zw.
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:
xxxxxxxxxx
print("If z =", z, "and w =", w, "then")
print ("z*w =", u, "and z/w =", v)