--- a/getting-started-with-lists/getting_started_with_lists.rst Tue Oct 26 16:04:50 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-Hello friends and welcome to the tutorial on getting started with
-lists.
-
- {{{ Show the slide containing title }}}
-
- {{{ Show the slide containing the outline slide }}}
-
-In this tutorial we will be getting acquainted with a python data
-structure called lists. We will learn ::
-
- * How to create lists
- * Structure of lists
- * Access list elements
- * Append elements to lists
- * Deleting elements from lists
-
-List is a compound data type, it can contain data of other data
-types. List is also a sequence data type, all the elements are in
-order and there order has a meaning.
-
-We will first create an empty list with no elements. On your IPython
-shell type ::
-
- empty = []
- type(empty)
-
-
-This is an empty list without any elements.
-
-* Filled lists
-
-Lets now define a list, nonempty and fill it with some random elements.
-
-nonempty = ['spam', 'eggs', 100, 1.234]
-
-Thus the simplest way of creating a list is typing out a sequence
-of comma-separated values (items) between square brackets.
-All the list items need not have the same data type.
-
-
-
-As we can see lists can contain different kinds of data. In the
-previous example 'spam' and 'eggs' are strings and 100 and 1.234
-integer and float. Thus we can put elements of heterogenous types in
-lists. Thus list themselves can be one of the element types possible
-in lists. Thus lists can also contain other lists. Example ::
-
- list_in_list=[[4,2,3,4],'and', 1, 2, 3, 4]
-
-We access list elements using the number of index. The
-index begins from 0. So for list nonempty, nonempty[0] gives the
-first element, nonempty[1] the second element and so on and
-nonempty[3] the last element. ::
-
- nonempty[0]
- nonempty[1]
- nonempty[3]
-
-We can also access the elememts from the end using negative indices ::
-
- nonempty[-1]
- nonempty[-2]
- nonempty[-4]
-
--1 gives the last element which is the 4th element , -2 second to last and -4 gives the fourth
-from last element which is first element.
-
-We can append elements to the end of a list using append command. ::
-
- nonempty.append('onemore')
- nonempty
- nonempty.append(6)
- nonempty
-
-As we can see non empty appends 'onemore' and 6 at the end.
-
-
-
-Using len function we can check the number of elements in the list
-nonempty. In this case it being 6 ::
-
- len(nonempty)
-
-
-
-Just like we can append elements to a list we can also remove them.
-There are two ways of doing it. One is by using index. ::
-
- del(nonempty[1])
-
-
-
-deletes the element at index 1, i.e the second element of the
-list, 'eggs'. The other way is removing element by content. Lets say
-one wishes to delete 100 from nonempty list the syntax of the command
-should be ::
-
- a.remove(100)
-
-but what if their were two 100's. To check that lets do a small
-experiment. ::
-
- a.append('spam')
- a
- a.remove('spam')
- a
-
-If we check a now we will see that the first occurence 'spam' is removed
-thus remove removes the first occurence of the element in the sequence
-and leaves others untouched.
-
-
-{{{Slide for Summary }}}
-
-
-In this tutorial we came across a sequence data type called lists. ::
-
- * We learned how to create lists.
- * How to access lists.
- * Append elements to list.
- * Delete Element from list.
- * And Checking list length.
-
-
-
-{{{ Sponsored by Fossee Slide }}}
-
-This tutorial was created as a part of FOSSEE project.
-
-I hope you found this tutorial useful.
-
-Thank You
-
-
- * Author : Amit Sethi
- * First Reviewer :
- * Second Reviewer : Nishanth
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-with-symbolics/questions.rst Tue Oct 26 16:08:02 2010 +0530
@@ -0,0 +1,61 @@
+Objective Questions
+-------------------
+
+.. A mininum of 8 questions here (along with answers)
+
+1. How do you define a name 'y' as a symbol?
+
+
+ Answer: var('y')
+
+2. List out some constants pre-defined in sage?
+
+ Answer: pi, e ,euler_gamma
+
+3. List the functions for differentiation and integration in sage?
+
+ Answer: diff and integral
+
+4. Get the value of pi upto precision 5 digits using sage?
+
+ Answer: n(pi,5)
+
+5. Find third order differential of function.
+
+ f(x)=sin(x^2)+exp(x^3)
+
+ Answer: diff(f(x),x,3)
+
+6. What is the function to find factors of an expression?
+
+ Answer: factor
+
+7. What is syntax for simplifying a function f?
+
+ Answer f.simplify_full()
+
+8. Find the solution for x between pi/2 to pi for the given equation?
+
+ sin(x)==cos(x^3)+exp(x^4)
+ find_root(sin(x)==cos(x^3)+exp(x^4),pi/2,pi)
+
+9. Create a simple two dimensional matrix with two symbolic variables?
+
+ var('a,b')
+ A=matrix([[a,1],[2,b]])
+
+Larger Questions
+----------------
+
+.. A minimum of 2 questions here (along with answers)
+
+1.Find the points of intersection of the circles
+
+ x^2 + y^2 - 4x = 1
+ x^2 + y^2 - 2y = 9
+
+2. Integrate the function
+
+x^2*cos(x)
+
+between 1 to 3.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-with-symbolics/quickref.tex Tue Oct 26 16:08:02 2010 +0530
@@ -0,0 +1,8 @@
+Creating a linear array:\\
+{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+
+Plotting two variables:\\
+{\ex \lstinline| plot(x, sin(x))|}
+
+Plotting two lists of equal length x, y:\\
+{\ex \lstinline| plot(x, y)|}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-with-symbolics/script.rst Tue Oct 26 16:08:02 2010 +0530
@@ -0,0 +1,277 @@
+Symbolics with Sage
+-------------------
+
+Hello friends and welcome to the tutorial on symbolics with sage.
+
+{{{ Show welcome slide }}}
+
+
+.. #[Madhu: What is this line doing here. I don't see much use of it]
+
+During the course of the tutorial we will learn
+
+{{{ Show outline slide }}}
+
+* Defining symbolic expressions in sage.
+* Using built-in costants and functions.
+* Performing Integration, differentiation using sage.
+* Defining matrices.
+* Defining Symbolic functions.
+* Simplifying and solving symbolic expressions and functions.
+
+We can use Sage for symbolic maths.
+
+On the sage notebook type::
+
+ sin(y)
+
+It raises a name error saying that y is not defined. But in sage we
+can declare y as a symbol using var function.
+
+
+::
+ var('y')
+
+Now if you type::
+
+ sin(y)
+
+sage simply returns the expression.
+
+
+Thus sage treats sin(y) as a symbolic expression . We can use
+this to do symbolic maths using sage's built-in constants and
+expressions..
+
+
+So let us try ::
+
+ var('x,alpha,y,beta')
+ x^2/alpha^2+y^2/beta^2
+
+taking another example
+
+ var('theta')
+ sin^2(theta)+cos^2(theta)
+
+
+Similarly, we can define many algebraic and trigonometric expressions
+using sage .
+
+
+Sage also provides a few built-in constants which are commonly used in
+mathematics .
+
+example : pi,e,infinity , Function n gives the numerical values of all these
+ constants.
+
+{{{ Type n(pi)
+ n(e)
+ n(oo)
+ On the sage notebook }}}
+
+
+
+If you look into the documentation of function "n" by doing
+
+.. #[Madhu: "documentation of the function "n"?]
+
+::
+ n(<Tab>
+
+You will see what all arguments it takes and what it returns. It will be very
+helpful if you look at the documentation of all functions introduced through
+this script.
+
+
+
+Also we can define the no. of digits we wish to use in the numerical
+value . For this we have to pass an argument digits. Type
+
+.. #[Madhu: "no of digits"? Also "We wish to obtain" than "we wish to
+ use"?]
+::
+
+ n(pi, digits = 10)
+
+Apart from the constants sage also has a lot of builtin functions like
+sin,cos,log,factorial,gamma,exp,arcsin etc ...
+lets try some of them out on the sage notebook.
+
+
+::
+
+ sin(pi/2)
+
+ arctan(oo)
+
+ log(e,e)
+
+
+Given that we have defined variables like x,y etc .. , We can define
+an arbitrary function with desired name in the following way.::
+
+ var('x')
+ function('f',x)
+
+
+Here f is the name of the function and x is the independent variable .
+Now we can define f(x) to be ::
+
+ f(x) = x/2 + sin(x)
+
+Evaluating this function f for the value x=pi returns pi/2.::
+
+ f(pi)
+
+We can also define functions that are not continuous but defined
+piecewise. Let us define a function which is a parabola between 0
+to 1 and a constant from 1 to 2 . Type the following as given on the
+screen
+
+::
+
+
+ var('x')
+ h(x)=x^2 g(x)=1
+ f=Piecewise(<Tab>
+
+{{{ Show the documentation of Piecewise }}}
+
+::
+ f=Piecewise([[(0,1),h(x)],[(1,2),g(x)]],x) f
+
+
+
+
+We can also define functions which are series
+
+
+We first define a function f(n) in the way discussed above.::
+
+ var('n')
+ function('f', n)
+
+
+To sum the function for a range of discrete values of n, we use the
+sage function sum.
+
+For a convergent series , f(n)=1/n^2 we can say ::
+
+ var('n')
+ function('f', n)
+
+ f(n) = 1/n^2
+
+ sum(f(n), n, 1, oo)
+
+
+Lets us now try another series ::
+
+
+ f(n) = (-1)^(n-1)*1/(2*n - 1)
+ sum(f(n), n, 1, oo)
+
+
+This series converges to pi/4.
+
+
+Moving on let us see how to perform simple calculus operations using Sage
+
+For example lets try an expression first ::
+
+ diff(x**2+sin(x),x)
+ 2x+cos(x)
+
+The diff function differentiates an expression or a function. Its
+first argument is expression or function and second argument is the
+independent variable.
+
+We have already tried an expression now lets try a function ::
+
+ f=exp(x^2)+arcsin(x)
+ diff(f(x),x)
+
+To get a higher order differential we need to add an extra third argument
+for order ::
+
+ diff(<tab> diff(f(x),x,3)
+
+in this case it is 3.
+
+
+Just like differentiation of expression you can also integrate them ::
+
+ x = var('x')
+ s = integral(1/(1 + (tan(x))**2),x)
+ s
+
+
+
+Many a times we need to find factors of an expression ,we can use the "factor" function
+
+::
+ factor(<tab>
+ y = (x^100 - x^70)*(cos(x)^2 + cos(x)^2*tan(x)^2)
+ f = factor(y)
+
+One can simplify complicated expression ::
+
+ f.simplify_full()
+
+This simplifies the expression fully . We can also do simplification
+of just the algebraic part and the trigonometric part ::
+
+ f.simplify_exp()
+ f.simplify_trig()
+
+
+
+One can also find roots of an equation by using find_root function::
+
+ phi = var('phi')
+ find_root(cos(phi)==sin(phi),0,pi/2)
+
+Lets substitute this solution into the equation and see we were
+correct ::
+
+ var('phi')
+ f(phi)=cos(phi)-sin(phi)
+ root=find_root(f(phi)==0,0,pi/2)
+ f.substitute(phi=root)
+
+as we can see when we substitute the value the answer is almost = 0 showing
+the solution we got was correct.
+
+
+
+
+Lets us now try some matrix algebra symbolically ::
+
+
+
+ var('a,b,c,d')
+ A=matrix([[a,1,0],[0,b,0],[0,c,d]])
+ A
+
+Now lets do some of the matrix operations on this matrix
+
+
+::
+ A.det()
+ A.inverse()
+
+
+
+{{{ Part of the notebook with summary }}}
+
+So in this tutorial we learnt how to
+
+
+* We learnt about defining symbolic expression and functions.
+* Using built-in constants and functions.
+* Using <Tab> to see the documentation of a function.
+* Simple calculus operations .
+* Substituting values in expression using substitute function.
+* Creating symbolic matrices and performing operation on them .
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-with-symbolics/slides.tex Tue Oct 26 16:08:02 2010 +0530
@@ -0,0 +1,67 @@
+% Created 2010-10-21 Thu 00:06
+\documentclass[presentation]{beamer}
+\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{amssymb}
+\usepackage{hyperref}
+
+
+\title{Plotting Data }
+\author{FOSSEE}
+\date{2010-09-14 Tue}
+
+\begin{document}
+
+\maketitle
+
+
+
+
+
+
+\begin{frame}
+\frametitle{Tutorial Plan}
+\label{sec-1}
+\begin{itemize}
+
+\item Defining symbolic expressions in sage.\\
+\label{sec-1.1}%
+\item Using built-in costants and functions.\\
+\label{sec-1.2}%
+\item Performing Integration, differentiation using sage.\\
+\label{sec-1.3}%
+\item Defining matrices.\\
+\label{sec-1.4}%
+\item Defining Symbolic functions.\\
+\label{sec-1.5}%
+\item Simplifying and solving symbolic expressions and functions.\\
+\label{sec-1.6}%
+\end{itemize} % ends low level
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-2}
+\begin{itemize}
+
+\item We learnt about defining symbolic expression and functions.\\
+\label{sec-2.1}%
+\item Using built-in constants and functions.\\
+\label{sec-2.2}%
+\item Using <Tab> to see the documentation of a function.\\
+\label{sec-2.3}%
+\item Simple calculus operations .\\
+\label{sec-2.4}%
+\item Substituting values in expression using substitute function.\\
+\label{sec-2.5}%
+\item Creating symbolic matrices and performing operation on them .\\
+\label{sec-2.6}%
+\end{itemize} % ends low level
+\end{frame}
+
+\end{document}