Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Basic Polynomial Operations

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

The basic polynomial operations include the following operations:

  • Finding the order of a polynomial
  • Evaluating a polynomial
  • Adding, subtracting, multiplying, or dividing polynomials
  • Determining the composition of a polynomial
  • Determining the greatest common divisor of two polynomials
  • Determining the least common multiple of two polynomials
  • Calculating the derivative of a polynomial
  • Integrating a polynomial
  • Finding the number of real roots of a real polynomial

The following equations define two polynomials used in the following sections.

P(x) = a0 + a1x + a2x2 + a3x3 = a3(xp1)(xp2)(xp3) (A)
Q(x) = b0 +b1x + b2x2 = b2(xq1)(xq2) (B)

Order of Polynomial

The largest exponent of the variable determines the order of a polynomial. The order of P(x) in Equation A is three because of the variable x3. The order of Q(x) in Equation B is two because of the variable x2.

Polynomial Evaluation

Polynomial evaluation determines the value of a polynomial for a particular value of x, as shown by the following equation.

(C)

Evaluating an nth-order polynomial requires n multiplications and n additions.

Polynomial Addition

The addition of two polynomials involves adding together coefficients whose variables have the same exponent. The following equation shows the result of adding together the polynomials defined by Equations A and B.

P(x) + Q(x) = (a0 + b0) + (a1 + b1)x +(a2 + b2)x2 + a3x3 (D)

Polynomial Subtraction

Subtracting one polynomial from another involves subtracting coefficients whose variables have the same exponent. The following equation shows the result of subtracting the polynomials defined by Equations A and B.

P(x) – Q(x) = (a0b0) + (a1b1)x + (a2b2)x2 + a3x3 (E)

Polynomial Multiplication

Multiplying one polynomial by another polynomial involves multiplying each term of one polynomial by each term of the other polynomial. The following equations show the result of multiplying the polynomials defined by Equations A and B.

P(x)Q(x) = (a0 + a1x + a2x2 + a3x3)(b0 + b1x + b2x2)

= a0(b0 + b1x + b2x2) + a1x(b0 + b1x + b2x2)

+ a2x2(b0 + b1x + b2x2) + a3x3(b0 + b1x + b2x2)

= a3b2x5 + (a3b1 + a2b2)x4 + (a3b0 + a2b1 + a1b2)x3

+ (a2b0 + a1b1 + a0b2)x2 + (a1b0 + a0b1)x + a0b0 (F)

Polynomial Division

Dividing the two polynomials P(x) and Q(x) results in the quotient U(x) and remainder V(x), such that the following equation is true.

P(x) = Q(x)U(x) + V(x) (G)

For example, the following equations define polynomials P(x) and Q(x).

P(x) = 5 – 3xx2+ 2x3 (H)
Q(x) = 1 – 2x + x2 (I)

Complete the following steps to divide P(x) by Q(x).

  1. Divide the highest order term in Equation H by the highest order term in Equation I.

    (J)

  2. Multiply the result of Equation J by Q(x) from Equation I.
    2xQ(x) = 2x – 4x2 + 2x3 (K)
  3. Subtract the product of Equation K from P(x).
    (L)

    The highest order term becomes 3x2.

  4. Repeat step 1 through step 3 using 3x2 as the highest term of P(x).
    1. Divide 3x2 by the highest order term in Equation I.

      (M)

    2. Multiply the result of Equation M by Q( x) from Equation I.
      3Q(x) = 3x2 – 6x + 3 (N)
    3. Subtract the result of Equation N from 3x2 – 5x + 5.

      (O)

      Because the order of the remainder x + 2 is lower than the order of Q(x), the polynomial division procedure stops. The following equations give the quotient polynomial U(x) and the remainder polynomial V(x) for the division of Equation H by Equation I.

      U(x) = 3 + 2x (P)
      V(x) = 2 + x (Q)

Polynomial Composition

Polynomial composition involves replacing the variable x in a polynomial with another polynomial. For example, replacing x in Equation A with the polynomial from Equation B results in the following equation.

P(Q(x)) = a0 + a1Q(x) + a2(Q(x))2 + a3(Q(x))3

= a0 + Q(x){a1 + Q(x)[a2 +a3Q(x)]} (R)

where P(Q(x)) denotes the composite polynomial.

Greatest Common Divisor of Polynomials

The greatest common divisor of two polynomials P(x) and Q(x) is a polynomial R(x) = gcd(P(x), Q(x)) and has the following properties:

  • R(x) divides P(x) and Q(x).
  • C(x) divides P(x) and Q(x) where C(x) divides R(x).

The following equations define two polynomials P(x) and Q(x).

P(x) = U(x)R(x) (S)
Q(x) = V(x)R(x) (T)

where U(x), V(x), and R(x) are polynomials.

The following conditions are true for Equations R and S:

  • U(x) and R(x) are factors of P(x).
  • V(x) and R(x) are factors of Q(x).
  • P(x) is a multiple of U(x) and R(x).
  • Q(x) is a multiple of V(x) and R(x).
  • R(x) is a common factor of polynomials P(x) and Q(x).

