Some symbolic calculation ideas, Integral Tables etc.

Jari-Pekka Ikonen jari-pekka.ikonen at kolumbus.fi
Thu Jul 5 12:49:05 CEST 2012


Hi,

One can do symbolic calculations with Scilab using expression handlers of character strings.

To do it easier one could use classes (symbolic class etc.).

**********************************************************************************************************************************************************************
Here is one idea about how to generate Integral Tables having differentiation of expressions available: (compare Issue 3311 SymPy development)

To create an Integral <-> Integrand Table for all achievable Integral expressions one needs to create all expression-trees including all functions and functionlike expression quantities (==fnq), like:

Constants,Variables, +,-,*,/,^,f1(arg1),f2(arg1,arg2),...,fn(arg1,...,argn),
Diff1(f,x),Diff2(f,x,y),...,Diffn(f,x0,x1,...,xn),
Integrate1(f,x1,x1a,x1b),Integrate2(f,x,y,xa,xb,ya,yb),...,
Integraten(f,x0,x1,...,xn,x1a,x1b,x2a,x2b,...,xna,xnb),

where every argument is also an expressiontree.

Every fnq can be numbered, so every expression is equivalent to a numbertree.

Now: To construct all expressions up to N fnq:s in it one can start from simplest (one fnq, no arguments), list all fnq:s like that and then proceed to two, three etc. up to N fnqs.The result will always become a number tree.


I think Scilab should include a procedure call that would return all these fnq-expressions (as number trees or as expressions) in a Table:


Allcombinations_fnq(N)

Then differentiating this Table (at easies using number trees) of all expressions would give an Integral Table as such.Then all linear combinations would also be Integral Tables. 

Applying all available transformation rules would then give alternative versions of same integrals.

To solve an integral it is then enough to create the number tree of an Integrand and use the Integral Table, which is fast.
Comment 1 by project member asmeurer at gmail.com, Jun 27, 2012 
Do you know of any other computer algebra systems that do something like this so we can see how they have it implemented?

Comment 2 by jari-pek... at kolumbus.fi, Today (13 hours ago) 
Matlab with Symbolic Math Toolbox can use and execute text M-files, that can also be variables and created runtime by Matlab code.

To create an expression tree including a subset of all functionlike expression items (==fnq) one needs following variables:

isfnqincluded = [0,0,0,1,0,1,1,1,1,0,0]; % where 0 is not included and 1 is included

Then isfnqincluded(nfnq) tells if fnq number nfnq is included in the expression item handling or not. Items can be like:

Itemname     Itemnumber   Item value        Itemtype          arguments   arg.types     

Constant         1    (value of the constant)   (Const types)           0       []
Variable          2       "variable name"          (Variable types)        1       [(argtype)]
fn1                 3       "function name"          (fn1 type)                 n       [t1,t2,t3,...,tn]
...
sin                10       "sin"                         (sin types)                1   [(int,rat,real or complex)]
atan2            11       "atan2"                     (atan2 types)             2   [2x(int,rat,real or complex)]
...
Diff               50       "differentiation"           (Diff types)                4       [ta,tb,expr,diffvar]
Integrate       51       "integration"               (Integrate types)        4       [ta,tb,expr,intgvar]
...

etc. for all fnq:s

Allexpressionscanners scan through all combinations of expression items to create on valid expression at a time. Easiest way is probably from bottom to top.
First looping (Loop 1....Loop P+1) gives every expression item an unique number (loop counter value common to all following loops is Ifnq):

Loop 1:

Pick 0 argument expression items:

Ifnq=1
Itemnumbers:  1, type 1st
Ifnq+=1   % This is C, replace same for MATLAB Ifnq=Ifnq+1
Itemnumbers:  1, type 2nd
Ifnq+=1
Itemnumbers:  1, type 3rd
Ifnq+=1
Itemnumbers:  1, type 4th
Ifnq+=1
Itemnumbers:  1, type 5th
Ifnq+=1

...(rest with 0 arguments)

% Above loop results as an input of fnq:s with 0 arguments, certain types.
% At any expression later on these can be replaced to an argument place
% needed to be of that certain type.

Loop 2

Pick 1 argument expression items:

Ifnq+=1
Itemnumbers:  2, type 1st
Ifnq+=1
Itemnumbers:  2, type 2nd
Ifnq+=1
Itemnumbers:  2, type 3rd
Ifnq+=1
Itemnumbers:  2, type 4th
Ifnq+=1
Itemnumbers:  2, type 5th
Ifnq+=1
...
Ifnq+=1
Itemnumbers:  10, type 1st
Ifnq+=1
Itemnumbers:  10, type 2nd
Ifnq+=1
Itemnumbers:  10, type 3rd
Ifnq+=1
Itemnumbers:  10, type 4th
Ifnq+=1
Itemnumbers:  10, type 5th
Ifnq+=1
...(rest with 1 arguments)

% Above loop results as an input of fnq:s with 1 arguments, certain types.
% At any expression later on these can be replaced to an argument place
% needed to be of that certain type.

Loop 3

Pick 2 argument expression items:

Ifnq+=1
Itemnumbers:  11, type 1st
Ifnq+=1
Itemnumbers:  11, type 2nd
Ifnq+=1
Itemnumbers:  11, type 3rd
Ifnq+=1
Itemnumbers:  11, type 4th
Ifnq+=1
Itemnumbers:  11, type 5th
Ifnq+=1
...(rest with 2 arguments)

% Above loop results as an input of fnq:s with 2 arguments, certain types.
% At any expression later on these can be replaced to an argument place
% needed to be of that certain type.

Loop 4

Pick 3 argument expression items:

Ifnq+=1
Itemnumbers:...(rest with 3 arguments, certain types)

% Above loop results as an input of fnq:s with 3 arguments, certain types.
% At any expression later on these can be replaced to an argument place
% needed to be of that certain type.
...

Loop K

Pick K-1 argument expression items:

Ifnq+=1
Itemnumbers:...(rest with K-1 arguments, certain types)

% Above loop results as an input of fnq:s with K-1 arguments, certain types.
% At any expression later on these can be replaced to an argument place
% needed to be of that certain type.

If there are no expression items having more than P items, then P+1:th Loop is the last in this list.The idea is to have a counter that gives every loop result an unique number to identify it later on.


Next looping level starts to create "all expressions" list.
This may be easier from Top to bottom:

Starting at Expression outermost fnq, say start level is Ilevel=Ifnqtop.

% Ilevel handling is this:

Pick each Ifnq-list item having level Ilevel
   For each of these items replace all arguments by Ilevel-1 loop handling results. 
   When Ilevel reaches 0 replace rest argument places with 0 argument expression Items

% This way all Ifnq:s will be used and all arguments will have all Ifnq:s down to
% Ilevel 0 where rest of the argument places are replaced by constants.
% This algorithm also includes all types of arguments in all argument places.
% Final scan could drop away all those alternatives that are not valid, or previous
% algorithm could simply include type checking and drop away alternatives that are
% not valid.


% In MATLAB it is then easy to replace Ifnq:s numbers with actual expression,
% differentiate this (using Symbolic Math Toolbox) and again replace the
% expression items
% (function names etc) with Ifnq values with all types or certain types.

% Linear combinations and transformation rules can also be applied using the
% Symbolic Math Toolbox which gives alternate forms to same differentiations.
% Reading differentiation results other way round will give an Integral Table
% of all available expressions. Of course one then needs an
% Expression to Ifnq-expression converter which is just a replace loop.

% If one handles MATLAB/Programming Language code also as fnq:s one can
% this way create
% "all available algorithms"-trees, which may be of more use in quantum computers.
% Also some codetree optimization issues as well as
% "finding all algorithms suitable to a task" up to a certain complexity
% can be handled.
% 
% One could also utilise this to handle "Mathematics world to Digital World 
% relations" possibilities.

Comment 4 by jari-pek... at kolumbus.fi, Today (moments ago) 
To prove an Integral solution stepwise from this table one needs following:

Inversed(transformation rules) & Inversed(linear combination) & Inversed(differentiation including inversed chain rules)



This should be relatively easy to implement using Scilab data types. Of course to include all expression items there needs to be
  a Table of Expression Items (fnq:s) available
and to differentiate them there needs to be
  a Differentiation Table available
and to transform expressions there needs to be
  an Expression Transformation Table available.

Sometimes in the Future Symbolic calculation will most probably be included in the Scilab Software.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/dev/attachments/20120705/01f684fb/attachment.htm>


More information about the dev mailing list