Tuesday, April 9, 2013

Analytical derivation with Scilab

Today, I have discovered one useful function in Scilab, the derivat() function that works with expressions like
which consists of functions of linear combinations with integer exponents of one variable (in the example denoted by z).

The function derivat() implements the analytical derivation of p(z), giving the following result:

We can create this kind of expression with Scilab function poly(), like this:
-->p1 = poly([1 -2 1], 'x', 'coef')
 p1  =

                   2 
    1 - 2x + x  

-->p2 = poly([1 -4 2], 'y', 'coef')
 p2  =

                     2 
    1 - 4y + 2y  

-->p3 = poly(ones(1, 10), 'z', 'coef')
 p3  =

                 2    3    4    5    6    7    8    9 
    1 + z + z + z + z + z + z + z + z + z   

-->p4 = poly([-1 1], 't', 'roots')
 p4  =

           2 
  - 1 + t

-->s = %s; p5 = s^{-1} + 2 + 3*s
 p5  =

                     2 
    1 + 2s + 3s  
    -----------  
           s       


And so on.


Now, the derivat() function implements the analytical derivation of the given functions:

-->derivat(p1)
 ans  =

  - 2 + 2x  

-->derivat(p2)
 ans  =

  - 4 + 4y  

-->derivat(p3)
 ans  =

                    2      3      4      5      6      7      8 
    1 + 2z + 3z + 4z + 5z + 6z + 7z + 8z + 9z  

-->derivat(p4)
 ans  =

    2t  

-->derivat(p5)
 ans  =

             2 
  - 1 + 3s  
    ------  
       2    
      s     


There is a way for applying your knowledge about linear systems with a powerful open source simulation tool.

No comments: