(50g) Fun with Farey sequences - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (50g) Fun with Farey sequences (/thread-4162.html) |
(50g) Fun with Farey sequences - Tugdual - 06-15-2015 08:37 PM A video to start with. A wikipedia page for the algorithm. And some code for the 50g Code: %%HP: T(3)A(R)F(,); RE: (50g) Fun with Farey sequences - Thomas Klemm - 06-15-2015 08:53 PM More fun … Cheers Thomas RE: (50g) Fun with Farey sequences - Tugdual - 06-15-2015 10:34 PM (06-15-2015 08:53 PM)Thomas Klemm Wrote: More fun …Nice! Note: Had no idea one could sum List with objects to push back that object in the list. The 48 code is very slim. RE: (50g) Fun with Farey sequences - Didier Lachieze - 06-16-2015 07:09 PM Thanks for the links. Great video ! I've adapted the Python program for the Prime: Code: #pragma mode( separator(.,;) integer(h32) ) The result is a list of reals, you need to press the "a b/c" key to display it as fractions. I don't know how to do it programmatically. EDIT: edited to add exact() to the result as suggested by Joe below. RE: (50g) Fun with Farey sequences - Joe Horn - 06-16-2015 10:50 PM (06-16-2015 07:09 PM)Didier Lachieze Wrote: The result is a list of reals, you need to press the "a b/c" key to display it as fractions. I don't know how to do it programmatically. The "exact" function will serve your purposes. exact({1.2, 3.4}) returns {6/5, 17/5}, even in a Home program. Doesn't work on arrays in Home, just lists. Works on arrays and lists in CAS programs, though. RE: (50g) Fun with Farey sequences - Didier Lachieze - 06-17-2015 05:20 AM Thanks ! RE: (50g) Fun with Farey sequences - Didier Lachieze - 06-17-2015 08:04 AM (06-15-2015 10:34 PM)Tugdual Wrote: The 48 code is very slim.yes and you can have the UserRPL program returning the same result as the SysRPL version (a list of algebraic fractions) by replacing: a b →V2 + by: a b / →Q + RE: (50g) Fun with Farey sequences - Thomas Klemm - 06-18-2015 09:33 PM (06-15-2015 10:34 PM)Tugdual Wrote: The 48 code is very slim. This program avoids the STO command: Code: \<< \-> n Cheers Thomas RE: (50g) Fun with Farey sequences - Gerald H - 06-23-2015 09:54 AM I have this for the 49G. Code: :: RE: (50g) Fun with Farey sequences - Thomas Klemm - 06-24-2015 10:23 PM (06-23-2015 09:54 AM)Gerald H Wrote: Couldn't that be replaced by: Code: 5UNROLL ( … a b c d ) Unfortunately I'm not familiar with the HP-49/50. In addition to that I wasn't able to compile your program successfully with Debug4x. It appears to be a problem with flash-pointers: Entry FPTR2 does not exist. Therefore I can't run the program and must admit that I don't fully understand what's going on in this section: Code: OVER Would you mind explaining it? Maybe even provide stack diagrams as comment? Without these I would have had a hard time to understand how the HP-48 is calculating complex arccos and arcsin functions. Kind regards Thomas RE: (50g) Fun with Farey sequences - Gerald H - 06-25-2015 05:46 AM Dear Thomas, The code replacement you suggest is not good. #/ is bint division, stack diagram Code:
FPTR2 ^NDXFext does exist, stack diagram Code: zint a You may have a problem with Z0_ which is shorthand for ZINT 0 The section you don't fully understand does this Code:
I suggest you change Z0_ to ZINT 0 & try to compile again. Thanks for your interest. RE: (50g) Fun with Farey sequences - Thomas Klemm - 06-26-2015 11:19 PM (06-25-2015 05:46 AM)Gerald H Wrote: #/ is bint division, stack diagram From "Programming in System RPL" by Eduardo M Kalinowski and Carsten Dominik: Code: Addr. Name Description Thus #/ is what is called /MOD in Forth: Code: /MOD ( n1 n2 -- rem quot ) Divides. Returns the remainder and quotient. Who would think that this was a good idea to use #/ instead? Thanks for the explanation of ^NDXFex. I assumed something like this but didn't know where to look it up. Quote:Thanks for your interest. I try my best to keep up with your production of programs. But I must admit that I'm not fluent in System RPL. Thus I'm a slow reader. Cheers Thomas |