[HP 35s] Hosoda's trig program affected by bug 20? - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Calculators (and very old HP Computers) ( /forum-3.html)+--- Forum: General Forum ( /forum-4.html)+--- Thread: [HP 35s] Hosoda's trig program affected by bug 20? ( /thread-4421.html) |

[HP 35s] Hosoda's trig program affected by bug 20? - Marcio - 07-24-2015 11:10 AM
Hello all, While playing with program based functions on the 35s, I noticed that the solver will never finish if Hosoda's program for trig functions is called from inside functions. Hosoda does make use of DSE at the beginning to save the stack registers, so I suspect 20 bug is to blame here. For example, if you use Hosoda, try solving \(sin(x)=1\) for \(x\). This is how I did it: F001 LBL F F002 RCL X F003 XEQ H001; F004 1 F005 - F006 RTN FN = F 80 \(\rightarrow\)RAD STO X Solve for X. For those unfamiliar with Hosoda's program, it is a nice addition to the 35s to compensate for the loss of accuracy when trig functions are used, especially in cases where the angle is very small (~1E-7) or near 90 degrees. Our dear friend Gerald added a few enhancements to it and published the final code here. Very much appreciated. Marcio RE: [HP 35s] Hosoda's trig program affected by bug 20? - Gerald H - 07-24-2015 11:19 AM
If you substitute 0.5 for 1 in your programme the solver evaluation does finish. "Enhancements" is the wrong word - I merely completed the two missing lines. RE: [HP 35s] Hosoda's trig program affected by bug 20? - Marcio - 07-24-2015 11:34 AM
(07-24-2015 11:19 AM)Gerald H Wrote: If you substitute 0.5 for 1 in your programme the solver evaluation does finish. How long did it take to finish? The 35s I have here has not yet finished since you posted this. RE: [HP 35s] Hosoda's trig program affected by bug 20? - Gerald H - 07-24-2015 11:49 AM
Sorry, my error. Given initial value P= 0.8 after 3 minutes of evaluation the value of P was the same, so I guess the solver bug applies OR the programme messes with the solver in some way. RE: [HP 35s] Hosoda's trig program affected by bug 20? - Marcio - 07-29-2015 01:42 PM
Update: The same will happen if you try to integrate a program. RE: [HP 35s] Hosoda's trig program affected by bug 20? - Thomas Klemm - 07-29-2015 06:56 PM
(07-24-2015 11:10 AM)Marcio Wrote: Hosoda does make use of DSE at the beginning to save the stack registers, so I suspect 20 bug is to blame here. If that's the only reason that the solver fails then you could use a loop-unrolling: Code: `J004 X<> 00` Code: `J015 RPN` I must admit that I don't understand the following lines: Code: `J018 4` Why do we need the value 4 in register 04? But I've noticed this line: Code: `J066 ISG J` This might still lead to a problem when using the solver. Kind regards Thomas RE: [HP 35s] Hosoda's trig program affected by bug 20? - Dieter - 07-29-2015 07:21 PM
(07-29-2015 06:56 PM)Thomas Klemm Wrote: If that's the only reason that the solver fails then you could use a loop-unrolling: The 35s does not use direct numeric registers like the classic calculators. It uses 26 lettered variables A...Z instead. These can be accessed indirectly by negative (!) addresses, i.e. A is –1, B is –2 etc. Of course your idea can be implemented by replacing R00...R03 with A...D – or X, Y, Z and T, if you like. The Hosoda program uses positive addresses instead. These refer to the 800+ indirect registers of the 35s. So a STO (I) with I=3 stores a value in register (003). I assume this was the preferred solution because this way the program does not interfere with the regular variables A...Z that can be accessed directly by the user. (07-29-2015 06:56 PM)Thomas Klemm Wrote: I must admit that I don't understand the following lines: I think the author wanted to make sure that at least four indirect registers are allocated. On the 35s this is done by storing a non-zero value in the highest register (here (004). Since the values on the stack may be zero, explicitly storing a non-zero number (here: 4) there (resp. the first one beyond it) makes sure that registers up to (004) are allocated. Finally (000)...(003) hold the original stack, and (004) contains a 4, which merely tells the 35s to allocate sufficient memory. Dieter RE: [HP 35s] Hosoda's trig program affected by bug 20? - Thomas Klemm - 07-29-2015 07:52 PM
Thanks for your answers. I forgot so many things about this calculator. Which proves that I don't use it often. Cheers Thomas |