Google

Sparse Polynomial representation and addition

Written on:August 25, 2012
Comments are closed

Sparse Polynomial representation and addition:

Polynomial is an expression which is composed of terms, wherein terms are composed of coefficient and exponent.  An example of a polynomial is: 4x3+5x2+6x+9.  This polynomial is composed of four terms with the following sets of coefficient and exponent – {(4,3), (5,2), (6,1), (9,0)}.  Thus representation of a polynomial using arrays is straightforward.  The subscripts of the array may be considered as exponents and the coefficients may be stored at an appropriate place referred to by the subscript.  Array representation for the above example is:

arr:                9          6        5        4         coefficients

subscripts: 0         1        2         3          exponents

The above representation works fine for the above example, but for polynomials such as 5×6+7, array representation is considered feasible on account of memory usage, since it results in a sparse arrangement as follows:

 

arr    7         0         0        0        0        0          5

         0          1          2        3         4        5          6 (Subscripts)
Sparse matrix representation may be considered for the above matrix as given below:

Rows                     Cols                       Value
———————————————————–

1                              7                              2              (Total)

0                              0                              7

0                              6                              5

For addition of two polynomials using arrays, subscript-wise elements may be added to result in the polynomial containing result of addition of two polynomials.

Example:

Polynomial 1:     4x3 + 5x2 + 6x + 7

Polynomial 2:     3x3 + 4x2 + 2x + 2

———————–

7x3 + 9x2 + 8x + 9

———————–

Array Representation:

Subscripts:           0              1              2              3

———————————————————

Polynomial 1:     7              6              5              4

Polynomial 2:     2              2              4              3

Result of sum:   9              8              9               7

 
Program to represent two polynomials using arrays and compute their sum

Sorry, the comment form is closed at this time.