Download this introduction

Transcript
That is a list of six answers, because that degree six polynomial has six roots. It was easy to read this
time, but you can also access each answer one at a time. Instead, we type
answer = solve( x^6 - 21*x^5 + 175*x^4 - 735*x^3 + 1624*x^2 - 1764*x + 720 == 0, x)
and then we can type print answer[0] or print answer[1] to get the first or second entries. To get the
fifth entry of that list, we’d type print answer[4]. This is because SAGE is built out of Python, and
Python numbers its lists from 0 and not from 1. There are reasons for this, based on some very old computer
languages.
Now consider this problem, suggested by Dr. Grout. To solve
p+q
=
9
qy + px
= −6
2
2
=
24
p
=
1
qy + px
we would type
var(’p q y’)
eq1 = p+q == 9
eq2 = q*y + p*x == -6
eq3 = q*y^2 + p*x^2 == 24
eq4 = p == 1
solve( [eq1, eq2, eq3, eq4 ], p, q, x, y )
which produces
[[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) 2/3], [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y ==
-1/6*sqrt(2)*sqrt(5) - 2/3]]
As you can see, that is a list of lists, again using square brackets and commas. Clearly, that is a very
hard to read mess. Using the technique that we learned when analyzing the degree six polynomial above,
we replace the last line with
answer=solve( [eq1, eq2, eq3, eq4 ], p, q, x, y )
Now we can type
print answer[0]
print answer[1]
and we get
[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) 2/3]
[p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(2)*sqrt(5) 2/3]
This is SAGE’s way of telling you:
√
Solution 1: p = 1, q = 8, x = − 43 10 − 23 , y =
Solution 2:
p = 1, q = 8, x =
4
3
√
10 − 23 , y = −
√
10
6
−
2
3
−
2
3
√
10
6
Since there are only two answers, we cannot ask for a third. In fact, if we type print answer[2] then
we get
33