TI-BASIC:Polynomial Division

From Learn @ Cemetech
Jump to navigationJump to search

Routine Summary

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


L,,1,,- Dividend L,,2,,- Divisor


L,,3,,- Quotient coefficients in descending degree

Variables used

L,,1,,, L,,2,,, L,,3,,, A, B, D

Calculator Compatibility



Timothy Foster




:DelVar L₁DelVar L₂
:Input "DIVIDEND ",A
:Input "DIVISOR ",B
:Disp "
:Input D
:Disp "
:Input D


:DelVar L₃

This routine will solve polynomial division with any given integer degrees. The dimension of L,,1,, is the degree+1 of the dividend polynomial, and the dimension of L,,2,, 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 L,,3,, 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 L,,3,,, 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 L,,1,, and stores them into the end of L,,3,, for a complete answer.

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


{{Template:TI-BASIC:Math |eqn= {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\} }}

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