getting-started-with-symbolics/script.rst
changeset 442 a9b71932cbfa
parent 376 3e947a3fa83e
child 458 9a1c5d134feb
equal deleted inserted replaced
441:430035b678f7 442:a9b71932cbfa
     2 .. ----------
     2 .. ----------
     3 
     3 
     4 .. By the end of this tutorial, you will be able to
     4 .. By the end of this tutorial, you will be able to
     5 
     5 
     6 .. 1. Defining symbolic expressions in sage.  
     6 .. 1. Defining symbolic expressions in sage.  
     7 .. # Using built-in costants and functions. 
     7 .. # Using built-in constants and functions. 
     8 .. # Performing Integration, differentiation using sage. 
     8 .. # Performing Integration, differentiation using sage. 
     9 .. # Defining matrices. 
     9 .. # Defining matrices. 
    10 .. # Defining Symbolic functions.  
    10 .. # Defining Symbolic functions.  
    11 .. # Simplifying and solving symbolic expressions and functions.
    11 .. # Simplifying and solving symbolic expressions and functions.
    12 
    12 
    35 During the course of the tutorial we will learn
    35 During the course of the tutorial we will learn
    36 
    36 
    37 {{{ Show outline slide  }}}
    37 {{{ Show outline slide  }}}
    38 
    38 
    39 * Defining symbolic expressions in sage.  
    39 * Defining symbolic expressions in sage.  
    40 * Using built-in costants and functions. 
    40 * Using built-in constants and functions. 
    41 * Performing Integration, differentiation using sage. 
    41 * Performing Integration, differentiation using sage. 
    42 * Defining matrices. 
    42 * Defining matrices. 
    43 * Defining Symbolic functions.  
    43 * Defining Symbolic functions.  
    44 * Simplifying and solving symbolic expressions and functions.
    44 * Simplifying and solving symbolic expressions and functions.
    45 
    45 
    71 So let us try ::
    71 So let us try ::
    72    
    72    
    73    var('x,alpha,y,beta') 
    73    var('x,alpha,y,beta') 
    74    x^2/alpha^2+y^2/beta^2
    74    x^2/alpha^2+y^2/beta^2
    75  
    75  
    76 taking another example
    76 taking another example ::
    77    
    77    
    78    var('theta')
    78    var('theta')
    79    sin^2(theta)+cos^2(theta)
    79    sin(theta)*sin(theta)+cos(theta)*cos(theta)
    80 
    80 
    81 
    81 Similarly, we can define many algebraic and trigonometric expressions using sage .
    82 Similarly, we can define many algebraic and trigonometric expressions
    82 
    83 using sage .
    83 
    84 
    84 Following is an exercise that you must do. 
    85 
    85 
    86 Sage also provides a few built-in constants which are commonly used in
    86 %% %%  Define following expressions as symbolic expressions
    87 mathematics .
    87 in sage?
    88 
    88    
    89 example : pi,e,infinity , Function n gives the numerical values of all these
    89    1. x^2+y^2
    90     constants.
    90    #. y^2-4ax
    91 
    91   
    92 {{{ Type n(pi)
    92 Please, pause the video here. Do the exercise and then continue. 
    93    	n(e)
    93 
    94 	n(oo) 
    94 The solution is on your screen.
    95     On the sage notebook }}}  
    95 
       
    96 
       
    97 Sage also provides a few built-in constants which are commonly used in mathematics .
       
    98 
       
    99 example : pi,e,infinity , Function n gives the numerical values of all these constants.
       
   100 
       
   101 {{{ Type n(pi) n(e) n(oo) On the sage notebook }}}
    96 
   102 
    97 
   103 
    98 
   104 
    99 If you look into the documentation of function "n" by doing
   105 If you look into the documentation of function "n" by doing
   100 
   106 
   128    sin(pi/2)
   134    sin(pi/2)
   129    
   135    
   130    arctan(oo)
   136    arctan(oo)
   131      
   137      
   132    log(e,e)
   138    log(e,e)
       
   139 
       
   140 Following is are exercises that you must do. 
       
   141 
       
   142 %% %% Find the values of the following constants upto 6 digits  precision 
       
   143    
       
   144    1. pi^2
       
   145    #. euler_gamma^2
       
   146 
       
   147 
       
   148 %% %% Find the value of the following.
       
   149 
       
   150    1. sin(pi/4)
       
   151    #. ln(23)  
       
   152 
       
   153 Please, pause the video here. Do the exercises and then continue. 
       
   154 
       
   155 The solutions are on your screen.
       
   156 
   133 
   157 
   134 
   158 
   135 Given that we have defined variables like x,y etc .. , We can define
   159 Given that we have defined variables like x,y etc .. , We can define
   136 an arbitrary function with desired name in the following way.::
   160 an arbitrary function with desired name in the following way.::
   137 
   161 
   155 
   179 
   156 ::
   180 ::
   157       
   181       
   158 
   182 
   159       var('x') 
   183       var('x') 
   160       h(x)=x^2 g(x)=1 
   184       h(x)=x^2 
       
   185       g(x)=1 
   161       f=Piecewise(<Tab>
   186       f=Piecewise(<Tab>
   162 
   187 
   163 {{{ Show the documentation of Piecewise }}} 
   188 {{{ Show the documentation of Piecewise }}} 
   164     
   189     
   165 ::
   190 ::
   166       f=Piecewise([[(0,1),h(x)],[(1,2),g(x)]],x) f
   191       f=Piecewise([[(0,1),h(x)],[(1,2),g(x)]],x) 
       
   192       f
       
   193 
   167 
   194 
   168 
   195 
   169 
   196 
   170 
   197 
   171 We can also define functions which are series 
   198 We can also define functions which are series 
   182 
   209 
   183 For a convergent series , f(n)=1/n^2 we can say ::
   210 For a convergent series , f(n)=1/n^2 we can say ::
   184    
   211    
   185    var('n') 
   212    var('n') 
   186    function('f', n)
   213    function('f', n)
   187 
       
   188    f(n) = 1/n^2
   214    f(n) = 1/n^2
   189 
       
   190    sum(f(n), n, 1, oo)
   215    sum(f(n), n, 1, oo)
   191 
   216 
   192  
   217  
   193 Lets us now try another series ::
   218 Lets us now try another series ::
   194 
   219 
   197     sum(f(n), n, 1, oo)
   222     sum(f(n), n, 1, oo)
   198 
   223 
   199 
   224 
   200 This series converges to pi/4. 
   225 This series converges to pi/4. 
   201 
   226 
       
   227 
       
   228 Following  are exercises that you must do. 
       
   229 
       
   230 %% %% Define the piecewise function. 
       
   231    f(x)=3x+2 
       
   232    when x is in the closed interval 0 to 4.
       
   233    f(x)=4x^2
       
   234    between 4 to 6. 
       
   235    
       
   236 %% %% Sum  of 1/(n^2-1) where n ranges from 1 to infinity. 
       
   237 
       
   238 Please, pause the video here. Do the exercise(s) and then continue. 
   202 
   239 
   203 Moving on let us see how to perform simple calculus operations using Sage
   240 Moving on let us see how to perform simple calculus operations using Sage
   204 
   241 
   205 For example lets try an expression first ::
   242 For example lets try an expression first ::
   206 
   243 
   265      f.substitute(phi=root)
   302      f.substitute(phi=root)
   266 
   303 
   267 as we can see when we substitute the value the answer is almost = 0 showing 
   304 as we can see when we substitute the value the answer is almost = 0 showing 
   268 the solution we got was correct.
   305 the solution we got was correct.
   269 
   306 
       
   307 Following is an (are) exercise(s) that you must do. 
       
   308 
       
   309 %% %% Differentiate the following. 
       
   310       
       
   311       1. sin(x^3)+log(3x)  , degree=2
       
   312       #. x^5*log(x^7)      , degree=4 
       
   313 
       
   314 %% %% Integrate the given expression 
       
   315       
       
   316       sin(x^2)+exp(x^3) 
       
   317 
       
   318 %% %% Find x
       
   319       cos(x^2)-log(x)=0
       
   320       Does the equation have a root between 1,2. 
       
   321 
       
   322 Please, pause the video here. Do the exercises and then continue. 
   270 
   323 
   271 
   324 
   272 
   325 
   273 Lets us now try some matrix algebra symbolically ::
   326 Lets us now try some matrix algebra symbolically ::
   274 
   327 
   284 ::
   337 ::
   285     A.det() 
   338     A.det() 
   286     A.inverse()
   339     A.inverse()
   287 
   340 
   288 
   341 
   289 
   342 Following is an (are) exercise(s) that you must do. 
   290 {{{ Part of the notebook with summary }}}
   343 
       
   344 %% %% Find the determinant and inverse of :
       
   345 
       
   346       A=[[x,0,1][y,1,0][z,0,y]]
       
   347 
       
   348 Please, pause the video here. Do the exercise(s) and then continue. 
       
   349 
       
   350 
       
   351 
       
   352 
       
   353 {{{ Show the summary slide }}}
   291 
   354 
   292 So in this tutorial we learnt how to
   355 So in this tutorial we learnt how to
   293 
   356 
   294 
   357 
   295 * We learnt about defining symbolic expression and functions.  
   358 * We learnt about defining symbolic expression and functions.