Post Reply 
WP 34S Solver
05-26-2015, 07:36 PM (This post was last modified: 05-26-2015 07:56 PM by AnalogJoe.)
Post: #1
WP 34S Solver
Hi, I just bought a WP 34S calculator, I really like it however the learning curve is quite steep with this one. I've been a long time HP user, however most of my experience comes from using the "bigger" HP calculators such as the 48GX and 50G series.

I've been trying to understand the Solve function, to be honest the documentation on the WP 34S is really poor, so I've been reading the Hp 15c manual which apparently is quite similar to the way things are done in the WP 34S.

Im trying to find the roots of polynomials, the WP 34S has a dedicated quadratic solver, but I want to know how to find the roots of higher order polynomials such as 3rd order, etc..

Im doing the following test program, my goal here is to find the roots of the following simple quadratic equation: x^2 + 5x + 1=0

Following the 15c examples in the manual I hit 'h' then P/R

and type:

LBL 00
2
y^x
x<>y
5
x
1
+
RTN


I enter 2 initial guesses which are 1 and 2 in the X and Y registers, then I hit SLV 00

The calculator works a little while and displays: -0.2

The correct roots are -0.208712152 and -4.791287847

So the solution is considerably off the correct result. Also no matter what initial values I enter, I cant get the calculator to display something near -4.79 which is the second root.

My hope is that once I figure out how to solve quadratic equations solving cubics will be easy.

Any idea what am I doing wrong? also, does the calculator support complex roots using the the SLV function?
Find all posts by this user
Quote this message in a reply
05-26-2015, 07:58 PM (This post was last modified: 05-26-2015 08:01 PM by Dieter.)
Post: #2
RE: WP 34S Solver
(05-26-2015 07:36 PM)AnalogJoe Wrote:  Im doing the following test program, my goal here is to find the roots of the following simple quadratic equation: x^2 + 5x + 1=0

OK. But that's not what you programmed:

(05-26-2015 07:36 PM)AnalogJoe Wrote:  LBL 00
2
y^x
x<>y
5
x
1
+
RTN

There is a "+" missing after the "5 x". This way the function you provide is simply 5x + 1. And an additional x² that is left in Y.

Now guess where 5x + 1 becomes zero. ;-)

(05-26-2015 07:36 PM)AnalogJoe Wrote:  The calculator works a little while and displays: -0.2

Got it now? ;-)
Simply provide the correct function, and you'll get what you want:

Code:
LBL 00

x<>y
5
*
+
1
+
RTN

BTW, do not use y^x as it is quite slow. There is a x² function that is shorter and much faster.

BTW2, "real cowboys" use Horner's method, for instance like this:
Code:
LBL 00
5
+
*
1
+
RTN

Looking at the equation you know that the roots will be negative, so try 0 and –5 as the two initial estimates.

Code:
0  ENTER  -5  SLV 00
=> -0,20871215252208...

-2  ENTER  -10  SLV 00
=> -4,7912878474779...

There you are.

(05-26-2015 07:36 PM)AnalogJoe Wrote:  Now the correct roots are -0.208712152 and -4.791287847

Another way of getting these is the dedicated quadratic solver SLVQ. It can be accessed via the X.FCN menu.

Code:
1 ENTER 5 ENTER 1   SLVQ
=> -4,791287847477920
x<>y
=> -0,2087121525220800

(05-26-2015 07:36 PM)AnalogJoe Wrote:  So the solution is off the correct result. Also no matter what initial values I enter, I cant get the calculator to display something near -4.79 which is the second root.

You'll now know why: there is just one single root at exactly –0,2 for f(x)=5x+1. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
05-26-2015, 08:22 PM
Post: #3
RE: WP 34S Solver
(05-26-2015 07:36 PM)AnalogJoe Wrote:  to be honest the documentation on the WP 34S is really poor,

That caused me to smile. It doesn't matter how long or how much time you spend on the documentation, there will always be someone who think it sucks for one reason or another. Big Grin

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
05-26-2015, 08:43 PM
Post: #4
RE: WP 34S Solver
(05-26-2015 07:58 PM)Dieter Wrote:  Simply provide the correct function, and you'll get what you want:
Code:

LBL 00

x<>y
5
*
+
1
+
RTN
If you replace "x<>y" with "RCL L" then it would indeed be correct ... Wink

Franz
Visit this user's website Find all posts by this user
Quote this message in a reply
05-26-2015, 08:49 PM
Post: #5
RE: WP 34S Solver
(05-26-2015 08:43 PM)fhub Wrote:  If you replace "x<>y" with "RCL L" then it would indeed be correct ... Wink

It is correct this way. SLV fills the complete stack with x, so you can take it from any stack register. RCL L is just another option.

Dieter
Find all posts by this user
Quote this message in a reply
05-26-2015, 09:02 PM
Post: #6
RE: WP 34S Solver
(05-26-2015 08:49 PM)Dieter Wrote:  SLV fills the complete stack with x
Ok, that's something I didn't know.
Nevertheless it's not a good idea to do it this way, at least not if you also want to use the function (in LBL 00) in your own calculations.

Franz
Visit this user's website Find all posts by this user
Quote this message in a reply
05-26-2015, 09:04 PM (This post was last modified: 05-26-2015 09:05 PM by AnalogJoe.)
Post: #7
RE: WP 34S Solver
(05-26-2015 08:22 PM)Tim Wessman Wrote:  
(05-26-2015 07:36 PM)AnalogJoe Wrote:  to be honest the documentation on the WP 34S is really poor,

That caused me to smile. It doesn't matter how long or how much time you spend on the documentation, there will always be someone who think it sucks for one reason or another. Big Grin

Sorry I didnt mean to sound mean, and I never thought it sucked, I just think it is poor in a way that it lacks examples, and also does not tell you the main functions of the calculator, rather a big list of commands. For example I had to mess around several minutes to figure out how to enter matrices since the manual doesnt tell you how to do that.
Find all posts by this user
Quote this message in a reply
05-26-2015, 09:06 PM
Post: #8
RE: WP 34S Solver
Thank you Dieter, im terribly sorry I didnt see this!


(05-26-2015 07:58 PM)Dieter Wrote:  
(05-26-2015 07:36 PM)AnalogJoe Wrote:  Im doing the following test program, my goal here is to find the roots of the following simple quadratic equation: x^2 + 5x + 1=0

OK. But that's not what you programmed:

(05-26-2015 07:36 PM)AnalogJoe Wrote:  LBL 00
2
y^x
x<>y
5
x
1
+
RTN

There is a "+" missing after the "5 x". This way the function you provide is simply 5x + 1. And an additional x² that is left in Y.

Now guess where 5x + 1 becomes zero. ;-)

(05-26-2015 07:36 PM)AnalogJoe Wrote:  The calculator works a little while and displays: -0.2

Got it now? ;-)
Simply provide the correct function, and you'll get what you want:

Code:
LBL 00

x<>y
5
*
+
1
+
RTN

BTW, do not use y^x as it is quite slow. There is a x² function that is shorter and much faster.

BTW2, "real cowboys" use Horner's method, for instance like this:
Code:
LBL 00
5
+
*
1
+
RTN

Looking at the equation you know that the roots will be negative, so try 0 and –5 as the two initial estimates.

Code:
0  ENTER  -5  SLV 00
=> -0,20871215252208...

-2  ENTER  -10  SLV 00
=> -4,7912878474779...

There you are.

(05-26-2015 07:36 PM)AnalogJoe Wrote:  Now the correct roots are -0.208712152 and -4.791287847

Another way of getting these is the dedicated quadratic solver SLVQ. It can be accessed via the X.FCN menu.

Code:
1 ENTER 5 ENTER 1   SLVQ
=> -4,791287847477920
x<>y
=> -0,2087121525220800

(05-26-2015 07:36 PM)AnalogJoe Wrote:  So the solution is off the correct result. Also no matter what initial values I enter, I cant get the calculator to display something near -4.79 which is the second root.

