The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

Couple of new HP-17bii solver programs in Articles
Message #1 Posted by Don Shepherd on 19 Jan 2012, 11:04 a.m.

Link to a couple of new 17bii solver programs.

      
Re: Couple of new HP-17bii solver programs in Articles
Message #2 Posted by y.miyata on 20 Jan 2012, 9:30 p.m.,
in response to message #1 by Don Shepherd

Thank you very much for the nice solver programs. Both works quite nicely as you have described. The "LOG(0)" technique should be a good trick to stop the solver when required. In addition, they clearly show how magically a sigle line solver program does a complex calculation.

In fact, now my main calculator is a HP-17BII. I have been using my favorite HP-42S for long for my daily work in biological scientific research field, where frequent calculations with many programs are necessary. However, because the 42S price became quite high, I'm afraid I might be unable to buy another 42S if I happen to break it. So, I tried to translate these 42S programs into 17BII solver forms. Surprisingly, almost all of programs I have written for 42S can be expressed as 17BII solver lines with similar user interfaces. Sometimes it resulted in a very tricky line, but in most cases my 42S program can be expressed as a short and smart equation. In addition, 17BII has a real time clock capability and financial functions which are also quite useful.

I bought a couple of 17BII at low prices for backups, and keep the 42S for other purposes such as programming fun and really complicated calculations.

I'm sure that 17BII is a very powerful and "programmable" calculator.

            
Re: Couple of new HP-17bii solver programs in Articles
Message #3 Posted by Don Shepherd on 20 Jan 2012, 10:31 p.m.,
in response to message #2 by y.miyata

You're welcome, I enjoyed writing them. I changed the Hi-Lo program because it really didn't need to end a loop early. LOG(0) (or any illegal instruction, like divide by 0) is handy for exiting a loop early after storing a value of interest in a menu variable, and then RCL'ing the variable, but there are situations in which it won't work, especially if you need to do a lot of further processing after exiting the loop. But it is an interesting approach.

I think most members of the forum aren't especially interested in the 17bii because (a) it's a financial calculator, and (b) it lacks trig functions. But I enjoy the challenge of seeing if the 17b and 17bii can be programmed to solve particular problems, and I'm constantly amazed at what a "non-programmable" calculator can do.

                  
Re: Couple of new HP-17bii solver programs in Articles
Message #4 Posted by Allen on 21 Jan 2012, 12:17 a.m.,
in response to message #3 by Don Shepherd

Neat Programs, Don! I love the 17bii, and use it as often as I use all my other 42s/32sii/50g/48gx machines combined. It's a very capable and stylish machine!

                        
Re: Couple of new HP-17bii solver programs in Articles
Message #5 Posted by Don Shepherd on 21 Jan 2012, 4:15 p.m.,
in response to message #4 by Allen

Thanks Allen. I agree, the 17b and 17bii are simply very handsome calculators. I really like the single shift key and an uncluttered key layout. You can print your equations via the infrared printer. The date arithmetic is nice. The solver with its programming-enabling commands is second to none. I wish I could congratulate the HP engineer who invented this solver and thank him or her for IF and .

One subject I don't think I've seen discussed in the forum before is the use of HP programmable calculators to create programs that offer simple challenges that require you to engage your mind, like the Hi-Lo game. I know I've read that stimulating your brain is effective in preventing Alzheimer's disease, and as we all get older that becomes something that I think is important. A collection of programs (that can be implemented on HP programmable calculators) that provide brain stimulation would be a good thing.

As for me, I don't plan to run out of 17b's!

Edited: 21 Jan 2012, 4:26 p.m.

                  
Re: Couple of new HP-17bii solver programs in Articles
Message #6 Posted by y.miyata on 22 Jan 2012, 9:13 p.m.,
in response to message #3 by Don Shepherd

> I changed the Hi-Lo program because it really didn't need to end a loop early.

I have also enjoyed the upgraded program. When I modify solver lines, I often need to store several "versions" of solver lines in the memory and I wish if I could save the older line and copy it to a new line to modify it (I mean it is often painful to re-enter a whole long line again). Do you think it is possible on 17BII? In case I need a serious debugging, I prefer to do so on the solver in 200LX where I can copy and paste the line.

> (b) it lacks trig functions.

Yes, this might be a major drawback of 17BII, although I rarely need the trig functions. Previously, I had been using 19BII, and it has trig functions. In addition, the separate alpha-keys are convenient to enter equations. However, 19BII is too large and heavy for my lab-coat pocket, and it was painful (and dangerous) to change the batteries of 19BII.

I have 27S and this is also a very nice calculator with the same Pioneer form and the handsome solver with a lot of mathematical and financial functions. The problem is that it does't accept RPN input. Probably, "27SII" with an RPN option might be my ideal calculator.

                        
Re: Couple of new HP-17bii solver programs in Articles
Message #7 Posted by Gerson W. Barbosa on 22 Jan 2012, 10:03 p.m.,
in response to message #6 by y.miyata

Quote:
> (b) it lacks trig functions.

Yes, this might be a major drawback of 17BII, although I rarely need the trig functions.


Equations for them can be written, however. Here is a compact one for sine:

SIN=L(Y:SIGMA(N:0:5:1:(-1)^N*(X*PI/540)^(2*N+1)/FACT(2*N+1)))
*(3-4*SQ(G(Y)))

Another one, longer but faster:

SIN=L(Y:X*(5.81776417331E-3+L(X2:SQ(X))*(-3.2818376137E-8+G(
X2)*(5.55391606E-14+G(X2)*(2.0935E-26*G(X2)-4.47566E-20)))))*
(3-4*SQ(G(Y)))

Others available here.

                              
Re: Couple of new HP-17bii solver programs in Articles
Message #8 Posted by y.miyata on 23 Jan 2012, 8:28 p.m.,
in response to message #7 by Gerson W. Barbosa

Quote:

Others available here.


Yes, in fact I remember that previously I have examined all of the equation listed in your link (quite impressive, I would like to take this opportunity to thank you for your very nice article), and I stored equation series No.2 in my HP17BII, which is useful to perform simple trig functions.

But in most of the cases where I need trig functions, I would like to use them in more complicated solver equations such as

COS(x)*(SIN(X))^2/(x*SIN(X+PI))=0.5.

In such cases, even with your trig equations, 17BII seems to be not that much convenient...

                                    
Re: Couple of new HP-17bii solver programs in Articles
Message #9 Posted by Gerson W. Barbosa on 23 Jan 2012, 11:05 p.m.,
in response to message #8 by y.miyata

Thanks! I started converting them from the HP-12C Platinum program during a dull day at the beach. The longer equations were edited and tested first on the HP-200LX, which made the task easier. I personally prefer the first set, but I guess most will prefer the second one for its compactness.

Quote:
But in most of the cases where I need trig functions, I would like to use them in more complicated solver equations such as

COS(x)*(SIN(X))^2/(x*SIN(X+PI))=0.5.


Yes, you're right! After posting I realized you would need them for something like that. It's a pity the HP-17BII lacks trigs. It would be a great option in this form factor. Perhaps there would be space in ROM for these functions if an international option were not offered.

Gerson.

                                    
Re: Couple of new HP-17bii solver programs in Articles
Message #10 Posted by Thomas Klemm on 23 Jan 2012, 11:12 p.m.,
in response to message #8 by y.miyata

Quote:
COS(x)*(SIN(X))^2/(x*SIN(X+PI))=0.5

In this case even trigonometric functions wouldn't be of a help as the solutions turn out to be complex numbers:

x ~ +/-2.17519+/-0.743742 i

Kind regards
Thomas

                                          
Re: Couple of new HP-17bii solver programs in Articles
Message #11 Posted by y.miyata on 24 Jan 2012, 8:00 p.m.,
in response to message #10 by Thomas Klemm

Quote:

the solutions turn out to be complex numbers:


I'm sorry, I made a mistake in writing the equation. The right one is

COS(x)*(SIN(X))^2/(x*SIN(X+PI/2))=0.5

I would be glad if you kindly confirm that this equation has 2 real solutions.

Thanks!

                                                
Re: Couple of new HP-17bii solver programs in Articles
Message #12 Posted by Thomas Klemm on 24 Jan 2012, 10:30 p.m.,
in response to message #11 by y.miyata

I simply copied the equation cos(x)(sin^2(x))/(x sin(x+pi/2)) = 0.5 into WolframAlpha which gave me these two solutions. Just make sure to use only lowercase x and not both x and X in the equation.

x = 0.554572
x = 1.84908

From the result I used the alternate form to get: 1-cos(2x) = x. Now you could use the HP-17bii with the Taylor-series of this expression to solve the equation:

x = 2x2 - 2x4/3 + 4x6/45 - 2x8/315

I didn't do that but according to WolframAlpha you should get:

x = 0.554573
x = 1.80219

This might already be close enough to your needs. Otherwise add more terms of the Taylor expansion.

Cheers
Thomas

                                                      
Re: Couple of new HP-17bii solver programs in Articles
Message #13 Posted by Gerson W. Barbosa on 25 Jan 2012, 11:50 a.m.,
in response to message #12 by Thomas Klemm

The equation has actually three real roots. It can be rewritten as (sin(x))^2 - 0.5*x = 0, since sin(x+pi/2) = cos(x). When submitting it to WolframAlpha we get

x = 0
x ~ 0.55457209082980902139383036
x ~ 1.8490768364385078905686851
The HP-42S solver gives
X=0
X=0.554572090831
X=1.84907683644

01 LBL "EQ" 02 MVAR "X" 03 0.5 04 RCL "X" 05 * 06 LASTX 07 SIN 08 X^2 09 - 10 .END.

The initial estimates, 0.1, 0.5 and 2, respectively, have to be changed outside the solver, otherwise the solver may get stuck to the first root it finds.

The HP-200LX solver will always return X=0, no matter the initial estimates, for

SQ(L(Y:SIGMA(N:0:5:1:(-1)^N*(X*PI/540)^(2*N+1)/FACT(2*N+1)))
*(3-4*SQ(G(Y))))-0.5*X=0

Cheers,

Gerson.

                                                            
Re: Couple of new HP-17bii solver programs in Articles
Message #14 Posted by Thomas Klemm on 25 Jan 2012, 5:09 p.m.,
in response to message #13 by Gerson W. Barbosa

But the value x = 0 is not a solution of the initial equation. Instead it's added because we multiplied both sides of the equation with x.

If that turns out to be a problem for the solver we can easily divide the Taylor series again by x and get the following instead:

1 = 2x - 2x3/3 + 4x5/45 - 2x7/315

Just from looking at the graph I would not expect the solver to have problems to find these two solutions:

Best regards
Thomas

                                                                  
Re: Couple of new HP-17bii solver programs in Articles
Message #15 Posted by Gerson W. Barbosa on 25 Jan 2012, 6:02 p.m.,
in response to message #14 by Thomas Klemm

Quote:
But the value x = 0 is not a solution of the initial equation.

You're right! That's been quite a mistake of mine.

What puzzles me now is the behavior of the HP-42S solver above. I don't remember another example that requires leaving the solver to change estimates.

Regards,

Gerson.

                                                                        
Re: Couple of new HP-17bii solver programs in Articles
Message #16 Posted by Thomas Klemm on 25 Jan 2012, 6:23 p.m.,
in response to message #15 by Gerson W. Barbosa

Quote:
have to be changed outside the solver

I'm afraid I don't understand your problem. What exactly are you doing here?

Cheers
Thomas

                                                                              
Re: Couple of new HP-17bii solver programs in Articles
Message #17 Posted by Gerson W. Barbosa on 25 Jan 2012, 7:01 p.m.,
in response to message #16 by Thomas Klemm

Just follow these keystrokes considering, the program "EQ" above is in memory and the variable "X" contains 0:

             keystrokes                  display

