I've used an HP28C and 15C for years. Two weeks ago my sons gave me an HP42S with both Owner's Manual and Programming Manual. I have figured everything out for the most part except for roots of polynomials. I can figure quadratics and cubics such as x^3+3x^2+9x1 but I can't get the programming syntax for 3x^39x^2+14x+7 nor can I figure any kind of quadratics. Please help me. These are a breeze to figure on the 15C and 28C. Also, is there any kind of program for the 42S that can compute complex roots of polynomials?
HP42S Help


« Next Oldest  Next Newest »

▼
06272012, 01:03 PM
▼
06282012, 12:44 AM
Hi. I guess the closest technique is the Horner's method. Think of 3x^39x^2+14x+7as ((3*x9)*X+14)*X+7If you want to use the HP42S builtin SOLVER, you could program it like this: LBL "XMPL"Now you just need to SOLVE for XMPL: [SHIFT][SOLVER]You'll see [XMPL] amongst the menu labels. Press the key right (...) below it (SoftKey) and the display will show the possible variables for solving (the Variables Menu, hence the MVAR "X"), in this case a single [X]. You can either guess a starting value (avoiding possible miscalculations) or simply press the key right above [X]. My HP42S found [X=0.3897]with the example above. Hope it helps. Cheers.
Luiz (Brazil) Edited: 28 June 2012, 1:12 p.m. after one or more responses were posted ▼
06282012, 04:18 AM
There is no need for Horner's method with this one, you can simply, though unelegantly key in LBL TST MVAR "X" RCL "X" 3 Y^X 3 * RCL "X" X^2 9 *  RCL "X" 14 * + 7 + RTN ...and than solve TST for X, that yields X=0.3897 As this is pretty straightforward, maybe I have not completely understood what the initial problem with this is...?
Edited: 28 June 2012, 4:40 a.m. ▼
06282012, 08:58 AM
Hi. I just considered that by using Horner's method to reduce a polynomial expression to a few arithmetic operations with no need for powers/exponents, the final program would be easier to be written. 8^) Cheers. Luiz (Brazil) ▼
06282012, 09:22 AM
Right, in this case two program step are spared : 001 LBL "TST 001 LBL "XMP Very similar in fact ▼
06282012, 02:13 PM
Thanks so much for helping me with the cubic equation. I tried both methods given to me to find the roots for the following quartics and I get only one root for each equation:
x^4+8x^3+9x^28x10=0 I am obviously doing something wrong. ▼
06282012, 04:08 PM
I only tried the first one but could find all four roots: 6.4495, 1.5505, 1 and 1.
It all depends on the right initial guesses, use the programmed function to calculate some values to plot it roughly, then you put in two guesses for x that are located in the vicinity of the potential roots. You do this by starting the solver, selecting the programmed function and than keying in the lower guess, press [X], upper guess, press [X] and than [X] again to solve. See the manual on further details. Edited: 28 June 2012, 5:08 p.m. after one or more responses were posted ▼
06282012, 04:25 PM
What program syntax did you use to solve the first equation? I will copy and save it for future reference.
06282012, 09:47 PM
I've found the following program at Thomas Okken's website: "G4_G3_G2.raw Solves 2nd, 3rd, and 4th order polynomials. using closedform solutions. Contributed by Christian Vetterli."
00 { 526Byte Prgm }I haven't tested it on the real HP42S, but for William's polynomial Free42 Decimal returns the following roots: XEQ G4 These match your results, considering the very small imaginary parts are actually zero.
Edited: 28 June 2012, 9:53 p.m.
06282012, 04:36 PM
That’s the problem with numeric solver; you have to initiate each root search with an appropriate initial value.
For x^4+8x^3+9x^28x10, enter the polynomial equation into you HP28C : « X 8 + X * 9 + X * 8 – X * 10  » STEQA draw the curve between x=10 up to x=+10 abscises. (10,31) DUP PMAX CHS PMINAnd start drawin the curve : DRAW
You may obtain the following graph, using cursor keys and INS key you simply have to plot positions close to the four roots. Then press ON key to exist graph . You have now in the stack the four initial values close enough to the root to use in the HP28C’s solveur (or any solveur of you alternative HP calculators). 4: (6.4706,1.0000)(Exact value may depend upon pixel positions where you press the INS key) [SOLV][SOLVR]Enter first estimate into X register : [ X ]And initiate seek of the first root : [shift][ X ]The HP28C may display ‘Solving for X’ and stop indicating that a first zero is found : #X:#1.0000#############Write down this first root or store it in a safe place (for example in the stack): 4 [shift][ ROLL ]Enter second estimate into X register: [ X ]And initiate seek of the second root: [shift] [ X ]There6.4706 value is used as the initial value and rapidly the process converges to a ‘sign reversal’ root; a root that is not exactly evaluated to zero due to limited precision of the calculator: #X:#6.4495##############
Process the same way for the two last estimates: 4 [shift] [ ROLL ] [ X ] [shift] [ X ] 4 [shift] [ROLL][ X ] [shift] [ X ] 4 [shift] [ROLL] [CURSOR]And you will have the four root of the polynomial into the stack: 4: 6.4495 For the second equation, process the same way and take advantage of your HP28C to draw the curve. It is great helper in finding how to initiate root seeking. Making all previous HP a crabs
Edited: 28 June 2012, 5:10 p.m. after one or more responses were posted ▼
06282012, 05:09 PM
Thanks for the programming syntax for the 28C. But what I actually needed was the syntax for the 42S to solve the quartic equation I referenced above. ▼
06282012, 06:35 PM
The HP42S solver is acting exactly as one the HP28C does. Main differencies are that it only use a pair of initial values to start seeking. The HP28C may use a single, a pair or a triplet as initial(s) guess entered as a list { best_guess, low_interval_guess, high_interval_guess } .
[shift][PRGM]You may enter your code as you prefer (using or not exponents or Horner’s format, whatever), simply indicate variable(s) to be put in menu by using the MVAR command. And avoid syntax error or typingbug as you have few chances on such a calculator to easily check tips. 00 { 39Byte Prgm }Leave program mode : [shift][PRGM]
Now you are ready to start the solver: [shift][SOLVER]Select the equation you just type in by pressing the corresponding softkey [ P_X ]Enter low guess and high guess for first root seeking. Here, a plot is missing that why I am in trouble trying to understanding you, as you have an HP28C which is much superior for this type of guessing! :) 6 [+/] [ X ] 2 [+/] [ X ][ X ]That make { 6 4 } the first pair of initial values to seek for the first root. Rapidly the HP42S displays first root stored in X register:  X = 3 Note that you can get the same result and investigate how the calculator is seeking by keying on a HP28C/S in its solver : { 6 4 } [ X ][shift][ X ]
Second root can be found using a different set of initial values: 2 [+/] [ X ] 0 [ X ][ X ]That make { 2 0 } as second interval to seek for the second root.  X =0.5 That is rapidly found and displayed. And so on for other guess pair to seek after the two other roots : 0 [ X ] 1 [ X ] [ X ]  X =1.5 
Finaly , last interval : 1.8 [ X ] 5 [ X ] [ X ]  X =2  But, I sorry to repeat it again, it is hard to have efficient initial guess without a graph. And nothing is as easy and convenient as a graphic calculator to quickly plot it and zoom in regions of interest. Having the shape of the function is a great help to seek after its roots!
▼
06282012, 08:00 PM
Thank you for your response. I thank everyone for their helpful responses. I totally agree with you about graphing. I have loved my 28C since I got it in 1986. As I said before, I have had a 45, 15C, 28C and a 50g. Of all, the 28C is my favorite. I'm glad I joined this forum. All of you have been incredibly helpful. ▼
06282012, 10:20 PM
Christian Vetterli's program above will compute all roots, real or complex, of polynomials up to degree 4 (if you don't mind keying in 200+ lines). Let it solve 4x^48x^313x^210x+22=0, for instance: XEQ G4
06302012, 07:57 AM
You can simplify the program above by deleting the three ENTER commands after RCL X. The HP42S solver populates the stack with the independent variable, just as the HP15C did. This is true for the integrator also. ▼
07012012, 09:19 PM
Hi. Thanks for pointing that out, but as a matter of fact, those three ENTER are actually needed. The HP42S does not actually work as the HP15C (*) because of one fact: you can have more than one unknown in an equation when writing them for the HP42S SOLVER so you can choose which unknown to solve for. That's why you may actually 'declare' the unknowns you want to solve for by using the 'MVAR' statement/function. Then your program simply returns the function value based upon the many unknowns you have previously declared. Because neither the user nor the calculator can predict which variable will be claimed for solving for, the program must be written having all possibilities being handled. As you see, right after the 'RCL "X"' there is only one copy of the variable "X" in the stack register 'X'. If you do not copy it into the whole stack, the program will not compute the polynomial expression correctly because any previously existing values in Y, Z and T will be used, instead of the actual "X" value being tested. Think of an expression with two unknowns, like "A" AND "B", whether they repeat or not in the expression. You could choose to solve for either "A" or "B", once the other is known and previously defined (stored). Then the SOLVER will compute the same expression as many times as needed for the chosen variable, and its value will be updated in the variable name itself, not in the stack registers. You see, when you have a program in the HP15C that is going to be used by the SOLVER or the numerical integrator, it must be programed in such a way that it returns the value of the function being evaluated based in one specific unknown. Some years ago the multivariable 'functionality' of the HP42S SOLVER was proposed for the HP15C by using the index register. It worked pretty fine, and the resulting programs are listed in the article forum somewhere in the far past... Hopefully I expressed myself correctly... in English, at least. Cheers. Luiz (Brazil) (*) it applies to the HP34C SOLVER and its implementation found in the MATH module for the HP41 as well.
Edited: 1 July 2012, 9:31 p.m.
06302012, 05:11 PM
Quote: Sounds like you raised him well :). 
Possibly Related Threads...  
Thread  Author  Replies  Views  Last Post  
42s questions and 42s vs 35s  snaggs  13  2,960 
09192011, 02:44 AM Last Post: snaggs 