You'll now know why: there is just one single root at exactly –0,2 for f(x)=5x+1. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
05-26-2015, 09:13 PM
Post: #9
RE: WP 34S Solver
(05-26-2015 09:04 PM)AnalogJoe Wrote:  Sorry I didnt mean to sound mean, and I never thought it sucked, I just think it is poor in a way that it lacks examples, and also does not tell you the main functions of the calculator, rather a big list of commands.

Nah, I didn't think you were being mean. Rather, the people who made the 34s spent a long time on the documentation word smithing everything, and yet there will always be someone who believe it would have been more clear to explain things in a different way/put it in a different order/more verbosity/less verbosity and so on.

I just find it interesting to see it happening to a document that *I* wasn't personally involved with in any way.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
05-26-2015, 09:18 PM
Post: #10
RE: WP 34S Solver
While we are at it, is there any way that SLV finds complex solutions?
Find all posts by this user
Quote this message in a reply
05-26-2015, 09:18 PM
Post: #11
RE: WP 34S Solver
(05-26-2015 09:04 PM)AnalogJoe Wrote:  For example I had to mess around several minutes to figure out how to enter matrices since the manual doesn't tell you how to do that.

MED: Matrix Editor

This description is from matrixedit.wp34s:
Code:
/*
 *  Interactive editor for matrices.
 *  Start the editor with a matrix descriptor in X.
 *  Use the arrow keys to navigate:
 *    up/down: previous/next column
 *    f-up/f-down: previous/next row
 *  Type a digit to enter a number. This will suspend
 *  the progrom. R/S will enter X at the current row/column.
 *  XEQ RCL restores the present value to X if you decide
 *  not to change the cell. Press R/S to continue.
 *
 *  Some hot keys:
 *   A will start over at (1,1).
 *     When used outside the editor you will need to specifiy
 *     a new descriptor first.
 *   B (labeled 1/x) will call M[^-1] on the matrix.
 *   C continues at the last position.
 *   D computes and displays the determinant. R/S or C continue.
 *
 *  We need a few registers for internal use and therefore 
 *  set the stacksize to 4 to free registers A to D.
 *  Press <- to restore the mode and exit the editor.
 *  Double precision mode will always be reset!
 *
 *  Register usage:
 *   A - Matrix descriptor
 *   B - Current register
 *   D - Old setup mode
 *   I, J - Row and column
 *   K last key pressed
 *
 *  Flags:
 *   A - Controls big "=" sign
 *   00 - Shift state
 *
 *  Fixed labels:
 *   A, 11 - Start over with new matrix ('A'gain)
 *   B, 12 - Compute the inverse ('1/x')
 *   C     - Continue with current matrix ('C'ontinue)
 *   14, D - Compute the determinant ('D'eterminant)
 *   22    - [RCL] recalls current matrix element
 *   24    - [f] toggles navigation from horizontal to vertical
 *   31    - [ENTER^] (same as recall)
 *   35    - [<-] Backspace to exit the editor
 *   51    - [^] Navigation up/left
 *   61    - [v] Navigation down/right
 */

Stolen from [WP-34S] Calculations With Complex Matrices

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
05-26-2015, 10:51 PM
Post: #12
RE: WP 34S Solver
(05-26-2015 09:18 PM)Thomas Klemm Wrote:  
(05-26-2015 09:04 PM)AnalogJoe Wrote:  For example I had to mess around several minutes to figure out how to enter matrices since the manual doesn't tell you how to do that.

MED: Matrix Editor

