48G polynomial roots to stack



#10

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


#11

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.


#12

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


#13

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)


#14

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


#15

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.


#16

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

#17

OBJ-> DROP

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

#18

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.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Polynomial program Michael Carey 12 898 11-20-2013, 08:43 PM
Last Post: CR Haeger
  HP prime: logs and roots Alberto Candel 5 485 11-20-2013, 12:31 PM
Last Post: Manolo Sobrino
  HP 50g - select characters on the stack, copy/paste Sean Freeman 7 711 11-20-2013, 07:11 AM
Last Post: Sean Freeman
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 530 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 538 11-11-2013, 02:19 PM
Last Post: Thomas Radtke
  HP Prime Stack operations from within a program John Colvin 1 360 11-08-2013, 09:45 PM
Last Post: Helge Gabert
  HP Prime polynomial long division bluesun08 13 979 10-30-2013, 03:29 AM
Last Post: parisse
  Prime: Anyway to refresh stack? kris223 5 537 10-16-2013, 05:09 PM
Last Post: kris223
  hp prime - sending program results to the stack giancarlo 6 628 10-15-2013, 02:00 AM
Last Post: Giancarlo
  HP Prime - RPN stack access from programs? Mike Mander (Canada) 10 733 09-30-2013, 11:20 AM
Last Post: steindid

Forum Jump: