The expression and summation of the unary polynomial

Source: Internet
Author: User

Symbolic polynomial operation, has become a typical use case for table processing, mathematically, a unary polynomial pn (x) can be written according to ascending:

Pn (x) =p0+p1x1+p2x2+p3x3+...+pnxn

It is determined only by the n+1 coefficients alone. Therefore, in a computer, it can be represented by a linear table P:

p= (p0,p1,p2,p3,..., PN)

The exponent I of each item is implied in the ordinal of its coefficient pi.

This section will focus on how to use the basic operation of a linear list to implement the operation of a unary polynomial.

Using the basic operation of linear list to realize the operation of one-element sparse polynomial, the abstract data type polynomial is realized.


ADT polynomial{
Data objects: d={ai | ai∈termset, i=1,2,..., m, m≥0
Each element in the Termset contains a real number representing the coefficients and an integer representing the exponent}
Data relations: r1={<ai-1, Ai>|ai-1, ai∈d, and exponential value ai-1 in <ai, i=2,......,n}
Basic operation:
Creatpolyn (&P,M)
Operation Result: Enter the coefficients and exponent of M term, establish the unary polynomial p.
Destroypolyn (&P)
Initial conditions: A unary polynomial p already exists.
Operation Result: Destroy the unary polynomial p.
Printpolyn (P)
Initial conditions: A unary polynomial p already exists.
Operation Result: Print out the unary polynomial p.
Polynlength (P)
Initial conditions: A unary polynomial p already exists.
Operation Result: Returns the number of items in a unary polynomial p.
Addpolyn (&PA,&PB)
Initial conditions: A unary polynomial pa and PB already exist.
Operation Result: completes the polynomial summation operation, namely: PA=PA+PB, and destroys one meta-polynomial Pb.
Subtractpolyn (&PA,&PB)
Initial conditions: A unary polynomial pa and PB already exist.
Operation Result: Complete the polynomial subtraction operation, namely: PA=PA-PB, and destroy the unary polynomial Pb.
Multiplypolyn (&PA,&PB)
Initial conditions: A unary polynomial pa and PB already exist.
Operation Result: complete polynomial multiplication operation, namely: PA=PAXPB, and destroy one meta-polynomial Pb.
}adt polynomial

To achieve the above definition of the unary polynomial, it is obvious that the chain storage structure should be adopted. How to implement the multi-phase addition operation represented by this linear table.

Arithmetic rules based on the addition of a unary polynomial: for the two unary polynomial all exponents of the same term, the corresponding coefficients are added, if they are not zero, it constitutes one of the "and polynomial", and for the two unary polynomial in all the index is different, then copied to the "and polynomial".

The expression and summation of the unary polynomial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.