summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--using_sage/script.rst290
-rw-r--r--using_sage/slides.org95
-rw-r--r--using_sage/slides.tex140
3 files changed, 424 insertions, 101 deletions
diff --git a/using_sage/script.rst b/using_sage/script.rst
index e32ac0d..45fe950 100644
--- a/using_sage/script.rst
+++ b/using_sage/script.rst
@@ -22,58 +22,100 @@
Script
------
-{{{ show the welcome slide }}}
+.. L1
-Hello Friends. Welcome to this tutorial on using Sage.
+{{{ Show the first slide containing title, name of the production
+team along with the logo of MHRD }}}
-{{{ show the slide with outline }}}
+.. R1
-In this tutorial we shall quickly look at a few examples of using Sage
-for Linear Algebra, Calculus, Graph Theory and Number theory.
+Hello Friends and Welcome to the tutorial on 'Using Sage'.
-{{{ show the slide with Calculus outline }}}
+.. L2
+
+{{{ show the slide with objectives }}}
+
+.. R2
+
+At the end of this tutorial, you will be able to,
+
+ 1. Learn the range of things for which Sage can be used.
+ #. Know the functions used for Calculus in Sage.
+ #. Learn about graph theory and number theory using Sage.
+
+.. L3
+
+{{{ Switch to the pre-requisite slide }}}
+
+.. R3
+
+Before beginning this tutorial,we would suggest you to complete the
+tutorial on "Getting started with Sage".
Let us begin with Calculus. We shall be looking at limits,
differentiation, integration, and Taylor polynomial.
-{{{ show sage notebook }}}
+.. L4
+
+{{{ open sage notebook }}}
+
+.. R4
We have our Sage notebook running. In case, you don't have it running,
start is using the command, ``sage --notebook``.
+.. R5
+
To find the limit of the function x*sin(1/x), at x=0, we say
+
+.. L5
::
- lim(x*sin(1/x), x=0)
+ lim(x*sin(1/x), x=0)
+
+.. R6
We get the limit to be 0, as expected.
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.
+
+.. L6
::
- lim(1/x, x=0, dir='above')
+ lim(1/x, x=0, dir='right')
+
+.. R7
To find the limit from the negative side, we say,
+
+.. L7
::
- lim(1/x, x=0, dir='below')
+ lim(1/x, x=0, dir='left')
+
+.. R8
+
+Let us now see how to perform differentiation, using Sage. We shall
+find the differential of the expression ``exp(sin(x^2))/x`` w.r.t ``x``.
+For this, we shall first define the expression, and then use the ``diff``
+function to obtain the differential of the expression.
-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.
+.. L8
::
var('x')
f = exp(sin(x^2))/x
-
diff(f, x)
+.. R9
+
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.
+
+.. L9
::
var('x y')
@@ -83,56 +125,95 @@ one of the variables. Let us differentiate the expression
diff(f, y)
+.. R10
+
+Thus we get our partial differential solution.
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.
+from the differentiation that we did before, ``diff(f, y)`` which gave us
+the expression ---``e^(sin(-x^2 + y))*cos(-x^2 + y)/x``.
+The ``integrate`` command is used to obtain the integral of an
+expression or function.
+
+.. L10
::
integrate(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y)
-We get back the correct expression. The minus sign being inside or
-outside the ``sin`` function doesn't change much.
+.. R11
+
+As we can see,we get back the correct expression. The minus sign being
+inside or outside the ``sin`` function doesn't change much.
Now, let us find the value of the integral between the limits 0 and
pi/2.
+
+.. L11
::
integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2)
+.. R12
+
+Hence we get our solution for the definite integration.
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.
+
+.. L12
::
var('x n')
taylor((x+1)^n, x, 0, 4)
+.. R13
+
+We easlily got the Taylor expansion,using the function ``taylor()``.
This brings us to the end of the features of Sage for Calculus, that
we will be looking at. For more, look at the Calculus quick-ref from
the Sage Wiki.
-Next let us move on to Matrix Algebra.
+.. L13
+
+.. L14
{{{ show the equation on the slides }}}
+.. R14
+
+Next let us move on to Matrix Algebra.
Let us begin with solving the equation ``Ax = v``, where A is the
matrix ``matrix([[1,2],[3,4]])`` and v is the vector
``vector([1,2])``.
+.. R15
+
To solve the equation, ``Ax = v`` we simply say
+
+.. L15
+
+{{{ Switch back to sage notebook page }}}
::
- x = solve_right(A, v)
+ A = matrix([[1,2],
+ [3,4]])
+
+ v = vector([1,2])
+ x = A.solve_right(v)
+ x
+
+.. R16
To solve the equation, ``xA = v`` we simply say
+
+.. L16
::
- x = solve_left(A, v)
+ x = A.solve_left(v)
+ x
-The left and right here, denote the position of ``A``, relative to x.
+.. R17
-#[Puneeth]: any suggestions on what more to add?
+The left and right here, denote the position of ``A``, relative to x.
Now, let us look at Graph Theory in Sage.
@@ -140,85 +221,182 @@ 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
+of lists. We create a simple graph by using the ``Graph()`` function.
+
+.. L17
::
- G = Graph({0:[1,2,3], 2:[4]})
+ G = Graph({0:[1,2,3], 2:[4]})
+
+.. R18
+
+to view the visualization of the graph, we say
-We say
+.. L18
::
- G.show()
+ G.show()
-to view the visualization of the graph.
+.. R19
Similarly, we can obtain a directed graph using the ``DiGraph``
function.
+
+.. L19
::
- G = DiGraph({0:[1,2,3], 2:[4]})
+ G = DiGraph({0:[1,2,3], 2:[4]})
+.. R20
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.
+
+.. L20
::
- G = graphs.CompleteGraph(5)
+ G = graphs.CompleteGraph(5)
- G.show()
+ G.show()
+.. R21
Sage provides other functions for Number theory and
Combinatorics. Let's have a glimpse of a few of them.
+``prime_range`` gives primes in the range 100 to 200.
+.. L21
+::
+
+ prime_range(100, 200)
+
+.. R22
+``is_prime`` checks if 1999 is a prime number or not.
+
+.. L22
::
- prime_range(100, 200)
+ is_prime(1999)
+
+.. R23
-gives primes in the range 100 to 200.
+``factor(2001)`` gives the factorized form of 2001.
+.. L23
::
- is_prime(1999)
+ factor(2001)
-checks if 1999 is a prime number or not.
+.. R24
+The ``Permutations()`` gives the permutations of ``[1, 2, 3, 4]``
+
+.. L24
::
- factor(2001)
+ C = Permutations([1, 2, 3, 4])
+ C.list()
+
+.. R25
+
+And the ``Combinations()`` gives all the combinations of ``[1, 2, 3, 4]``
+
+.. L25
+::
+
+ C = Combinations([1, 2, 3, 4])
+ C.list()
+
+.. L26
+
+{{{ Show summary slide }}}
+
+.. R26
-gives the factorized form of 2001.
+This brings us to the end of the tutorial.In this tutorial,
+we have learnt to,
+ 1. Use functions for calculus like --
+ - lim()-- to find out the limit of a function
+ - diff()-- to find out the differentiation of an expression
+ - integrate()-- to integrate over an expression
+ - integral()-- to find out the definite integral of an
+ expression by specifying the limits
+ - solve()-- to solve a function, relative to it's postion.
+ #. Create Both a simple graph and a directed graph, using the
+ functions ``graph`` and ``digraph`` respectively.
+ #. Use functions for Number theory.For eg:
+ - primes_range()-- to find out the prime numbers within the
+ specified range
+ - factor()-- to find out the factorized form of the number specified
+ - Permutations(), Combinations()-- to obtain the required permutation
+ and combinations for the given set of values.
+
+.. L27
+
+{{{Show self assessment questions slide}}}
+
+.. R27
+
+Here are some self assessment questions for you to solve
+
+1. How do you find the limit of the function ``x/sin(x)`` as ``x`` tends
+ to ``0`` from the negative side.
+
+
+2. List all the primes between 2009 and 2900
+
+
+3. Solve the system of linear equations
+
+ x-2y+3z = 7
+ 2x+3y-z = 5
+ x+2y+4z = 9
+
+.. L28
+
+{{{solution of self assessment questions on slide}}}
+
+.. R28
+
+And the answers,
+
+1. To find out the limit of an expression from the negative side,we add
+ an argument dir="below" as
::
- C = Permutations([1, 2, 3, 4])
- C.list()
+ lim(x/sin(x), x=0, dir="left")
-gives the permutations of ``[1, 2, 3, 4]``
+2. The prime numbers from 2009 and 2900 can be obtained as,
+::
+
+ prime_range(2009, 2901)
+3. We shall first write the equations in matrix form and then use the
+ solve() function
::
- C = Combinations([1, 2, 3, 4])
- C.list()
+ A = Matrix([[1, -2, 3],
+ [2, 3, -1],
+ [1, 2, 4]])
-gives all the combinations of ``[1, 2, 3, 4]``
-
-That brings us to the end of this session showing various features
-available in Sage.
+ b = vector([7, 5, 9])
-.. #[[Anoop: I feel we should add more slides, a possibility is to add
- the code which they are required to type in, I also feel we should
- add some review problems for them to try out.]]
+ x = A.solve_right(b)
+
+To view the ouput type x
+::
+
+ x
-{{{ Show summary slide }}}
+.. L29
-We have looked at some of the functions available for Linear Algebra,
-Calculus, Graph Theory and Number theory.
+{{{ Switch to thankyou slide }}}
-This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
+.. R29
-Hope you have enjoyed and found it useful.
+Hope you have enjoyed this tutorial and found it useful.
Thank you!
diff --git a/using_sage/slides.org b/using_sage/slides.org
index b8b5f6e..c5e35c8 100644
--- a/using_sage/slides.org
+++ b/using_sage/slides.org
@@ -18,7 +18,7 @@
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-#+TITLE: using Sage
+#+TITLE:
#+AUTHOR: FOSSEE
#+EMAIL:
#+DATE:
@@ -29,30 +29,87 @@
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
-* Outline
- - Calculus
- - Linear Algebra
- - Graph Theory
- - Number Theory
+*
+#+begin_latex
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Using Sage}
+\end{center}
+\vspace{18pt}
+\begin{center}
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
+\end{center}
+#+end_latex
+* Objectives
+ At the end of this tutorial, you will be able to,
+
+ - Learn the range of things for which Sage can be used.
+ - Know some of the functions for Calculus.
+ - Learn about graph theory and number theory using Sage.
+* Pre-requisite
+ Spoken tuorial on -
+ - Getting started with Sage
+* Equation
+ Ax = v,
+ where A is the matrix,'' matrix([[1,2],[3,4]])''
+ v is the vector, ''vector([1,2])''.
* Summary
- - Differentiating and Integrating
- - Taylor Expansions
- - Solving Equations
- - Initializing Graphs & Graph families
- - Prime numbers
- - Factors
- - Combinations & Permutations
-* Thank you!
+In this tutorial, we have learnt to,
+ - Use functions for calculus like --
+ - lim()-- to find out the limit of a function
+ - diff()-- to find out the differentiation of an expression
+ - integrate()-- to integrate over an expression
+ - integral()-- to find out the definite integral of an
+ expression by specifying the limits
+ - solve()-- to solve a function, relative to it's postion.
+ - Create Both a simple graph and a directed graph, using the
+ functions ``graph()`` and ``digraph()`` respectively.
+ - Use functions for Number theory.For eg:
+ - primes\_range()-- to find out the prime numbers within the
+ specified range
+ - factor()-- to find out the factorized form of the number specified
+ - Permutations(), Combinations()-- to obtain the required permutation
+ and combinations for the given set of values.
+* Evaluation
+ 1. How do you find the limit of the function ``x/sin(x)`` as ``x`` tends
+ to ``0`` from the negative side.
+
+ 2. List all the primes between 2009 and 2900.
+
+ 3. Solve the system of linear equations
+
+ x-2y+3z = 7
+ 2x+3y-z = 5
+ x+2y+4z = 9
+* Solutions
+1. lim(x/sin(x), x=0, dir="below")
+
+2. prime\_range(2009, 2901)
+
+3. A = Matrix([[1, -2, 3],
+ [2, 3, -1],
+ [1, 2, 4]])
+
+ b = vector([7, 5, 9])
+
+ solve\_right(A, b)
+*
#+begin_latex
\begin{block}{}
\begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
+ \textcolor{blue}{\Large THANK YOU!}
\end{center}
+ \end{block}
+\begin{block}{}
\begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
\end{center}
\end{block}
#+end_latex
diff --git a/using_sage/slides.tex b/using_sage/slides.tex
index 134b0d7..b79675f 100644
--- a/using_sage/slides.tex
+++ b/using_sage/slides.tex
@@ -1,4 +1,4 @@
-% Created 2010-10-27 Wed 13:16
+% Created 2011-06-15 Wed 11:05
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
@@ -8,7 +8,6 @@
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
-\usepackage{t1enc}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
@@ -24,14 +23,13 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\providecommand{\alert}[1]{\textbf{#1}}
-\title{using Sage}
+\title{}
\author{FOSSEE}
\date{}
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
-\maketitle
@@ -41,46 +39,136 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+\begin{frame}
+
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Using Sage}
+\end{center}
+\vspace{18pt}
+\begin{center}
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
+\end{center}
+\end{frame}
\begin{frame}
-\frametitle{Outline}
-\label{sec-1}
+\frametitle{Objectives}
+\label{sec-2}
+
+ At the end of this tutorial, you will be able to,
+
\begin{itemize}
-\item Calculus
-\item Linear Algebra
-\item Graph Theory
-\item Number Theory
+\item Learn the range of things for which Sage can be used.
+\item Know the functions used for calculus in Sage.
+\item Learn about graph theory and number theory using Sage.
\end{itemize}
\end{frame}
\begin{frame}
+\frametitle{Pre-requisite}
+\label{sec-3}
+
+ Spoken tuorial on -
+
+\begin{itemize}
+\item Getting started with Sage
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Equation}
+\label{sec-4}
+
+ Ax = v,\\
+ where A is the matrix, ``matrix([[1,2],[3,4]])''\\
+ v is the vector, ``vector([1,2])''.
+\end{frame}
+\begin{frame}
\frametitle{Summary}
-\label{sec-2}
+\label{sec-5}
+
+In this tutorial, we have learnt to,
\begin{itemize}
-\item Differentiating and Integrating
-\item Taylor Expansions
-\item Solving Equations
-\item Initializing Graphs \& Graph families
-\item Prime numbers
-\item Factors
-\item Combinations \& Permutations
+\item Use functions for calculus like --
+\begin{itemize}
+\item lim()-- to find out the limit of a function
+\item integrate()-- to integrate over an expression
+\item integral()-- to find out the definite integral of an
+ expression by specifying the limits
+\item solve()-- to solve a function, relative to it's postion.
+\end{itemize}
+\item Create both a simple graph and a directed graph, using the
+ functions ``graph()'' and ``digraph()'' respectively.
+\item Use functions for Number theory.For eg:
+\begin{itemize}
+\item primes$\_{\mathrm{range}}$()-- to find out the prime numbers within the
+ specified range
+\item factor()-- to find out the factorized form of the number specified
+\item Permutations(), Combinations()-- to obtain the required permutation
+ and combinations for the given set of values.
+\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
-\frametitle{Thank you!}
-\label{sec-3}
+\frametitle{Evaluation}
+\label{sec-6}
+
+
+\begin{enumerate}
+\item How do you find the limit of the function ``x/sin(x)'' as ``x'' tends
+ to ``0'' from the negative side.
+\vspace{3pt}
+\item List all the primes between 2009 and 2900.
+\vspace{3pt}
+\item Solve the system of linear equations
+
+ x-2y+3z = 7\\
+ 2x+3y-z = 5\\
+ x+2y+4z = 9
+\end{enumerate}
+\end{frame}
+\begin{frame}
+\frametitle{Solutions}
+\label{sec-7}
+
+
+\begin{enumerate}
+\item lim(x/sin(x), x=0, dir=``left'')
+\vspace{4pt}
+\item prime$\_{\mathrm{range}}$(2009, 2901)
+\vspace{4pt}
+\item A = Matrix([[1, -2, 3], \\
+\hspace{1.78cm}
+ [2, 3, -1], \\
+\hspace{1.78cm}
+ [1, 2, 4]]) \\
+\vspace{2pt}
+ b = vector([7, 5, 9])\\
+\vspace{2pt}
+ x = A.solve$\_{\mathrm{right}}$(b)\\
+\vspace{2pt}
+ x
+\end{enumerate}
+\end{frame}
+\begin{frame}
\begin{block}{}
\begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
+ \textcolor{blue}{\Large THANK YOU!}
\end{center}
+ \end{block}
+\begin{block}{}
\begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
\end{center}
\end{block}
\end{frame}
-\end{document}
+\end{document} \ No newline at end of file