Software for Algebra and Geometry Experimentation
while Mathematica, Matlab, and Maple are very expensive.
SAGE = Python + Local Web Interface + Tons of Work
A GOOD CALCULATOR - but a lot better than others
We can do simple arithmetic with SAGE:
Use: * for multiplication, + for addition, - for subtraction, / divide, ^ or ** for exponentiation
Place mouse on the cell below. Then press "evaluate" that appears below this cell. Or press Shift-Enter. (Note: don't put the equals (=) sign! )
-14 -14 |
20 20 |
51 51 |
3/17 3/17 |
-9 -9 |
At the very least, it can do what any calculator can do. SAGE will try to perform everything according to the standard ORDER of operations.
FRACTIONS
It can handle fractions symbolically (manipulate algebraically as if all are symbols) and numerically. More on the difference later. We will use the pound sign "#" to place a comment within the cell without affecting what you're calculating. SAGE-python knows this.
29/320 29/320 |
233/45 233/45 |
Now we can further process that last result using the following method:
5 5 |
8 8 |
233/45 233/45 |
|
|
Handling Exponents using the caret ^ symbol or double asterisk **.
17179869184 17179869184 |
17179869184 17179869184 |
39 39 |
-30^x + x^2 + 12*x + 9 -30^x + x^2 + 12*x + 9 |
SQUARE ROOTS
Use the square root function sqrt( )
2 2 |
sqrt(5) sqrt(5) |
Notice that if it can't get the exact value of the square root of 5, it will handle it just symbolically. And it would seem like it didn't do anything. You see it simply wants to try to maintain an exact value. To force it to perform and provide at least an estimate of the square root, just add a decimal point so that SAGE knows your input is a decimal and you want it to give an answer in decimal form. Then in the next cell we introduce the number "n" operator to control the number of digits of our final answer/estimate.
2.23606797749979 2.23606797749979 |
Then in the next cell we introduce the number "n" operator to control the number of digits of our final answer/estimate. This is even better.
2.236 2.236 |
5.177777778 5.177777778 |
sqrt(x^3) sqrt(x^3) |
|
Using the UNDERSCORE "_ " and the SHOW( ) functions or commands:
We use the underscore "_" symbol to mean "use the last result" OR more precisely, the result of the last cell that was evaluated. This is a really great time-saver as it aids in better manipulation w/o retyping longer and complicated expressions if they happen to be one.
6 6 |
8 8 |
sqrt(x^3) sqrt(x^3) |
sqrt(x^3) + x^2 + 1 sqrt(x^3) + x^2 + 1 |
|
(sqrt(x^3) + x^2 + 1)^4/x^(2/3) (sqrt(x^3) + x^2 + 1)^4/x^(2/3) |
|
pi pi |
|
PI and the SEMICOLON
SAGE can be used do display \pi's approximate value up to a certain number of digits. Note: we use a semicolon to separate the instructions or commands we want SAGE to do for us. This means we can do multiple instructions within one cell.
3.14 3.1415926535897932384626433832795028841971693993751058209749445923078164\ 06286208998628034825342117068 3.14 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 |
(C, r) (C, r) |
|
BASIC ALGEBRA: VARIABLES, EXPRESSIONS, AND EQUATIONS
In SAGE, x is considered a variable. To use other letters as variables, one must "declare" them using the var command:
|
|
ASSIGNing (using one equal sign =) a whole expression to another letter makes it easier to manipulate expressions. We demonstrate this below:
pi + sqrt(2) + y^z + 5/3 pi + sqrt(2) + y^z + 5/3 |
|
|
|
|
pi + sqrt(2) + 4*pi^(5/2)*sqrt(2)/x^7 + y^z + 5/3 pi + sqrt(2) - 4*pi^(5/2)*sqrt(2)/x^7 + y^z + 5/3 4/3*(3*pi + 3*sqrt(2) + 3*y^z + 5)*pi^(5/2)*sqrt(2)/x^7 pi + sqrt(2) + 4*pi^(5/2)*sqrt(2)/x^7 + y^z + 5/3 pi + sqrt(2) - 4*pi^(5/2)*sqrt(2)/x^7 + y^z + 5/3 4/3*(3*pi + 3*sqrt(2) + 3*y^z + 5)*pi^(5/2)*sqrt(2)/x^7 |
|
|
|
14 14 |
2 2 |
15*x^2 15*x^2 |
36 36 |
40389988416 40389988416 |
69720375229712477164533808935312303556800 69720375229712477164533808935312303556800 |
Here's a "trick" you can use to get LCM of two variable expressions like x^2 and 2x^5. First, make them the denominators of unit fractions (1 over your expression). Pretend you will add them all. Then use the factor command to force SAGE to combine them into one rational expression. Then you can also use "show" to get a better view of the result. Finally, you can see that the LCD (or our LCM) here is 2x^5. We have used the "ladder method" to do this (see your notes).
1/2*(2*x^3 + 1)/x^5 1/2*(2*x^3 + 1)/x^5 |
|
[] [] |
SOLVING EQUATIONS
We use the double equal signs "= =" to write an equation. The single equal sign "=" as in some examples above mean just assigning an expression to, say, a variable so we can reuse that expression without retyping it.
Let us say we want to solve the following: 3x +4 = -8x- 5. Then we would type this as:
[x == (-9/11)] [x == (-9/11)] |
[x == -2, x == 0] [x == -2, x == 0] |
[x == (7/2), x == (-4/3)] [x == (7/2), x == (-4/3)] |
|
|
PLOTTING
|
|
|
|
|
|
|
|
|
|
|
Traceback (click to the left of this block for traceback) ... SyntaxError: invalid syntax Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_65.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("UFM6IEZlZWwgZnJlZSB0byBjb250YWN0IG1lIGluIG15IGVtYWlsIG9uIE1NTC4="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpRCG8nj/___code___.py", line 2
PS: Feel free to contact me in my email on MML.
^
SyntaxError: invalid syntax
|
|
|