using-sage.rst
author Nishanth Amuluru <nishanth@fossee.in>
Wed, 06 Oct 2010 14:45:59 +0530
changeset 214 8b08fc88d5a0
parent 196 966be1a847c9
permissions -rw-r--r--
Added questions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     1
========
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     2
 Script
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     3
========
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     4
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     5
{{{ show the welcome slide }}}
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     6
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     7
Welcome to this tutorial on using Sage.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     8
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     9
{{{ show the slide with outline }}} 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    10
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    11
In this tutorial we shall quickly look at a few examples of the areas
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    12
(name the areas, here) in which Sage can be used and how it can be
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    13
used.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    14
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    15
{{{ show the slide with Calculus outline }}} 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    16
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    17
Let us begin with Calculus. We shall be looking at limits,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    18
differentiation, integration, and Taylor polynomial.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    19
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    20
{{{ show sage notebook }}}
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    21
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    22
We have our Sage notebook running. In case, you don't have it running,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    23
start is using the command, ``sage --notebook``.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    24
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    25
To find the limit of the function x*sin(1/x), at x=0, we say
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    26
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    27
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    28
   lim(x*sin(1/x), x=0)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    29
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    30
We get the limit to be 0, as expected. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    31
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    32
It is also possible to the limit at a point from one direction. For
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    33
example, let us find the limit of 1/x at x=0, when approaching from
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    34
the positive side.
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    35
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    36
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    37
    lim(1/x, x=0, dir='above')
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    38
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    39
To find the limit from the negative side, we say,
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    40
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    41
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    42
    lim(1/x, x=0, dir='above')   
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    43
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    44
Let us now see how to differentiate, using Sage. We shall find the
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    45
differential of the expression ``exp(sin(x^2))/x`` w.r.t ``x``. We
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    46
shall first define the expression, and then use the ``diff`` function
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    47
to obtain the differential of the expression.
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    48
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    49
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    50
    var('x')
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    51
    f = exp(sin(x^2))/x
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    52
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    53
    diff(f, x)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    54
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    55
We can also obtain the partial differentiation of an expression w.r.t
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    56
one of the variables. Let us differentiate the expression
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    57
``exp(sin(y - x^2))/x`` w.r.t x and y.
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    58
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    59
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    60
    var('x y')
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    61
    f = exp(sin(y - x^2))/x
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    62
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    63
    diff(f, x)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    64
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    65
    diff(f, y)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    66
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    67
Now, let us look at integration. We shall use the expression obtained
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    68
from the differentiation that we did before, ``diff(f, y)`` ---
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    69
``e^(sin(-x^2 + y))*cos(-x^2 + y)/x``. The ``integrate`` command is
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    70
used to obtain the integral of an expression or function.
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    71
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    72
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    73
    integrate(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    74
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    75
We get back the correct expression. The minus sign being inside or
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    76
outside the ``sin`` function doesn't change much. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    77
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    78
Now, let us find the value of the integral between the limits 0 and
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    79
pi/2. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    80
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    81
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    82
    integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    83
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    84
Let us now see how to obtain the Taylor expansion of an expression
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    85
using sage. Let us obtain the Taylor expansion of ``(x + 1)^n`` up to
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    86
degree 4 about 0.
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
    87
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    88
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    89
    var('x n')
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    90
    taylor((x+1)^n, x, 0, 4)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    91
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    92
This brings us to the end of the features of Sage for Calculus, that
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    93
we will be looking at. For more, look at the Calculus quick-ref from
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    94
the Sage Wiki. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    95
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    96
Next let us move on to Matrix Algebra. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    97
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    98
{{{ show the equation on the slides }}}
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    99
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   100
Let us begin with solving the equation ``Ax = v``, where A is the
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   101
matrix ``matrix([[1,2],[3,4]])`` and v is the vector
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   102
``vector([1,2])``. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   103
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   104
To solve the equation, ``Ax = v`` we simply say
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   105
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   106
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   107
    x = solve_right(A, v)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   108
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   109
To solve the equation, ``xA = v`` we simply say
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   110
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   111
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   112
    x = solve_left(A, v)
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   113
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   114
The left and right here, denote the position of ``A``, relative to x. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   115
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   116
#[Puneeth]: any suggestions on what more to add?
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   117
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   118
Now, let us look at Graph Theory in Sage. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   119
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   120
We shall look at some ways to create graphs and some of the graph
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   121
families available in Sage. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   122
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   123
The simplest way to define an arbitrary graph is to use a dictionary
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   124
of lists. We create a simple graph by
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   125
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   126
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   127
  G = Graph({0:[1,2,3], 2:[4]})
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   128
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   129
We say 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   130
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   131
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   132
  G.show()
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   133
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   134
to view the visualization of the graph. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   135
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   136
Similarly, we can obtain a directed graph using the ``DiGraph``
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   137
function. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   138
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   139
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   140
  G = DiGraph({0:[1,2,3], 2:[4]})
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   141
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   142
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   143
Sage also provides a lot of graph families which can be viewed by
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   144
typing ``graph.<tab>``. Let us obtain a complete graph with 5 vertices
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   145
and then show the graph. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   146
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   147
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   148
  G = graphs.CompleteGraph(5)
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   149
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   150
  G.show()
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   151
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   152
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   153
Sage provides other functions for Number theory and
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   154
Combinatorics. Let's have a glimpse of a few of them.  
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   155
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   156
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   157
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   158
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   159
  prime_range(100, 200)
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   160
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   161
gives primes in the range 100 to 200. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   162
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   163
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   164
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   165
  is_prime(1999) 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   166
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   167
checks if 1999 is a prime number or not. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   168
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   169
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   170
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   171
  factor(2001)
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   172
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   173
gives the factorized form of 2001. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   174
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   175
::
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   176
196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   177
  C = Permutations([1, 2, 3, 4])
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   178
  C.list()
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   179
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   180
gives the permutations of ``[1, 2, 3, 4]``
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   181
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   182
::
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   183
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   184
  C = Combinations([1, 2, 3, 4])
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   185
  C.list()
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   186
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   187
gives all the combinations of ``[1, 2, 3, 4]``
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   188
  
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   189
That brings us to the end of this session showing various features
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   190
available in Sage. 
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   191
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   192
{{{ Show summary slide }}}
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   193
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   194
We have looked at some of the functions available for Linear Algebra,
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   195
Calculus, Graph Theory and Number theory.   
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   196
966be1a847c9 Minor changes to using Sage.
Puneeth Chaganti <punchagan@fossee.in>
parents: 144
diff changeset
   197
Thank You!