All published worksheets from http://sagenb.org
Image: ubuntu2004
SAGE for HACC-Math 010
Software for Algebra and Geometry Experimentation
A practical alternative to
Maple, Mathematica, and Matlab
Sage is 100% Free and Open Source Software
while Mathematica, Matlab, and Maple are very expensive.
Main website: sagemath.org
History
SAGE = Python + Local Web Interface + Tons of Work
What is Sage? (according to W. Stein)
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! )
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.
Now we can further process that last result using the following method:
Handling Exponents using the caret ^ symbol or double asterisk **.
SQUARE ROOTS
Use the square root function sqrt( )
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.
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.
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.
PI and the SEMICOLON
SAGE can be used do display '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.
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:
DIVIDING POLYNOMIALS
This is a bit tricky: How does one tell SAGE how to divide two polynomials? Answer: It depends on (1) SAGE's default format and (2) on what format you want it to be displayed. SAGE's default format is try to write things in simplest form w/c means as a factored form. So sometimes, one would think it's not doing anything.
Won't explain this one in detail. You can study it in the manual for details. The important thing is this is how you can divide and format the result as a sum of terms in descending order.
This is the format we want. The remainder is 432. Hence, we can write the overall result also as:
2*x^4 - 10*x^3 + 28*x^2 - 8*x + 96 + 432/(x-5)
Another way to do this would be to use the "cryptic" code. W(P(x)) says consider P(x) as a polynomial. Then take the quotient plus the remainder using (x-5). Oh well....
NEGATIVE EXPONENTS are automatically converted to (simplified to) positive exponents
GREATEST COMMON FACTOR(DENOMINATOR)
LEAST COMMON MULTIPLE (LCM)
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.
FACTORING
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.
We use solve(equation, variable to be solved). Note: use parenthesis ( ) not square brackets [ ].
Or we can directly put the equation inside the solve( put equation here, put variable to be solved here) like this:
PLOTTING
An Example of a 3D plot you can play around with!
ANIMATION where time is involved!
Visit: http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.plot.animate.Animation-class.html
THE END