[Shift] [SOLVER] [EQ] [5] [X] [X] X=0 [2] [X] [X] X=0 [1] [X] [X] X=0 ; the root is stuck at X=0, no matter the estimates [EXIT] ; leaves the SOLVER environment [2] [STO] [X] ; stores 2 in the variable "X" [Shift] [SOLVER] [EQ] [X] X=2 ; back to the SOLVER enviroment again [X] X=1.84907683644

Strange, isn't it?

Cheers,

Gerson.

Edited: 25 Jan 2012, 7:03 p.m.

                                                                                    
Re: Couple of new HP-17bii solver programs in Articles
Message #18 Posted by Thomas Klemm on 26 Jan 2012, 3:00 a.m.,
in response to message #17 by Gerson W. Barbosa

My understanding is that since you entered only one guess the previous solution is used as the other one. Thus it is stuck at x = 0.

Instead of leaving the SOLVER environment you can simply enter two guesses:

[Shift] [SOLVER] [EQ]
[1] [X]
[2] [X]
[X]
X=1.849077

It might be that the solver just uses one of the initial guesses if the result is exactly 0, because there's no possible way to improve that result.

Does this makes sense to you?

Regards
Thomas

                                                                                          
Re: Couple of new HP-17bii solver programs in Articles
Message #19 Posted by Gerson W. Barbosa on 26 Jan 2012, 3:41 a.m.,
in response to message #18 by Thomas Klemm

Quote:
It might be that the solver just uses one of the initial guesses if the result is exactly 0, because there's no possible way to improve that result.

Does this makes sense to you?


Yes, it does. Thanks! That's exactly the procedure described in the manual. I had already tried [1] ENTER [2] [X] but it would not work. The procedure for the HP-200LX is slightly different and also not so intuitive: "to enter two guesses, key in the first guess and press the function key once, and then key in the second guess and press the function key twice." I haven't succeeded on the HP-200LX, however.

Gerson.

                                                                                                
Re: Couple of new HP-17bii solver programs in Articles
Message #20 Posted by y.miyata on 26 Jan 2012, 8:47 p.m.,
in response to message #19 by Gerson W. Barbosa

Quote:

I had already tried [1] ENTER [2] [X] but it would not work.


On HP-15C, I have got the answer with this way by [1] [ENTER] [2] [f] [SOLVE] [label].

Quote:
The procedure for the HP-200LX is slightly different and also not so intuitive:

I believe it is almost the same in HP-200LX as in HP-42S.

Store the equation: sin(x)*sin(x)/x-0.5

[calc] 1 [x] 2 [x] [x]

x= 1.849076836438508

0.1 [x] 1 [x] [x]

x=0.554572090829809

Often I prefer to get the answer after plotting the funcion.

[Plot] [Auto] (or [Draw]), move the cursor near the point where the graph crosses the Y=0, then [Solve]

You see the answer in the upper left corner of the screen.

                                                                                                      
Re: Couple of new HP-17bii solver programs in Articles
Message #21 Posted by Gerson W. Barbosa on 27 Jan 2012, 2:34 p.m.,
in response to message #20 by y.miyata

Quote:
Often I prefer to get the answer after plotting the funcion.

Duh! On plotting it I saw where I was going wrong. It turns out my equations assume X is in degrees, not radians! After editing, it works:

SQ(L(Y:SIGMA(N:0:6:1:(-1)^N*(X/3)^(2*N+1)/FACT(2*N+1)))
*(3-4*SQ(G(Y))))=X/2

X=0.554572090829808

and

X=1.849076836438507

Great advice! Thanks!

Gerson.

                                                            
Re: Couple of new HP-17bii solver programs in Articles
Message #22 Posted by y.miyata on 26 Jan 2012, 8:29 p.m.,
in response to message #13 by Gerson W. Barbosa

Quote:
It can be rewritten as (sin(x))^2 - 0.5*x = 0, since sin(x+pi/2) = cos(x).

Yes, you are right, the original equation I had was in fact (sin(x))^2/x=0.5, and I added cos(x) in the numerator (top) and sin(x+pi/2) in the denominator (bottom) [it added nothing mathematically] to emphasize the trig difficulty in 17BII.

Next subjects you may be interested in will be:

1. Calculate the x value where (sin(x))^2/x reaches maximum. Looking at the graph Thomas kindly illustrated, you may agree that it should be somewhere between x=1 and x=2.

2. Calculate the integration [x=0 to x=pi] of (sin(x))^2/x.

I have done these with HP-42S and HP-15LE (fast!). It was a good exercise to remember how to use these calculators (and also to prevent from Alzheimer's disease...).

Cheers.

                                                                  
Re: Couple of new HP-17bii solver programs in Articles
Message #23 Posted by Gerson W. Barbosa on 27 Jan 2012, 3:04 p.m.,
in response to message #22 by y.miyata

Quote:
1. Calculate the x value where (sin(x))^2/x reaches maximum. Looking at the graph Thomas kindly illustrated, you may agree that it should be somewhere between x=1 and x=2.

2. Calculate the integration [x=0 to x=pi] of (sin(x))^2/x.


Out of laziness, I've done these on my HP 50g :-)

1. 'SQ(SIN(X))/X' DERVX --> '(2*COS(X)*X-SIN(X))*SIN(X)/X^2'
    '(2*COS(X)*X-SIN(X))*SIN(X)/X^2=0' --> X=1.16556118521 (Numeric Solver)

2. 'Integrate(0,pi,SQ(SIN(X))/X,X)' EVAL --> 1.21882669653

Quote:
It was a good exercise to remember how to use these calculators (and also to prevent from Alzheimer's disease...).

I've heard studying a foreign language is good for this purpose too. I hope this applies also to languages I started to learn when I was young (and never finished, like German and Russian-- never went beyond lesson 3). Perhaps a good reason to start over :-)

Cheers,

Gerson.

                                                                        
Re: Couple of new HP-17bii solver programs in Articles
Message #24 Posted by Marcus von Cube, Germany on 27 Jan 2012, 3:59 p.m.,
in response to message #23 by Gerson W. Barbosa

Gerson, mache weiter! :-)

                                                                              
Re: Couple of new HP-17bii solver programs in Articles
Message #25 Posted by Gerson W. Barbosa on 27 Jan 2012, 4:37 p.m.,
in response to message #24 by Marcus von Cube, Germany

Hallo Marcus,

Living in Curitiba, I am surrounded by German descendants (the string "german" appears at least 15 times in the wikipedia article on the city). My daughter studies in a Lutheran high-school and has been studying German for two years (but only two hours a week, which is less than adequate). As of me, there are no excuses :-)

Regards,

Gerson.

                                                                                    
OT. Curitiba
Message #26 Posted by Marcus von Cube, Germany on 27 Jan 2012, 5:08 p.m.,
in response to message #25 by Gerson W. Barbosa

Impressive!

Time to see Brazil... :-)

                                                                                          
Re: OT. Curitiba
Message #27 Posted by Gerson W. Barbosa on 27 Jan 2012, 5:19 p.m.,
in response to message #26 by Marcus von Cube, Germany

Willkommen! :-)

                        
Re: Couple of new HP-17bii solver programs in Articles
Message #28 Posted by Don Shepherd on 22 Jan 2012, 11:09 p.m.,
in response to message #6 by y.miyata

Quote:
When I modify solver lines, I often need to store several "versions" of solver lines in the memory and I wish if I could save the older line and copy it to a new line to modify it (I mean it is often painful to re-enter a whole long line again). Do you think it is possible on 17BII?

Unfortunately, no. It would be nice if there was cut and paste available when editing solver equations, but I don't think even the 19bii can do that either. I played with the 19bii solver a few months ago and discovered something I really did not like: if you have an error in your solver equation somewhere, you can't save it until you fix the error, unlike the 17bii solver which does save it, even with the error. That's a huge problem when you get into longer equations, and for that reason I would not want to work on the 19bii, even with its convenient alpha keyboard.

It is ironic that L() and G() were not documented in the 17b or 17bii manuals, but the actual solvers on those machines had them and they worked fine. By the time HP got around to documenting L() and G() in the 17bii+ manuals, Kinpo changed the solver so it didn't work (correctly) like it did previously in the 17b and 17bii.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall