plot(x^3, (x, -2, 2))
Sage has variables + symbolic expressions AND functions. They look the same, but are different.
The variable x
is predefined, everything else must be declared.
We want the right hand side.
An alternative:
How would we know about this alternative? Immediate help on solve()
. (Question-mark, then the TAB key.)
Notice how a function prints differently than an expression.
Evaluation (exact, approximate), graphing, differentiation, integration. Note object-oriented syntax.
Question: How would we learn about these methods
?
Answer: "Tab-completion" on f
. f-dot-tab
Suppose you know nothing about how to do linear algebra in Sage. (Maybe this is not a difficult supposition!)
If you can make a matrix and a vector, then you are off and running. Here they are, with entries from the field of rational numbers.
Then tab-completion and ?-tab-help will get you up to speed quickly.
And the Sage Quick Reference sheets ("quickrefs") are very handy.
There is lots of documentation. The "Reference Manual" is about 4000 pages as a PDF and not organized for a beginner. The "Tutorial" has some fairly advanced mathematics in it. The "PREP Tutorials" are new and a great way to get started.
Helplink in upper-right corner gives a pop-up window
Tutorial,
Thematic Tutorials,
Constructions,
Reference Manual
Filedrop-down box -
Save worksheet to a file...makes a
*.sws
fileUploadlink/button - provide URL or Browse to local file to pull in a worksheet
Publishon a server
Shareon a server
Upload Now: http://buzzard.ups.edu/kcexpo.sws
Try the following exercise, with minimal guidance.
Theorem (from Algebraic Graph Theory):
The number of walks of length \(k\), between vertices \(u\) and \(v\) of a graph, is the \((u,v)\) entry of \(A^k\), where \(A\) is the adjacency matrix of the graph.
Question: How many walks are there of length \(7\) between two vertices of the complete bipartite graph \(K_{6,9}\) that lie in different halves
of the bipartition?
1. Build the complete bipartite graph \(K_{6,9}\), whose edges join every vertex of a \(6\)-set to every vertex of a \(9\)-set. Save this graph as the variable G
. Plot a picture of the graph. (Hint: try out ]]>
)
2. Construct and save the adjacency matrix of the graph as the variable A
.
3. Construct and save the seventh power of the adjacency matrix of the graph as the variable B
.
4. Output the entry of B
that corresponds to two vertices from different halves
of the bipartition. (Hint: use your picture to decide which vertices to use. Matrix indexing starts counting from 0
and brackets, ([, ]
), are used to index into a matrix.)
Did you get \(6^3\,9^3 = 157\,464\) walks of length \(7\)? How about walks of length \(8\) between the same two vertices?
Extra credit: write a one-line statement to get the answer.
Extra, extra credit: write a Python function that accepts a graph \(G\), and values of \(k\), \(u\), \(v\) as input and returns the number of walks.
This worksheet available at: http://buzzard.ups.edu/talks.html