/******************************************************* * Program to demonstrate synthetic division * * of polynomials subroutine * * ---------------------------------------------------- * * Reference: BASIC Scientific Subroutines, Vol. II * * By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1]. * * * * C++ version by J-P Moreau, Paris. * * (www.jpmoreau.fr) * * ---------------------------------------------------- * * SAMPLE RUN: * * ( Example: Divide (x+1)^5 by (x+1) ) * * * * DIVISION OF POLYNOMIALS * * * * What is the degree of the first polynomial: 5 * * * * Input the first polynomial coefficients as prompted: * * * * C( 0) = 1 * * C( 1) = 5 * * C( 2) = 10 * * C( 3) = 10 * * C( 4) = 5 * * C( 5) = 1 * * * * What is the degree of the second polynomial: 1 * * * * Input the second polynomial coefficients as prompted:* * * * B( 0) = 1 * * B( 1) = 1 * * * * The coefficients of the resulting polynomial are: * * * * A( 0) = 1.000000 * * A( 1) = 4.000000 * * A( 2) = 6.000000 * * A( 3) = 4.000000 * * A( 4) = 1.000000 * * * *******************************************************/ #include #include #define SIZE 25 int i,n1,n2; double A[SIZE], B[SIZE], C[SIZE]; /*********************************************** * Synthetic Division of polynomials Subroutine * * -------------------------------------------- * * It is assumed that polynomial coefficients * * are real. Calculates A(x)=C(x)/B(x). * * C(x) is of order n1, B(x) is of order n2, * * A(x) is at most of order n1-n2 (n1>n2). * ***********************************************/ void Division() { //Label e100 int i,j; for (i=n1; i>n2-1; i--) { A[i-n2]=C[i]/B[n2]; if (i==n2) goto e100; for (j=0; j