• Welcome to Valhalla Legends Archive.
 

Program the Rational Roots Theorem Using TI-83 BASIC

Started by Dynobird, October 09, 2005, 04:48 PM

Previous topic - Next topic

Dynobird

Given that the rational roots theorem states that given a (factorable) polynomial...
{
a_n * x^n + a_n-1 * x^(n-1) ... + a_0
The possible rational roots* are p/q
Where p are the factors of a_0 and q are the factors of a_n.
(The reasoning behind this is the potential roots of (3x-5) will be p/q = 5/3, p/q = -(5/3) since the a_n and q cancel out.)
Note: these factors p and q give you a pool of possible outcomes.  You may have many potential roots that aren't actual roots.
So you must plug them all into your calculator.
}

Make a program that finds all the rational roots for any given (factorable) polynomial.

* rational means it can be expressed as integer/integer
   - for example: .6 barred is rational because its 2/3
   - pi is not, sq. root of 5 also is not
   - negative numbers are also rational, so is zero ( 0 / 1 )

Time-Saver: I used lists for my databases, to store values in them and to iterate through them.
BTW, for those who don't have a keyboard for their TI-83 or don't know the language you can look it up online somewhere and post it here.
Programming on a calc w/o a keyboard is a major pain in the ass.

CrAzY

If your factoring, its easiest just to program for trinomials...  Those are used most in class :-/
CrAzY

Yoni


rabbit

T.T
I'm doing this in number theory now...except with Gaussian integers and not a calculator (go pen + paper).  I don't have a keyboard for my calculator, yet I program all the time.  In fact, here is the bestest program ever:
:A->0
:Lbl 1
:A+1->A
:Disp A
:Goto 1


I honestly have no idea how to start this out...
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Dynobird

Hints:
Utilize your calculator's easy-to-use extensive math capabilities.
I mean, compare this to Sun's pitiful java.lang.Math !
So when getting factors, you can use the greatest integer function (or rounding).
Example, is p/q a factor? If p/q == greatestinteger(p/q) then p/q = factor.

Of course, in calculator BASIC you write to lists to store your factors.
So here's an example:


:1 -> I                          // for index
:If p/q == int(p/q)
:Then
:p/q -> L_1(I)
:I+1 -> I
:END                       // WTF did they not make ++/-- operators!


I know this is not a fun thing to program, lol, but it's really useful if you take precalc or are going to.
Especially once you combine it with a program that does quadratic formula, quadr. formula with complex numbers,
and a program that reads from a table in order to find irrational roots (still working on that!)
In a precalc class, this program (** if efficient **) would be like the power of the sun in the palm of your hand!
(Yes, I know it's a spiderman reference ::) )

Joe[x86]

Quote from: rabbit on October 13, 2005, 05:06 PM
T.T
I'm doing this in number theory now...except with Gaussian integers and not a calculator (go pen + paper). I don't have a keyboard for my calculator, yet I program all the time. In fact, here is the bestest program ever:
:A->0
:Lbl 1
:A+1->A
:Disp A
:Goto 1


I honestly have no idea how to start this out...

:Lbl 1
:Disp "Hello."
:Goto 1
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

rabbit

Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Ender

The rational roots theorem says that given the polynomial:

(Ax-a)(Bx-b)(Cx-c) ...

The possible factors roots, x, are  a/A  b/B   c/C etc. You can find these by taking the factors of the constant term and the coefficient of the leading term, since ABC ... are multiplied together to make the coefficient of the leading term, and abc ... are multiplied together to make the constant term.  Factoring the constant term and the coefficient of the leading term get you the possible pool of factors.

This is very useful for factoring a polynomial in expanded form

Such as axn + bxn-1 + ... +  the constant term.

So to program this on your calculator, you take the coefficient of the leading term. TI-83's don't have the mod function, but you can use the greatest integer function or the rounding function in place of this. The greatest integer function looks like int( ) in math -> num.

The simplest factoring program to make just takes an integer n and divides it by 1, 2, 3, 4, ... , n and sees if the integer n / possible factor == int ( n / possible factor)         

So for instance, if 4 is a factor of 6, then 6/4 == int ( 6 / 4 ) => 1.5 == 1    And we see that four is not a factor of six.

After you factor the coefficient of the leading term and the constant term, plug in the factors of the constant term divided by the factors of the coefficient of the leading term as x. Obviously, you will need a few loops to do this. Less obviously, you are best off using lists to store your data.