Algorithm for performing synthetic division to generate the tail-canceling polynomial :
int i,j; double *w=(double *)malloc((P+1)*sizeof(double)); /*** load the numerator coefficients for B(z) ***/ for(i=0;i<P+1;i++){ w[i]=b[i]; } /*** do synthetic division ***/ for(i=0; i<=N; i++){ factor=w[0]; for(j=0;j<P;j++){ w[j]=w[j+1]+factor*a[j]; } w[P]=0; /**** The remainder after the i-th step is in w[0..(P-1)] ***/ } /*** copy the result to the output array ***/ for(i=0;i<P;i++) { bb[i]=w[i]; }