This description is from matrixedit.wp34s:
Code:
/*
 *  Interactive editor for matrices.
 *  Start the editor with a matrix descriptor in X.
 *  Use the arrow keys to navigate:
 *    up/down: previous/next column
 *    f-up/f-down: previous/next row
 *  Type a digit to enter a number. This will suspend
 *  the progrom. R/S will enter X at the current row/column.
 *  XEQ RCL restores the present value to X if you decide
 *  not to change the cell. Press R/S to continue.
 *
 *  Some hot keys:
 *   A will start over at (1,1).
 *     When used outside the editor you will need to specifiy
 *     a new descriptor first.
 *   B (labeled 1/x) will call M[^-1] on the matrix.
 *   C continues at the last position.
 *   D computes and displays the determinant. R/S or C continue.
 *
 *  We need a few registers for internal use and therefore 
 *  set the stacksize to 4 to free registers A to D.
 *  Press <- to restore the mode and exit the editor.
 *  Double precision mode will always be reset!
 *
 *  Register usage:
 *   A - Matrix descriptor
 *   B - Current register
 *   D - Old setup mode
 *   I, J - Row and column
 *   K last key pressed
 *
 *  Flags:
 *   A - Controls big "=" sign
 *   00 - Shift state
 *
 *  Fixed labels:
 *   A, 11 - Start over with new matrix ('A'gain)
 *   B, 12 - Compute the inverse ('1/x')
 *   C     - Continue with current matrix ('C'ontinue)
 *   14, D - Compute the determinant ('D'eterminant)
 *   22    - [RCL] recalls current matrix element
 *   24    - [f] toggles navigation from horizontal to vertical
 *   31    - [ENTER^] (same as recall)
 *   35    - [<-] Backspace to exit the editor
 *   51    - [^] Navigation up/left
 *   61    - [v] Navigation down/right
 */

Stolen from [WP-34S] Calculations With Complex Matrices

Cheers
Thomas

Who would have guessed? The best documentation really is in the source code...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-27-2015, 12:17 AM
Post: #13
RE: WP 34S Solver
(05-26-2015 07:36 PM)AnalogJoe Wrote:  Hi, I just bought a WP 34S calculator, I really like it however the learning curve is quite steep with this one. I've been a long time HP user, however most of my experience comes from using the "bigger" HP calculators such as the 48GX and 50G series.

I've been trying to understand the Solve function, to be honest the documentation on the WP 34S is really poor, so I've been reading the Hp 15c manual which apparently is quite similar to the way things are done in the WP 34S.

We're on the same boat, my dear Joe. The 34s is no piece of cake! If you want to fully embrace the genuine RPN world and get drunk with nostalgia capturing the old fashion way of calculating things with limited resources, the 34s will throw you right into the middle of the RPN lion's den. The 35s is a different league (a lot like the 50g in many areas), I myself was considering buying one as my trusty 50g is now overkill for the things I have been doing lately, but I find the 34s a lot more fun.

I agree with you about the manual. The 15c's clearly easier and packed with examples.
Find all posts by this user
Quote this message in a reply
05-27-2015, 04:26 AM (This post was last modified: 05-27-2015 05:16 AM by AnalogJoe.)
Post: #14
RE: WP 34S Solver
Hey Marcio, im glad to find out im not the only one. I've been using HP calculators for a very long time, just like you, in my case I started with a 48G+ which one day became completely destroyed and I had to replace it with a 48GX which again fell several times off my desk, but somehow managed to survive with a few minor screen spots in the corners. Those school benches where you have only a 'one arm' desk are a real hazard to calculators.

Then I bought a 50G which at first I didnt like very much compared to my 48GX, the keyboard just felt funny on the 50G so I used it very little, however over time I learned to like it, and now I use it quite often.

Few months ago I decided to buy an HP Prime and I was blown away by the processing power of that thing, Its like having a light version of Matlab in a calculator, yet I dont see it replacing my 48GX or the 50G, but having CAS and the ability to do very complex symbolic stuff on the fly is really something wonderful with the HP Prime, I used to have a TI Voyage 200 for symbolic manipulation because I always prefered symbolic manipulation of the TIs over the HPs, not anymore, the HP Prime made the TI Voyage almost useless, aside from the Electrical Engineer library of the TI which I still think is the best compared to any EE HP app out there.

