# Singular

#### D.7.1.11 partial_molien

Procedure from library `finvar.lib` (see finvar_lib).

Usage:
partial_molien(M,n[,p]);
M: a 1x2 <matrix>, n: an <int> indicating number of terms in the expansion, p: an optional <poly>

Assume:
M is the return value of molien or the second return value of reynolds_molien, p ought to be the second return value of a previous run of partial_molien and avoids recalculating known terms

Return:
n terms (type <poly>) of the partial expansion of the Molien series (first n if there is no third parameter given, otherwise the next n terms depending on a previous calculation) and an intermediate result (type <poly>) of the calculation to be used as third parameter in a next run of partial_molien

Theory:
The following calculation is implemented:
 ```(1+a1x+a2x^2+...+anx^n)/(1+b1x+b2x^2+...+bmx^m)=(1+(a1-b1)x+... (1+b1x+b2x^2+...+bmx^m) ----------------------- (a1-b1)x+(a2-b2)x^2+... (a1-b1)x+b1(a1-b1)x^2+... ```

Example:
 ```LIB "finvar.lib"; ring R=0,(x,y,z),dp; matrix A[3][3]=0,1,0,-1,0,0,0,0,-1; matrix REY,M=reynolds_molien(A); poly p(1..2); p(1..2)=partial_molien(M,5); p(1); ==> 4x5+5x4+2x3+2x2+1 p(1..2)=partial_molien(M,5,p(2)); p(1); ==> 18x10+12x9+13x8+8x7+8x6 ```