diff options
Diffstat (limited to 'using_sage_for_calculus')
-rw-r--r-- | using_sage_for_calculus/folder.png | bin | 0 -> 45829 bytes | |||
-rw-r--r-- | using_sage_for_calculus/quickref.tex | 8 | ||||
-rw-r--r-- | using_sage_for_calculus/script.odt | bin | 0 -> 35167 bytes | |||
-rw-r--r-- | using_sage_for_calculus/script.rst | 327 | ||||
-rw-r--r-- | using_sage_for_calculus/script.txt | 269 | ||||
-rw-r--r-- | using_sage_for_calculus/script2col.rst | 166 | ||||
-rw-r--r-- | using_sage_for_calculus/slides.org | 117 | ||||
-rw-r--r-- | using_sage_for_calculus/slides.tex | 200 |
8 files changed, 1087 insertions, 0 deletions
diff --git a/using_sage_for_calculus/folder.png b/using_sage_for_calculus/folder.png Binary files differnew file mode 100644 index 0000000..42d01a2 --- /dev/null +++ b/using_sage_for_calculus/folder.png diff --git a/using_sage_for_calculus/quickref.tex b/using_sage_for_calculus/quickref.tex new file mode 100644 index 0000000..b26d168 --- /dev/null +++ b/using_sage_for_calculus/quickref.tex @@ -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)|} diff --git a/using_sage_for_calculus/script.odt b/using_sage_for_calculus/script.odt Binary files differnew file mode 100644 index 0000000..f26e438 --- /dev/null +++ b/using_sage_for_calculus/script.odt diff --git a/using_sage_for_calculus/script.rst b/using_sage_for_calculus/script.rst new file mode 100644 index 0000000..f465248 --- /dev/null +++ b/using_sage_for_calculus/script.rst @@ -0,0 +1,327 @@ +.. Objectives +.. ---------- + +.. By the end of this tutorial you will -- + +.. 1. Get an idea of the range of things for which Sage can be used. +.. #. Know some of the functions for Calculus +.. #. Get some insight into Graphs in Sage. + + +.. Prerequisites +.. ------------- + +.. Getting Started -- Sage + +Script +------ + +.. L1 + +{{{ Show the title slide }}} + +.. R1 + +Hello Friends and Welcome to the tutorial on 'Using Sage for Calculus'. + +.. L2 + +{{{ show the 'objectives' slide }}} + +.. R2 + +At the end of this tutorial, you will be able to, + + 1. Learn the range of things for which Sage can be used. + #. Perform integrations & other Calculus in Sage. + #. Perform matrix algebra in sage. + +.. L3 + +{{{ show 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. + +.. 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 begin with, let us find the limit of the function x*sin(1/x), at x=0. +To do this we say + +.. L5 +:: + + lim(x*sin(1/x), x=0) + +.. R6 + +As expected, we get the limit to be 0. + +It is also possible to limit 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='right') + +.. R7 + +We get the limit from positive side. +To find the limit from the negative side, we say, + +.. L7 +:: + + lim(1/x, x=0, dir='left') + +.. L8 + +{{{ Show the 'differential expression' slide }}} + +.. 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. So, switch to the sage +notebook and type + +.. L9 +:: + + var('x') + f = exp(sin(x^2))/x + diff(f, x) + +.. R9 + +And we get the expected differential of the expression. + +.. L10 + +{{{ Show the slide 'Partial Differentiation' }}} + +.. R10 + +We can also obtain the partial differentiation of an expression with one of the +vriables. Let us differentiate the expression +``exp(sin(y - x^2))/x`` w.r.t x and y. Switch to sage notebook and type + +.. L11 +:: + + var('x y') + f = exp(sin(y - x^2))/x + diff(f, x) + diff(f, y) + +.. R11 + +Thus we get our partial differential solution. + +.. L12 + +{{{ Show the 'integration' slide }}} + +.. R12 + +Now, let us look at integration. We shall use the expression obtained +from the differentiation that we calculated before, ``diff(f, y)`` +which gave us the expression ---``cos(-x^2 + y)*e^(sin(-x^2 + y))/x``. +The ``integrate`` command is used to obtain the integral of an +expression or function. So, switch to sage notebook and type. + +.. L13 +{{{ Switch to sage }}} +:: + + integrate(cos(-x^2 + y)*e^(sin(-x^2 + y))/x, y) + +.. R13 + +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. + +.. L14 +:: + + integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2) + +.. R14 + +Hence we get our solution for the definite integration. +Let us now see how to obtain the Taylor expansion of an expression +using sage. We will obtain the Taylor expansion of ``(x + 1)^n`` up to +degree 4 about 0. + +.. L15 +:: + + var('x n') + taylor((x+1)^n, x, 0, 4) + +.. R15 + +We easily 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. + +.. L16 + +{{{ Show the 'More on Calculus' slide }}} + +.. R16 + +For more on calculus you may look at the Calculus quick-ref from the Sage +documentation at the given link. + +.. L17 + +{{{ show the 'Equation' slide }}} + +.. R17 + +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])``. + +.. R18 + +To solve the equation, ``Ax = v`` we simply say + +.. L18 + +{{{ Switch back to sage notebook page }}} +:: + + A = matrix([[1,2], + [3,4]]) + v = vector([1,2]) + x = A.solve_right(v) + x + +.. R19 + +To solve the equation, ``xA = v`` we simply say. +The left and right here, denote the position of ``A``, relative to x. + +.. L19 +:: + + x = A.solve_left(v) + x + +.. L20 + +{{{ show the 'Summary' slide }}} + +.. R20 + +This brings us to the end of this tutorial. In this tutorial we have learned to + +1. Use functions like lim(), integrate(), integral(), solve() +#. Use sage for performing matrix algebra, integrations & other calculus +operations using the above mentioned functions. + +.. L21 + +{{{ Show the 'Evaluation' slide }}} + +.. R21 + +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. + + #. Solve the system of linear equations + x-2y+3z = 7 + 2x+3y-z = 5 + x+2y+4z = 9 + +Try the xercises and switch to next slide for solutions. + +.. L22 + +{{{ Show the 'Solutions' slide }}} + +.. R22 + + 1. To find the limit of the function x/sin(x) as x tends to 0 from negative +side, use the lim function as: lim(x/sin(x), x=0, dir'left') + + #. A = Matrix([1, -2, 3], [2, 3, -1], [1, 2, 4]]) + b = vector([7, 5, 9]) + x = A.solve_right(b) + x + +.. L23 + +{{{ Show the 'FOSSEE' slide }}} + +.. R23 + +FOSSEE is Free and Open-source Software for Science and Engineering Education. +The goal of this project is to enable all to use open source software tools. +For more details, please visit the given link. + +.. L24 + +{{{ Show the 'About the Spoken Tutorial Project' slide }}} + +.. R24 + +Watch the video available at the following link. It summarizes the Spoken +Tutorial project. If you do not have good bandwidth, you can download and +watch it. + +.. L25 + +{{{ Show the 'Spoken Tutorial Workshops' slide }}} + +.. R25 + +The Spoken Tutorial Project Team conducts workshops using spoken tutorials, +gives certificates to those who pass an online test. + +For more details, please write to contact@spoken-tutorial.org + +.. L26 + +{{{ Show the 'Acknowledgements' slide }}} + +.. R26 + +Spoken Tutorial Project is a part of the "Talk to a Teacher" project. +It is supported by the National Mission on Education through ICT, MHRD, +Government of India. More information on this mission is available at the +given link. + +.. L27 + +{{{Show the 'Thank you' slide }}} + +.. R27 + +Hope you have enjoyed this tutorial and found it useful. +Thank you! diff --git a/using_sage_for_calculus/script.txt b/using_sage_for_calculus/script.txt new file mode 100644 index 0000000..87a4d7d --- /dev/null +++ b/using_sage_for_calculus/script.txt @@ -0,0 +1,269 @@ + +{| style="border-spacing:0;" +| style="border-top:0.05pt double #808080;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <center>'''Visual Cue'''</center> +| style="border:0.05pt double #808080;padding:0.049cm;"| <center>'''Narration'''</center> + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 1 + +Title Slide +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hello Friends and Welcome to the tutorial on 'Using Sage'. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 2 + +Objectives +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| # At the end of this tutorial, you will be able to,
+#
+# 1. Learn the range of things for which Sage can be used.
+# 2. Perform integrations & other Calculus in Sage.
+# 3. Perform matrix algebra in sage.
+ +Let us begin with Calculus. We shall be looking at limits, differentiation, integration, and Taylor polynomial. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Open sage notebook + +lim(x*sin(1/x), x=0) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We have our '''Sage''' '''notebook''' running. In case, you don't have it running,
start is using the command, '''sage''' ''space hyphen hyphen'' '''notebook.
''' + +To begin with, let us find the limit of the function '''x*sin(1/x)''', at '''x=0'''.
To do this we can use the '''lim''' '''funtcion''' as, '''lim''' ''within brackets'' '''x''' ''star '''''sin''' ''within brackets'' '''one''' ''divided by'' '''x '''''coma '''''x '''''is equal to '''''zero''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| lim(1/x, x=0, dir='right') +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We get the limit to be 0, as expected. + +It is also possible to limit a point from one direction. For example, let us find the limit of '''1/x''' at '''x=0''', when approaching from the positive side. So we say '''lim '''''within brackets '''''one by x, x=0, dir '''''is equal to in single quotes '''''right.''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| lim(1/x, x=0, dir='left') +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The same way we can even find the limit from the negative side, we say, '''lim '''''within brackets '''''one by x, x=0, dir '''''is equal to in single quotes '''''left.''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 3 + + +Differential Expression +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Let us now see how to perform '''differentiation''', using '''Sage'''. We shall find the '''differential''' of the expression '''sin''' '''square''' '''by x''' with reference to '''x ''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| var('x') + +f = exp(sin(x^2))/x + +diff(f, x) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| So switch to the sage notebook. + +We shall first define the expression, and then use the '''diff '''function to obtain the differential of the expression. + +So, type '''var '''''within round brackets in single quotes '''''x. '''Now, '''f '''''is equal to '''''exp '''''within brackets '''''sin '''''within brackets '''''x '''''to the power '''''two by x.''' + +We have the expression now and will obtain the differential using the '''diff function.''' + +Type '''diff '''''within brackets '''''f '''''coma '''''x.''' + +We get the differential. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show slide 4 + +Partial Differential Expression +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We can also obtain the partial differentiation of an expression with one of the vriables. + +Let us '''differentiate''' the '''expression
'''shown on the slide with + +reference to '''x''' and '''y'''. Switch to sage notebook + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| var('x y') + +f = exp(sin(y - x^2))/x + + +diff(f, x) + + +diff(f, y) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We first define the expression. + +So type, '''var '''''within round brackets in single quotes '''''x y''' + +Then, '''f '''''is equal to '''''exp '''''in brackets '''''sin '''''in brackets '''''y '''''minus '''''x '''''to the power''''' two by x.''' + +So the expression is ready now to get the partial differential of the expression we say '''diff '''''in brackets '''''f, x.''' + +Similarly for '''y '''we say '''diff '''''in brackets '''''f, y''.''''' + +Thus we get our partial differential solution. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 5 + +Integration +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Now, let us look at integration. We shall use the expression obtained from the differentiation that we calculated before, diff(f, y) which gave us the expression shown on the slide. + +The integrate command is used to obtain the integral of an expression or function. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| integrate(cos(-x^2 + y)*e^(sin(-x^2 + y))/x, y) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| So, switch to sage notebook and type, '''integrate '''and the expression we got from the previous calculation. As we can see, we get back the correct expression. + +The minus sign being
inside or outside the '''sin function''' doesn't change much. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| 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. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| var('x n') + +taylor((x+1)^n, x, 0, 4) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hence we get our solution for the definite integration. Let us now see how to obtain the Taylor expansion of an expression using sage using '''taylor function'''. + +Let us obtain the Taylor expansion of(x+1)^nup to degree 4 about 0. + +For this, type, '''var '''''in brackets '''''x n''' + +Now, '''taylor '''''in brackets again in brackets '''''x + one '''''the whole to the power '''''n '''''coma '''''x, zero, four.''' + +We easily got the Taylor expansion,using the function taylor(). + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 6 + + +More on Calculus +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| That we will be all about the features of '''Sage '''for calculus we will be looking at. For more, look at the Calculus quick-ref from the Sage Wiki. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 7 + +Equation +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Next let us move on to Matrix Algebra. Let us begin with solving the equation. Ax = v, where A is the matrix <nowiki>matrix([[1,2],[3,4]]) </nowiki>and v is the vector <nowiki>vector([1,2])</nowiki>. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Switch back to sage notebook page + +<nowiki>A = matrix([[1,2],</nowiki> + + <nowiki>[3,4]])</nowiki> + +<nowiki>v = vector([1,2])</nowiki> + +x = A.solve_right(v) + +x +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| To solve the equation, Ax = v we simply say, + + +'''A '''''is equal to '''''matrix '''''within round brackets in square brackets '''''one, two, '''''again in square brackets '''''three, four''' + +'''v '''''is equal to '''''vector '''''within round brackets in square brackets '''''one, two''' + +'''x '''''is equal to '''''A '''''dot '''''solve_right '''''in brackets '''''v''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| x = A.solve_left(v) + +x +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| To solve the equation, xA = v we simply say, + + +'''x '''''is equal to '''''A '''''dot '''''solve_left '''''in brackets '''''v''' + + +'''The left and right here, denote the position of A, relative to x.''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 8 + +Summary slide +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| # This brings us to the end of this tutorial. In this tutorial we have learned to
+#
+# 1. Use functions like '''lim(), integrate(), integral(), solve()'''
+# <nowiki>#. Use </nowiki>'''sage''' for performing '''matrix algebra, integrations''' & other calculus
operations using the above mentioned functions.
+ + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 9 + +Evaluation +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| 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. Solve the system of linear equations
+ +x-2y+3z = 7
+ +2x+3y-z = 5
+ +x+2y+4z = 9 + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 10 + +Solutions +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| And the answers, + +# 1. To find the limit of the function x/sin(x) as x tends to 0 from negative
side, use the lim function as: +# + + lim(x/sin(x), x=0, dir="left") + +# We shall first write the equations in '''matrix''' form and then use the '''solve()''' function +# + + <nowiki>A = Matrix([[1, -2, 3],</nowiki> + <nowiki>[2, 3, -1],</nowiki> + <nowiki>[1, 2, 4]])</nowiki> + +<nowiki>b = vector([7, 5, 9])</nowiki> + + +x = A.solve_right(b) + +To view the output type x + +x + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 11 + +FOSSEE +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| FOSSEE is Free and Open-source Software for Science and Engineering Education. The goal of this project is to enable all to use open source software tools. For more details, please visit the given link. + +|} + +{| style="border-spacing:0;" +| style="border-top:0.05pt double #808080;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 12 + +About the Spoken Tutorial Project +| style="border:0.05pt double #808080;padding:0.049cm;"| Watch the video available at the following link. It summarizes the Spoken Tutorial project. If you do not have good bandwidth, you can download and watch it. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 13 + +Spoken Tutorial Workshop +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The Spoken Tutorial Project Team conducts SELF workshops using spoken tutorials, gives certificates to those who pass an online test. For more details, you may write to contact@spoken-tutorial.org + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 14 + +Acknowledgements +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Spoken Tutorial Project is a part of the "Talk to a Teacher" project. It is supported by the National Mission on Education through ICT, MHRD, Government of India. More information on this mission is available at the given link. + + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 15 + +Thank You +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hope you have enjoyed this tutorial and found it useful. Thank you! + +|} + diff --git a/using_sage_for_calculus/script2col.rst b/using_sage_for_calculus/script2col.rst new file mode 100644 index 0000000..16c4871 --- /dev/null +++ b/using_sage_for_calculus/script2col.rst @@ -0,0 +1,166 @@ +.. Objectives +.. ---------- + +.. By the end of this tutorial you will -- + +.. 1. Get an idea of the range of things for which Sage can be used. +.. #. Know some of the functions for Calculus +.. #. Get some insight into Graphs in Sage. + + +.. Prerequisites +.. ------------- + +.. Getting Started -- Sage + +Script +------ + + + ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the title slide }}} | Hello Friends and Welcome to the tutorial on 'Using Sage for Calculus'. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ show the 'objectives' slide }}} | At the end of this tutorial, you will be able to, | +| | | +| | 1. Learn the range of things for which Sage can be used. | +| | #. Perform integrations & other Calculus in Sage. | +| | #. Perform matrix algebra in sage. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ show the 'pre-requisite' slide }}} | 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. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ open sage notebook }}} | We have our Sage notebook running. In case, you don't have it running, | +| | start is using the command, ``sage --notebook``. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | To begin with, let us find the limit of the function x*sin(1/x), at x=0. | +| | To do this we say | +| lim(x*sin(1/x), x=0) | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | As expected, we get the limit to be 0. | +| | | +| lim(1/x, x=0, dir='right') | It is also possible to limit a point from one direction. For | +| | example, let us find the limit of 1/x at x=0, when approaching from | +| | the positive side. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | We get the limit from positive side. | +| | To find the limit from the negative side, we say, | +| lim(1/x, x=0, dir='left') | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'differential expression' slide }}} | 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. So, switch to the sage | +| | notebook and type | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | And we get the expected differential of the expression. | +| | | +| var('x') | | +| f = exp(sin(x^2))/x | | +| diff(f, x) | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the slide 'Partial Differentiation' }}} | We can also obtain the partial differentiation of an expression with one of the | +| | vriables. Let us differentiate the expression | +| | ``exp(sin(y - x^2))/x`` w.r.t x and y. Switch to sage notebook and type | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | Thus we get our partial differential solution. | +| | | +| var('x y') | | +| f = exp(sin(y - x^2))/x | | +| diff(f, x) | | +| diff(f, y) | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'integration' slide }}} | Now, let us look at integration. We shall use the expression obtained | +| | from the differentiation that we calculated before, ``diff(f, y)`` | +| | which gave us the expression ---``cos(-x^2 + y)*e^(sin(-x^2 + y))/x``. | +| | The ``integrate`` command is used to obtain the integral of an | +| | expression or function. So, switch to sage notebook and type. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Switch to sage }}} | As we can see, we get back the correct expression. The minus sign being | +| :: | inside or outside the ``sin`` function doesn't change much. | +| | | +| integrate(cos(-x^2 + y)*e^(sin(-x^2 + y))/x, y) | Now, let us find the value of the integral between the limits 0 and | +| | pi/2. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | Hence we get our solution for the definite integration. | +| | Let us now see how to obtain the Taylor expansion of an expression | +| integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2) | using sage. We will obtain the Taylor expansion of ``(x + 1)^n`` up to | +| | degree 4 about 0. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | We easily got the Taylor expansion,using the function ``taylor()``. | +| | This brings us to the end of the features of Sage for Calculus, that | +| var('x n') | we will be looking at. | +| taylor((x+1)^n, x, 0, 4) | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'More on Calculus' slide }}} | For more on calculus you may look at the Calculus quick-ref from the Sage | +| | documentation at the given link. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ show the 'Equation' slide }}} | 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])``. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Switch back to sage notebook page }}} | To solve the equation, ``Ax = v`` we simply say | +| :: | | +| | | +| A = matrix([[1,2], | | +| [3,4]]) | | +| v = vector([1,2]) | | +| x = A.solve_right(v) | | +| x | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| :: | To solve the equation, ``xA = v`` we simply say. | +| | The left and right here, denote the position of ``A``, relative to x. | +| x = A.solve_left(v) | | +| x | | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ show the 'Summary' slide }}} | This brings us to the end of this tutorial. In this tutorial we have learned to | +| | | +| | 1. Use functions like lim(), integrate(), integral(), solve() | +| | #. Use sage for performing matrix algebra, integrations & other calculus | +| | operations using the above mentioned functions. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'Evaluation' slide }}} | 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. | +| | | +| | #. Solve the system of linear equations | +| | x-2y+3z = 7 | +| | 2x+3y-z = 5 | +| | x+2y+4z = 9 | +| | | +| | Try the xercises and switch to next slide for solutions. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'Solutions' slide }}} | 1. To find the limit of the function x/sin(x) as x tends to 0 from negative | +| | side, use the lim function as: lim(x/sin(x), x=0, dir'left') | +| | | +| | #. A = Matrix([1, -2, 3], [2, 3, -1], [1, 2, 4]]) | +| | b = vector([7, 5, 9]) | +| | x = A.solve_right(b) | +| | x | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'FOSSEE' slide }}} | FOSSEE is Free and Open-source Software for Science and Engineering Education. | +| | The goal of this project is to enable all to use open source software tools. | +| | For more details, please visit the given link. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'About the Spoken Tutorial Project' slide }}} | Watch the video available at the following link. It summarizes the Spoken | +| | Tutorial project. If you do not have good bandwidth, you can download and | +| | watch it. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'Spoken Tutorial Workshops' slide }}} | The Spoken Tutorial Project Team conducts workshops using spoken tutorials, | +| | gives certificates to those who pass an online test. | +| | | +| | For more details, please write to contact@spoken-tutorial.org | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{ Show the 'Acknowledgements' slide }}} | Spoken Tutorial Project is a part of the "Talk to a Teacher" project. | +| | It is supported by the National Mission on Education through ICT, MHRD, | +| | Government of India. More information on this mission is available at the | +| | given link. | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ +| {{{Show the 'Thank you' slide }}} | Hope you have enjoyed this tutorial and found it useful. | +| | Thank you! | ++----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+ diff --git a/using_sage_for_calculus/slides.org b/using_sage_for_calculus/slides.org new file mode 100644 index 0000000..c5e35c8 --- /dev/null +++ b/using_sage_for_calculus/slides.org @@ -0,0 +1,117 @@ +#+LaTeX_CLASS: beamer +#+LaTeX_CLASS_OPTIONS: [presentation] +#+BEAMER_FRAME_LEVEL: 1 + +#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} +#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) +#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC + +#+LaTeX_CLASS: beamer +#+LaTeX_CLASS_OPTIONS: [presentation] + +#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl} +#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} + +#+LaTeX_HEADER: \usepackage{listings} + +#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries, +#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, +#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} + +#+TITLE: +#+AUTHOR: FOSSEE +#+EMAIL: +#+DATE: + +#+DESCRIPTION: +#+KEYWORDS: +#+LANGUAGE: en +#+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 + +* +#+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 +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} + \textcolor{blue}{\Large THANK YOU!} + \end{center} + \end{block} +\begin{block}{} + \begin{center} + For more Information, visit our website\\ + \url{http://fossee.in/} + \end{center} + \end{block} +#+end_latex + + diff --git a/using_sage_for_calculus/slides.tex b/using_sage_for_calculus/slides.tex new file mode 100644 index 0000000..c9b58e6 --- /dev/null +++ b/using_sage_for_calculus/slides.tex @@ -0,0 +1,200 @@ +\documentclass[17pt]{beamer} +\usetheme{Madrid} +\useoutertheme{noslidenum} +\setbeamertemplate{navigation symbols}{} +\usepackage{beamerthemesplit} +\usepackage{ae,aecompl} +\usepackage[scaled=.95]{helvet} +\usepackage[english]{babel} +\usepackage[latin1]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{mathpazo,courier,euler} +\usepackage{listings} + +\lstset{language=sh, + basicstyle=\ttfamily\bfseries, + showstringspaces=false, + keywordstyle=\color{black}\bfseries} + +\definecolor{NavyBlue}{RGB}{0, 76, 153} +\setbeamercolor{structure}{fg=NavyBlue} +\author[FOSSEE]{} +\institute[IIT Bombay]{} +\date[]{} + +% theme split +\usepackage{verbatim} +\newenvironment{colorverbatim}[1][]% +{% +\color{blue} +\verbatim +}% +{% +\endverbatim +}% + +% logo +\logo{\includegraphics[height=1.30 cm]{../images/3t-logo.pdf}} +\logo{\includegraphics[height=1.30 cm]{../images/fossee-logo.png} + +\hspace{7.5cm} +\includegraphics[scale=0.3]{../images/fossee-logo.png}\\ +\hspace{281pt} +\includegraphics[scale=0.80]{../images/3t-logo.pdf}} + +\begin{document} + +\sffamily \bfseries +\title +[Using Sage for Calculus] +{Using Sage for Calculus} +\author +[FOSSEE] +{\small Talk to a Teacher\\{\color{blue}\url{http://spoken-tutorial.org}}\\National Mission on Education + through ICT\\{\color{blue}\url{http://sakshat.ac.in}} \\ [0.8cm]Script by: Hardik Ghaghada \\Narration by: \\ [0.7cm] +{\small 15 May 2013}} + +% slide 1 +\begin{frame} + \titlepage +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Objectives} + At the end of this tutorial, you will be able to, +\begin{itemize} +\item Learn the range of things for which Sage can be used. +\item Perform integrations \& other Calculus in Sage. +\item Perform matrix algebra in sage. +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Differential Expression} +$exp(sin(x^2))/x$\\ +w.r.t $x$ +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Partial Differential Expression} +$exp(sin(y - x^2))/x$\\ +w.r.t $x, y$ +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Integration} +\begin{itemize} +\item $diff(f, y)$\\ +\item $cos(-x^2 + y)*e^(sin(-x^2 + y))/x$\\ +\item $integrate$ +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{More on Calculus} +\url{www.sagemath.org/help.html} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Equation} + $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} +In this tutorial, we have learnt to, +\begin{itemize} +\item Use functions like lim(), integrate(), integral(), solve() +\item Use sage for performing matrix algebra, integrations \& other calculus +operations using the above mentioned functions. +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Evaluation} +\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} +\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} +\begin{enumerate} +\item lim(x/sin(x), x=0, dir=`left') +\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} +\frametitle{FOSSEE} +{\color{blue}Free and Open-source Software for \\Science and Engineering Education} \\ +\begin{itemize} +\item Goal - enabling all to use open source software tools +\item For more details, please visit {\color{blue}\url{http://fossee.in/}} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{About the Spoken Tutorial Project} +\begin{itemize} +\item Watch the video available at {\color{blue}\url{http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial}} +\item It summarises the Spoken Tutorial project +\item If you do not have good bandwidth, you can download and watch it +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Spoken Tutorial Workshops}The Spoken Tutorial Project Team +\begin{itemize} +\item Conducts workshops using spoken tutorials +\item Gives certificates to those who pass an online test +\item For more details, please write to \\ \hspace {0.5cm}{\color{blue}contact@spoken-tutorial.org} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Acknowledgements} +\begin{itemize} +\item Spoken Tutorial Project is a part of the Talk to a Teacher project +\item It is supported by the National Mission on Education through ICT, MHRD, Government of India +\item More information on this Mission is available at: \\{\color{blue}\url{http://spoken-tutorial.org/NMEICT-Intro}} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \begin{block}{} + \begin{center} + \textcolor{blue}{\Large THANK YOU!} + \end{center} + \end{block} +\begin{block}{} + \begin{center} + For more Information, visit our website\\ + \url{http://fossee.in/} + \end{center} + \end{block} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\end{document} |