HP Forums

Full Version: 48G polynomial roots to stack
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi Folks,

Using the polynomial solver on my 48G, how can I put the roots it finds onto the stack as pure numbers so I can perform individual mathmatical operations on them...i.e., I want to extract the roots from the list object that the calculator puts onto the stack, and put them in sequential stack levels. Can any of you 48G gurus out there help me with this?

Thanks very much, Hal

Hello Hal,

You just have to convert the matrix into numbers. Once you have the roots, type OBJ-> to convert the matrix to numbers. The calculator will place a number in each level plus a list with the matrix order in Level 1. Drop this list and you are ready to go.

Hope this helps.

Thanks for the response, but could you be a little more explicit...where do I type in OBJ-> (into what field?), and is the symbol that follows it a minus sign and a greater than sine, or an arrow? What key do I use to get it?

Thanks for your help, Hal

I recommend avoiding the graphical interface solver, and use the menu version of the solver. If you are working with polynomials, you can get to the polynomial solver with:

[left-shift] [7] [POLY]

where [POLY] is the [C] menu key labeled "POLY." You will then see a menu with the commands PROOT, PCOEF, and PEVAL. The command PROOT takes as input a vector of coefficients, and returns a vector of roots. For example, the polynomial x^2-4x-5 factors into (x+1)(x-5), so its roots are -1 and 5. The coefficient vector is [1 -4 -5] and the roots vector is [-1 5]

Thus, if you enter [1 -4 -5] and then press PROOT, you will get [-1 5] on the stack. Now, with [-1 5] on the stack, pressing PCOEF will return [1 -4 -5], the coefficient vector corresponding to the polynomial with roots -1 and 5.

PEVAL takes a coefficient vector and a real number and evaluates the polynomial at the specified value. For example, enter [1 -4 -5] and 3 and pressing PEVAL will return 1*(3)^2 - 4*(3) - 5.

To get back to your original goal, suppose you want the roots of the polynomial x^2-4x-5. Then you would enter [1 -4 -5] and then press the menu key PROOT (or just type in the command PROOT). Then if you want the each root on its own stack level, type: OBJ-> DROP (the number that is DROP'ed is the size of the vector or number of distinct roots, in this case, 2)

Hello Hal,

To execute OBJ->, activate the alpha keyboard by pressing ALPHA twice, type OBJ-> and then press ENTER.

You can also go to the program menu, pressing PRG, then TYPE. One of the menu functions is OBJ->

Hope this helps.

Thanks Han,

But I'm still having trouble with the "OBJ->DROP" command. Do I type it into the command line? Then what do I do (hiting ENTER didn't seem to do anything except put what I had just typed into level 1). What keys do I use to type the arrow after OBJ? Is it the right shifted arrow above the "1" key? Also, do I type in DROP using the alpha keyboard, or is it the shifted backspace key?
I guess I need an explicit keystroke sequence on how to get OBJ->DROP into the machine and execute it.

Thanks for you help, Hal

Here is a walkthrough, based on my 48GX. Suppose you are using the polynomial root solver on the 48GX. You want the roots of x^2-4x-5. So you enter [1 -4 -5] and press SOLVE. The 48GX returns [-1 5].

If you exit to the stack, you have "Roots: [-1 5]" on level 1.

Now hit the "H" key (for PRG), then the "C" key (for TYPE), and then the "A" key (for OBJ->). The useful OBJ-> command breaks down whatever object is on the stack. In this case, it puts the array [-1 5] on stack level 2, and the text "Roots" on stack level 1.

You presumably don't need the text, so press the backspace (<-) key to delete it. This drops [-1 5] to level 1.

Now hit OBJ-> again for further breakdown. You get { 2 } on level 1 (which was the number of elements in the array), and the two roots on levels 2 and 3. You can delete the { 2 }, leaving your roots on levels 1 and 2.

You can also invoke OBJ-> by hitting the "alpha" key twice (to lock it), followed by O, B, J, right-shift, zero, and ENTER. I prefer the menu method (PRG TYPE OBJ->) described above.

Edited: 11 Dec 2006, 3:42 p.m.

Yes, Yes!!!

I see the light...the right shifted zero key...the PRG, TYPE OBJ menu keys. What a fantastic function (now that I finally know how to access it)!! I see by experimenting with the other TYPE menu soft-keys that I can just as easily put any specified number of stack elements back into a list. Wow, what a machine!
Thanks for the help.
Hal

OBJ-> DROP

two commands (space after the > and before the 'D')