I just began a Master's program in EE, and in one of the exams I had to take they told me in advance that "advanced calculators" were strictly forbidden for that particular test, so I borrowed my brother's Casio scientific. Needless to say, after years of using RPN I was completely crippled using that Casio, I honestly felt like a 9 year old learning to use a calculator for the first time, problems which I used to solve in 5 minutes with the HP took me 15 minutes or more with the Casio! there was nothing wrong with that Casio but I was continuously trying to use it as an RPN calc so obviously I had to re-type the entire statement over and over.

It was then that I knew I had to go buy an RPN scientific, and I got myself a 35s, it was a big step down from he 48GX and 50G but it was very useable and RPN! after using it more I got hooked with the RPN programming style and I decided to buy the most advanced RPN scientific I could get, thus the WP 34S came to mind, lets see how it goes.

After all I must say, that my favorite calculator is still the 48GX, even with its sluggish behavior I've never found something quite like it. But these RPN scientifics are so much fun!

(05-27-2015 12:17 AM)Marcio Wrote:  
(05-26-2015 07:36 PM)AnalogJoe Wrote:  Hi, I just bought a WP 34S calculator, I really like it however the learning curve is quite steep with this one. I've been a long time HP user, however most of my experience comes from using the "bigger" HP calculators such as the 48GX and 50G series.

I've been trying to understand the Solve function, to be honest the documentation on the WP 34S is really poor, so I've been reading the Hp 15c manual which apparently is quite similar to the way things are done in the WP 34S.

We're on the same boat, my dear Joe. The 34s is no piece of cake! If you want to fully embrace the genuine RPN world and get drunk with nostalgia capturing the old fashion way of calculating things with limited resources, the 34s will throw you right into the middle of the RPN lion's den. The 35s is a different league (a lot like the 50g in many areas), I myself was considering buying one as my trusty 50g is now overkill for the things I have been doing lately, but I find the 34s a lot more fun.

I agree with you about the manual. The 15c's clearly easier and packed with examples.
Find all posts by this user
Quote this message in a reply
05-27-2015, 09:08 AM
Post: #15
RE: WP 34S Solver
(05-26-2015 09:18 PM)AnalogJoe Wrote:  While we are at it, is there any way that SLV finds complex solutions?

There is, in the library, a complex solver aimed to that. I have not used it (although my wp34s have it) and & I do not know if your particular build has included it.

Exploring the library software is quite rewarding, there are many pieces of good software on it. I'm now trying to port some library programs to XROM, just to have them permanently on the machine and, also, included in the "normal" catalogues.

You can download programs from your PC to the wp34s with a cable (bought or home made) via the emulator, see the manual.

Regards.
Find all posts by this user
Quote this message in a reply
05-27-2015, 09:57 AM
Post: #16
RE: WP 34S Solver
Moreover, if anyone creates a quality program for the WP 34S, we'll most likely include it in the firmware. The TVM solver is a product of this policy and we thank Franz for his sterling efforts here.

Much of the rest of the standard library is my responsibility and to be completely honest, I've not really properly finished all that many of these routines Sad


- Pauli
Find all posts by this user
Quote this message in a reply
05-27-2015, 05:16 PM
Post: #17
RE: WP 34S Solver
(05-27-2015 04:26 AM)AnalogJoe Wrote:  ...
It was then that I knew I had to go buy an RPN scientific, and I got myself a 35s, it was a big step down from he 48GX and 50G but it was very useable and RPN! after using it more I got hooked with the RPN programming style and I decided to buy the most advanced RPN scientific I could get, thus the WP 34S came to mind, lets see how it goes.
...

Joe,
I'll be interested to know how you like your 34s.

I've been playing with the emulator and so far I really like it, mostly because it forces me to analyze things before pressing keys mindlessly as I do on my 50g.
Find all posts by this user
Quote this message in a reply
05-28-2015, 03:44 AM (This post was last modified: 05-28-2015 03:44 AM by AnalogJoe.)
Post: #18
RE: WP 34S Solver
Marcio, I like it very much!, the calculator is well built, the keys are great, Im still not 100% happy about the stickers quality, some of them get scrapped quite easily, better stickers would really do wonders.

