Minor changes to using Sage.
authorPuneeth Chaganti <punchagan@fossee.in>
Wed, 22 Sep 2010 22:11:00 +0530
changeset 196 966be1a847c9
parent 195 e8a251048213
child 197 97d859b70f51
Minor changes to using Sage.
using-sage.rst
--- a/using-sage.rst	Wed Sep 22 15:22:21 2010 +0530
+++ b/using-sage.rst	Wed Sep 22 22:11:00 2010 +0530
@@ -22,7 +22,8 @@
 We have our Sage notebook running. In case, you don't have it running,
 start is using the command, ``sage --notebook``.
 
-To find the limit of the function x*sin(1/x), at x=0, we say::
+To find the limit of the function x*sin(1/x), at x=0, we say
+::
 
    lim(x*sin(1/x), x=0)
 
@@ -30,18 +31,21 @@
 
 It is also possible to the limit at a point from one direction. For
 example, let us find the limit of 1/x at x=0, when approaching from
-the positive side.::
+the positive side.
+::
 
     lim(1/x, x=0, dir='above')
 
-To find the limit from the negative side, we say,::
+To find the limit from the negative side, we say,
+::
 
     lim(1/x, x=0, dir='above')   
 
 Let us now see how to differentiate, using Sage. We shall find the
 differential of the expression ``exp(sin(x^2))/x`` w.r.t ``x``. We
 shall first define the expression, and then use the ``diff`` function
-to obtain the differential of the expression.::
+to obtain the differential of the expression.
+::
 
     var('x')
     f = exp(sin(x^2))/x
@@ -50,7 +54,8 @@
 
 We can also obtain the partial differentiation of an expression w.r.t
 one of the variables. Let us differentiate the expression
-``exp(sin(y - x^2))/x`` w.r.t x and y.::
+``exp(sin(y - x^2))/x`` w.r.t x and y.
+::
 
     var('x y')
     f = exp(sin(y - x^2))/x
@@ -62,7 +67,8 @@
 Now, let us look at integration. We shall use the expression obtained
 from the differentiation that we did before, ``diff(f, y)`` ---
 ``e^(sin(-x^2 + y))*cos(-x^2 + y)/x``. The ``integrate`` command is
-used to obtain the integral of an expression or function.::
+used to obtain the integral of an expression or function.
+::
 
     integrate(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y)
 
@@ -70,13 +76,15 @@
 outside the ``sin`` function doesn't change much. 
 
 Now, let us find the value of the integral between the limits 0 and
-pi/2. ::
+pi/2. 
+::
 
     integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2)
 
 Let us now see how to obtain the Taylor expansion of an expression
 using sage. Let us obtain the Taylor expansion of ``(x + 1)^n`` up to
-degree 4 about 0.::
+degree 4 about 0.
+::
 
     var('x n')
     taylor((x+1)^n, x, 0, 4)
@@ -93,27 +101,97 @@
 matrix ``matrix([[1,2],[3,4]])`` and v is the vector
 ``vector([1,2])``. 
 
-To solve the equation, ``Ax = v`` we simply say::
+To solve the equation, ``Ax = v`` we simply say
+::
 
     x = solve_right(A, v)
 
-To solve the equation, ``xA = v`` we simply say::
+To solve the equation, ``xA = v`` we simply say
+::
 
     x = solve_left(A, v)
 
 The left and right here, denote the position of ``A``, relative to x. 
 
-
+#[Puneeth]: any suggestions on what more to add?
 
 Now, let us look at Graph Theory in Sage. 
 
-Graph: G = Graph({0:[1,2,3], 2:[4]})
-Directed Graph: DiGraph(dictionary)
-Graph families: graphs. tab
-Invariants: G.chromatic polynomial(), G.is planar()
-Paths: G.shortest path()
-Visualize: G.plot(), G.plot3d()
-Automorphisms: G.automorphism group(), G1.is isomorphic(G2), G1.is subgraph(G2)
+We shall look at some ways to create graphs and some of the graph
+families available in Sage. 
+
+The simplest way to define an arbitrary graph is to use a dictionary
+of lists. We create a simple graph by
+::
+
+  G = Graph({0:[1,2,3], 2:[4]})
+
+We say 
+::
+
+  G.show()
+
+to view the visualization of the graph. 
+
+Similarly, we can obtain a directed graph using the ``DiGraph``
+function. 
+::
+
+  G = DiGraph({0:[1,2,3], 2:[4]})
+
+
+Sage also provides a lot of graph families which can be viewed by
+typing ``graph.<tab>``. Let us obtain a complete graph with 5 vertices
+and then show the graph. 
+::
+
+  G = graphs.CompleteGraph(5)
+
+  G.show()
+
+
+Sage provides other functions for Number theory and
+Combinatorics. Let's have a glimpse of a few of them.  
+
+
+::
 
-Now let us look at bits and pieces of Number theory, combinatorics, 
+  prime_range(100, 200)
+
+gives primes in the range 100 to 200. 
+
+::
+
+  is_prime(1999) 
+
+checks if 1999 is a prime number or not. 
+
+::
+
+  factor(2001)
+
+gives the factorized form of 2001. 
+
+::
 
+  C = Permutations([1, 2, 3, 4])
+  C.list()
+
+gives the permutations of ``[1, 2, 3, 4]``
+
+::
+
+  C = Combinations([1, 2, 3, 4])
+  C.list()
+
+gives all the combinations of ``[1, 2, 3, 4]``
+  
+That brings us to the end of this session showing various features
+available in Sage. 
+
+{{{ Show summary slide }}}
+
+We have looked at some of the functions available for Linear Algebra,
+Calculus, Graph Theory and Number theory.   
+
+Thank You!