WP 34S minichallenge

01212014, 12:24 PM
Post: #21




RE: WP 34S minichallenge
I can confirm those discussions


01212014, 12:29 PM
Post: #22




RE: WP 34S minichallenge  
01212014, 01:06 PM
(This post was last modified: 01212014 01:07 PM by Gerson W. Barbosa.)
Post: #23




RE: WP 34S minichallenge
(01212014 11:55 AM)Paul Dale Wrote:(01212014 08:26 AM)Didier Lachieze Wrote: Here is my solution: Isn't this something that should be addressed, or is there a technical reason that makes it difficult to preserve the original float number after switching back from an integer mode? On the HP42S, for instance, BASE BIN will convert 2.3 to 10., as expected and a subsequent DEC will restore it to 2.3 again. Shouldn't this be the expected behavior? Thanks! Gerson. 

01212014, 01:20 PM
Post: #24




RE: WP 34S minichallenge
(01212014 01:06 PM)Gerson W. Barbosa Wrote:(01212014 11:55 AM)Paul Dale Wrote: This solution does disturb the stack. If Y contains 2.3, it will end up containing 2.0 after the switch to integer mode and back. There is nothing like data types in the WP 34S. AFAIK, some of the nicer features of the HP42S rely on such data typing. d:/ 

01212014, 01:56 PM
Post: #25




RE: WP 34S minichallenge
Four steps, y'all:
LBL D RCL+ 01 IP DSE 01 GTO D RTN This assumes you enter the following keystrokes to solve the problem 100000.00001 STO 01 CLx D This takes time though! (please excuse if I overlooked the stack lift, but I think it preserves the stack)[/code]  Sanjeev Visvanatha 

01212014, 02:19 PM
Post: #26




RE: WP 34S minichallenge
(01212014 01:56 PM)Sanjeev Visvanatha Wrote: Four steps, y'all:The original HP15C program assumes n on register X, no previous initialization: 100000 GSB A > 5000050000 Anyway, your program would return 5000150000, which is off by 100000. But of course it can be improved. Since the increment is 1 the fractional part is optional, thus saving the IP instruction. Also, you can use BACK nnn to save occasional LBLs steps in the middle of the program. Regards, Gerson. 

01212014, 03:44 PM
(This post was last modified: 01212014 03:47 PM by Gerson W. Barbosa.)
Post: #27




RE: WP 34S minichallenge
(01212014 11:29 AM)Paul Dale Wrote: I considered an integer mode solution too. The shortest I could come up with is: In principle the minichallenge is interested only in integer results ("It computes the sum of the first n natural numbers using Gauss's formula."). Of course if it gives valid results for real inputs, as does my original solution, yours and Didier's, so much the better. It is required that the calculator modes get back to the default settings (like DECM) when done, in case they're changed by the program. This would make for five steps (additional BASE 02 and DECM instructions), if DECM restored the original float numbers when switching back from BASE 02, of course. If we are pleased with integer arguments only, then even an HP42S is almost possible: Code:
100000 XEQ GS > 5000050000 but 50000 XEQ GS > 1250024999 (too bad this error of 1 unit due to rounding error) Cheers, Gerson. 

01212014, 04:07 PM
(This post was last modified: 01212014 04:53 PM by Didier Lachieze.)
Post: #28




RE: WP 34S minichallenge
(01212014 03:44 PM)Gerson W. Barbosa Wrote: If we are pleased with integer arguments only, then even an HP42S is almost possible: Well, here is a solution working on both the 42S and WP 34S, not limited to integers and where I don't see the rounding error highlighted above: Code: 00 {15Byte Prgm} 50000 XEQ GS > 1.250.025.000 

01212014, 04:29 PM
Post: #29




RE: WP 34S minichallenge
(01212014 02:19 PM)Gerson W. Barbosa Wrote: The original HP15C program assumes n on register X, no previous initialization: Thank you. Revisions are respectfully submitted below, for a 5 step solution: LBL D X>< 01 CLx RCL+ 01 DSE 01 BACK 002 RTN I believe this leaves the stack unchanged as well, but does take a while with your example. 100000 D > 5,000,050,000  Sanjeev Visvanatha 

01212014, 05:11 PM
Post: #30




RE: WP 34S minichallenge
(01212014 04:29 PM)Sanjeev Visvanatha Wrote: Thank you. Revisions are respectfully submitted below, for a 5 step solution: You're quite welcome! All solutions are welcome, even if not the expected ones. Also you've come up with a better solution than the one in my reply to Walter, thus perfectly fitting into the required 5step limit. Oh, and it surely leaves the stack unchanged after program execution. Thanks for your contribution and interest! Regards, Gerson. 

01212014, 05:15 PM
Post: #31




RE: WP 34S minichallenge
I submitted my initial solution without looking at what was submitted at that point in time. So, I did not see the other similar solution until I received your first reply! I got to know my wp34s better, so thanks go to you for giving me the impetus to do so!
 Sanjeev Visvanatha 

01212014, 05:41 PM
Post: #32




RE: WP 34S minichallenge
(01212014 04:07 PM)Didier Lachieze Wrote:Very nice! More accurate and faster than mine, but that was the goal of the minichallenge: to increase our arsenal of solutions for further use.(01212014 03:44 PM)Gerson W. Barbosa Wrote: If we are pleased with integer arguments only, then even an HP42S is almost possible: Well, at least my WP 34S program returns 1.250.025.000,000003 for that particular example, which is quite acceptable for a finiteprecision machine. I will post it later. Regards, Gerson. 

01212014, 08:43 PM
Post: #33




RE: WP 34S minichallenge
(01212014 11:48 AM)Paul Dale Wrote: The divide by two is what is stumping me. x² RCL+L 2 ÷ is the obvious solution but it doesn't preserve the stack and saving the stack consumes more steps than are available.What? Who vetoed against this? Some time ago I suggested a simple instruction that might have been called HALF or something similar. If possible it should take a register address, so that here a HALF X would have done the trick. The main reason why it did not get implemented was the lack of available memory. Now I hear that such an instruction would have been possible. ?!? Dieter 

01212014, 10:13 PM
Post: #34




RE: WP 34S minichallenge
Walter vetoed it of course
Most things are possible, weather they justify themselves is the important thing. These instructions didn't. I proposed a set of instructions: Code: + nnn Which performed the specified operation to X using the associated constant. Thus, " 22" would subtract 22 from X (doing the right thing with Last X).  Pauli 

01212014, 10:46 PM
(This post was last modified: 01212014 10:53 PM by nsg.)
Post: #35




RE: WP 34S minichallenge
And here is another way to divide by 2 without touching stack:
Code: 01 LBL A There is a middle ground. Use constants 14 only. this way only 4 bits (2 fror constant and 2 for operation) represent variation and therefore only 16 opcodes are wasted. And constants 14 cover easily 99% of cases. (01212014 10:13 PM)Paul Dale Wrote: I proposed a set of instructions: 

01212014, 11:16 PM
(This post was last modified: 01212014 11:26 PM by Gerson W. Barbosa.)
Post: #36




RE: WP 34S minichallenge
(01212014 10:46 PM)nsg Wrote: And here is another way to divide by 2 without touching stack: This exactly matches mine! I knew it would appear sooner or later :) Code:
Perhaps there are other ways around, some of which might even work on other RPN calculators, like Didier's. Thank you all for your interest and contributions. Gerson. Edited to fix subscript and superscript characters 

01212014, 11:33 PM
Post: #37




RE: WP 34S minichallenge
And here is my rather flawed HP42S solution:
Code:
Only for integer arguments. It might return results off by one unit, for some (not so) large arguments. 

01222014, 03:44 AM
(This post was last modified: 01222014 04:27 AM by Sanjeev Visvanatha.)
Post: #38




RE: WP 34S minichallenge
(01212014 11:48 AM)Paul Dale Wrote: ... It works using Σ+ so long as the summation registers are clear: LBL D Σ+ X<>L X^2 Σ+ x̄ RTN I believe the stack remains 'unchanged'. However, the Y register is altered (I believe) through the use of the mean command. In this case though, original Y is returned back to Y. Due to the requirement that the summation registers are cleared prior to execution, the criteria of the challenge were not met.  Sanjeev Visvanatha 

01222014, 05:15 AM
(This post was last modified: 01222014 05:21 AM by walter b.)
Post: #39




RE: WP 34S minichallenge
(01212014 10:13 PM)Paul Dale Wrote: Most things are possible, weather they justify themselves is the important thing. These instructions didn't. So true. (01212014 10:13 PM)Paul Dale Wrote: I proposed a set of instructions: ... IIRC, such discussions occurred when we were approaching asymptotically the first release of a SW for our (then still potential) users. At that time, I had faithfully added each and every arcane function to the documentation so far and was simply fed up with it. Maybe I even pointed to the function sets of vintage calcs which were able to solve everything nevertheless. As I said, IIRC. d;) BTW, before voting for more instructions how about using the right reply button in this very forum? This would demonstrate maturity for an extended instruction set 

01222014, 05:47 AM
Post: #40




RE: WP 34S minichallenge
There's a left reply button?


« Next Oldest  Next Newest »

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