(05-27-2015 05:16 PM)Marcio Wrote:  
(05-27-2015 04:26 AM)AnalogJoe Wrote:  ...
It was then that I knew I had to go buy an RPN scientific, and I got myself a 35s, it was a big step down from he 48GX and 50G but it was very useable and RPN! after using it more I got hooked with the RPN programming style and I decided to buy the most advanced RPN scientific I could get, thus the WP 34S came to mind, lets see how it goes.
...

Joe,
I'll be interested to know how you like your 34s.

I've been playing with the emulator and so far I really like it, mostly because it forces me to analyze things before pressing keys mindlessly as I do on my 50g.
Find all posts by this user
Quote this message in a reply
05-28-2015, 04:03 AM (This post was last modified: 05-28-2015 04:04 AM by Marcio.)
Post: #19
RE: WP 34S Solver
(05-28-2015 03:44 AM)AnalogJoe Wrote:  Marcio, I like it very much!, the calculator is well built, the keys are great, Im still not 100% happy about the stickers quality, some of them get scrapped quite easily, better stickers would really do wonders.

Nice!

I am still studying the solver function as it seems to require a bit more attention than I expected. It seems the algorithm running behind it is somewhat similar to the false position method, which works very nicely but requires you to provide the interval/limits in which a particular root must be.
Find all posts by this user
Quote this message in a reply
05-28-2015, 04:19 AM (This post was last modified: 05-28-2015 11:36 AM by AnalogJoe.)
Post: #20
RE: WP 34S Solver
Well as far as I know you only have to provide an initial guess, as opposed to the intervals of solution. The WP 34s developers may shed some light into this issue, but im pretty sure the Solver uses somekind of open method such as Newton-Rhapson, or similar..

I have mixed feelings about these type of HP numeric solvers, on one hand they are extremely painful when it comes to solving polynomials because they will only find one particular root, and you have to constantly change your initial guess in order to find the different roots, at this point it is useful to remember Descartes rule of signs to get a better idea of what you should be looking for.

However if you are looking for a complex root, then you are out of luck, these solvers wont find it, I had to program a complex solver on my 35s to do this, and will probably have to do the same for the WP 34s. So finding polynomial roots with these solvers is a painstaking process, something that an off the shelf Casio will happily do up to 3rd order polynomials including complex roots, the WP34s only has a dedicated quadratic solver with complex root finding capability.

One could argue that not every day (at least not in my case) you need to solve a polynomial of a degree higher than 3, so lets say for a moment that 3rd degree is the highest degree poly for common applications, if the polynomial has 3 real roots then the HP solver will find them, but many times not all the roots wil be real, in that case, you dont need the HP solver to find the complex roots (in case they exist), instead you only need to find a real root, and since a 3rd degree poly with real coefficients will always have at least one real root, then you can use the Solver to find that root and then use synthetic division to reduce the 3rd order polynomial to a 2nd order polynomial, at that point you can now use the Quadratic Solver of the WP 34s and find the remaining complex roots.

So yeah theres still a way to get your answer even if you dont have the complex solver library, but it is a lot more painful.

On the other hand these solvers are extremely useful when you need to find solutions for any other type of equations, and specially useful for stuff like trascendental equations, in this regard the same off the shelf Casios that solve 3rd order polynomials are completely useless, so the bottomline is that the Solver function has its pros and cons.

Apparently there are programs available which address these issues on the 34s, but you need the dreaded flash cable to load them, something I have yet to build.

Something you should definitely check out is the integration solver, I loved how it will display the current calculated value in each iteration step, also the differentiate and 2nd derivative functions are extremely useful.

(05-28-2015 04:03 AM)Marcio Wrote:  Nice!

I am still studying the solver function as it seems to require a bit more attention than I expected. It seems the algorithm running it is somewhat similar to the false position method, which works very nicely but requires you to provide the interval/limits in which a particular root must be.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)