Polynomial Division

Routine Summary

This program will divide two polynomials of any positive integer degree.

Inputs

L1- Dividend
L2- Divisor

Outputs

L3- Quotient coefficients in descending degree

Variables used

L1, L2, L3, A, B, D

Calculator Compatibility

TI-83/84/+/SE

Author

Timothy Foster

Download

polydiv.8xp

:DelVar L₃
:For(A,1,dim(L₁)+1-dim(L₂
:L₁(A)/L₂(1→L₃(A
:For(B,2,dim(L₂
:L₃(A)L₂(B
:-Ans+L₁(A+(B-1→L₁(A+(B-1
:End
:End
:ClrHome
:For(A,dim(L₁)-(dim(L₂)-2),dim(L₁
:L₁(A→L₃(1+dim(L₃
:End
:Disp "FIRST TERM
:Output(2,1,"X^
:Output(2,3,dim(L₁)-dim(L₂
:Output(3,1,L₃

This routine will solve polynomial division with any given integer degrees. The dimension of L1 is the degree+1 of the dividend polynomial, and the dimension of L2 is the degree+1 of the divisor. The numbers used in the list are the coefficients of the respective polynomial in descending degree order, including place holder 0's. So, a polynomial of 3x3+2x2-1 would need to be {3,2,0,-1}. The program outputs the code as L3 in that form. The program also displays the degree of the first term. Once you reach the x0 term, all the coefficients afterward are the remainders. So, a display of X^2 {3,2,1,5,3} says 3x2+2x+1 and a remainder of 5x+3.

The program first asks for input. It asks for the degree of each polynomial, and then it asks for the contents using a For( loop until there are no more terms. It then commences with the main loop which is another For( loop. The program works in very much the same way people would go about solving a division problem. It divides the current leading terms of the dividend by the first term of the divisor and puts it into L3, our answer. It then does a second For( loop multiplying the partial quotient by every term of the divisor. At the end, it discovers the remainder in L1 and stores them into the end of L3 for a complete answer.

Here are a couple of examples for you to try out to see if the code was inputted correctly:

(1)
\begin{align} {x^2+3x-2 \over x+1} = x+2- {4 \over x+1} \hspace{12pt} \{ 1,2,-4 \} \end{align}
(2)
\begin{align} {x^4+3x^2-2x+1 \over x^2+4x+6} = x^2-4x+13-{30x+77 \over x^2+4x+6} \hspace{12pt} \{1,-4,13,-30,-77\} \end{align}

Error Conditions

  • ERR: INVALID DIM occurs if the degrees are made negative or the divisor's degree is larger than the dividend
  • ERR: DIVIDE BY 0 happens if the leading coefficient of the divisor is 0
  • ERR: DATA TYPE is thrown if anything is imaginary

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.