If P(x) and Q(x) have the common factor R(x), and if R(x) is divisible by any other common factors of P(x) and Q(x) such that the division does not result in a remainder, R(x) is the greatest common divisor of P(x) and Q(x). If the greatest common divisor R(x) of polynomials P(x) and Q(x) is equal to a constant, P(x) and Q(x) are coprime.

You can find the greatest common divisor of two polynomials by using Euclid's division algorithm and an iterative procedure of polynomial division. If the order of P(x) is larger than Q(x), you can complete the following steps to find the greatest common divisor R(x).

  1. Divide P(x) by Q(x) to obtain the quotient polynomial Q1(x) and remainder polynomial R1(x).

    P(x) = Q(x) Q1(x) + R1(x)

  2. Divide Q(x) by R1(x) to obtain the new quotient polynomial Q2(x) and new remainder polynomial R2(x).

    Q(x) = R1(x)Q2(x) + R2(x)

  3. Divide R1(x) by R2(x) to obtain Q3(x) and R3(x).

    R1(x) = R2(x)Q3(x) + R2(x)

    R2(x) = R3(x) Q4(x) + R4(x)

If the remainder polynomial becomes zero, as shown by the following equation,

Rn – 1(x) = Rn(x)Qn + 1(x) (U)

the greatest common divisor R(x) of polynomials P(x) and Q(x) equals Rn(x).

Least Common Multiple of Two Polynomials

Finding the least common multiple of two polynomials involves finding the smallest polynomial that is a multiple of each polynomial.

P(x) and Q(x) are polynomials defined by Equations R and S, respectively. If L(x) is a multiple of both P(x) and Q(x), L(x) is a common multiple of P(x) and Q(x). In addition, if L(x) has the lowest order among all the common multiples of P(x) and Q(x), L(x) is the least common multiple of P(x) and Q(x).

If L(x) is the least common multiple of P(x) and Q(x) and if R(x) is the greatest common divisor of P(x) and Q(x), dividing the product of P(x) and Q(x) by R(x) obtains L(x), as shown by the following equation.

(V)

Derivatives of a Polynomial

Finding the derivative of a polynomial involves finding the sum of the derivatives of the terms of the polynomial.

Equation V defines an nth-order polynomial, T(x).

T(x) = c0 + c1x + c2x2 + … + cnxn (W)

The first derivative of T(x) is a polynomial of order n – 1, as shown by the following equation.

(X)

The second derivative of T(x) is a polynomial of order n – 2, as shown by the following equation.

(Y)

The following equation defines the kth derivative of T(x).

(Z)

where kn.

The Newton-Raphson method of finding the zeros of an arbitrary equation is an application where you need to determine the derivative of a polynomial.

Integrals of a Polynomial

Finding the integral of a polynomial involves the summation of integrals of the terms of the polynomial.

Indefinite Integral of a Polynomial

The following equation yields the indefinite integral of the polynomial T(x) from Equation V.

(AA)

Because the derivative of a constant is zero, c can be an arbitrary constant. For convenience, you can set c to zero.

Definite Integral of a Polynomial

Subtracting the evaluations at the two limits of the indefinite integral obtains the definite integral of the polynomial, as shown by the following equation.

(AB)
(AC)
(AD)

Number of Real Roots of a Real Polynomial

For a real polynomial, you can find the number of real roots of the polynomial over a certain interval by applying the Sturm function.

If

P0(x) = P(x) (AE)

and

(AF)

the following equation defines the Sturm function.

(AG)

where Pi(x) is the Sturm function and

(AH)

represents the quotient polynomial resulting from the division of Pi – 2(x) by Pi – 1(x).

You can calculate Pi(x) until it becomes a constant. For example, the following equations show the calculation of the Sturm function over the interval (–2, 1).

P0(x) = P(x) = 1 – 4x + 2x3 (AI)
(AJ)
(AK)
(AL)
= –1 + (8/3)x (AM)
(AN)
(AO)
= 101/32 (AP)

To evaluate the Sturm functions at the boundary of the interval (–2, 1), you do not have to calculate the exact values in the evaluation. You only need to know the signs of the values of the Sturm functions. The following table lists the signs of the Sturm functions for the interval (–2, 1).

x P0(x) P1(x) P2(x) P3(x) Number of Sign Changes

–2

+

+

3

1

+

+

+

1

In the previous table, notice the number of sign changes for each boundary. For x = –2, the evaluation of Pi(x) results in three sign changes. For x = 1, the evaluation of Pi(x) results in one sign change.

The difference in the number of sign changes between the two boundaries corresponds to the number of real roots that lie in the interval. For the calculation of the Sturm function over the interval (–2, 1), the difference in the number of sign changes is two, which means two real roots of polynomial P(x) lie in the interval (–2, 1). The following figure shows the result of evaluating P(x) over (–2, 1).

In the previous figure, the two real roots lie at approximately –1.5 and 0.26.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit