Couple of new HP-17bii solver programs in Articles
#1

Link to a couple of new 17bii solver programs.

#2

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.

#3

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.

#4

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!

#5

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.

#6

> 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.

#7

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.

#8

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.

#9

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...

#10

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.

#11

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

#12

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!

#13

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

#14

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.

#15

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

#16

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.

#17

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

#18

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.

#19

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

#20

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.

#21

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.

#22

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.

#23

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.

#24

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.

#25

Gerson, mache weiter! :-)

#26

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.

#27

Impressive!

Time to see Brazil... :-)

#28

Willkommen! :-)



Possibly Related Threads…
Thread Author Replies Views Last Post
  hp-prime solver and variable name fabrice48 22 8,116 12-10-2013, 03:25 AM
Last Post: fabrice48
  HP Prime: Lists in programs Alberto Candel 7 3,453 12-04-2013, 02:16 AM
Last Post: Alberto Candel
  Solver issue with HP 17BII - different from 19BII Jeff Kearns 13 4,467 11-28-2013, 02:36 AM
Last Post: Don Shepherd
  HP Prime Triangle solver BruceH 29 8,398 11-28-2013, 12:03 AM
Last Post: Dale Reed
  HP Prime: matrices in programs, in need of help Alberto Candel 9 3,174 11-26-2013, 01:33 AM
Last Post: cyrille de Brébisson
  17BII & 17BII+ Discounted Payback Period Revisited Tom Neudorfl 8 2,805 11-25-2013, 10:28 AM
Last Post: Don Shepherd
  HP prime: linear solver app Alberto Candel 1 1,408 11-21-2013, 01:57 AM
Last Post: Michael Carey
  HP Prime: Linear Solver app bug BruceH 0 1,122 11-15-2013, 06:36 PM
Last Post: BruceH
  Grouping programs on the HP Prime Michael de Estrada 11 3,660 11-04-2013, 01:38 PM
Last Post: Damien
  HP Prime Solver Variables Issue Anibal Morones Ruelas 8 2,986 10-19-2013, 09:45 AM
Last Post: Harold A Climer

Forum Jump: