Little explorations with HP calculators (no Prime)
|
10-30-2017, 08:46 PM
Post: #241
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Another question.
I do not remember to have read about a numeric solver for the 50g that solves returning the nearest integer. I did also a quick search focused on hpmuseum.org but the results are negative as well. The idea would be that the numeric solver searches only for integer solutions, not returning real ones. In some problems would be helpful. Wikis are great, Contribute :) |
|||
10-31-2017, 09:54 AM
Post: #242
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Observation about the 50g AUR bookmarked.
Even with all the bookmarks, search function and whatnot , I find the index at the end of the document quite powerful for searches based on one command. This especially if the word I am searching can be easily part of other words. For example AXL is easy to find, REPL requires the help of the index. My point is: document extensions that are meant to facilitate the search when the document is printed, such as the index at the end of the book, actually are helpful also with digital searches. In particular it is quite helpful if there is a bookmark to jump on the page that contains the indexed word. Wikis are great, Contribute :) |
|||
10-31-2017, 02:22 PM
(This post was last modified: 10-31-2017 02:32 PM by pier4r.)
Post: #243
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
I'd like to share the following little exploration.
Since I am trying to collect as much interesting digital content* as possible with the hp calc torrent I started also to use what I collect there, even just to check possible damaged documents. While re-reading the hp solve issue no1 , I noticed the exercises about approximating PI. The MoHPC forums are full of very beautiful attempts to compute as much digits of PI as possible in creative ways. Try on your favorite search engine the search string: site:hpmuseum.org compute pi (I tried it on google). Therefore I was unmoved by the exercise, I mean it appeared quite trivial (not the part with the continued fraction though). Nonetheless I gave it a shot to use a bit my 506w and I can be damned, it led to nice questions! From whatever exercise (or action) one can open up a nice world that one did not see before. So my related question to the exercise was to find the following: - given a fixed denominator D that is a whole number. - find the largest whole number L so that L/D < PI and the smallest whole number H so that H/D > PI - increase D of 1 and do the entire procedure again. In this way one find, for each fixed D, a range that enclose PI in terms of L and H. What interested me is that it seems that it builds a pattern pretty quickly: Code:
One can observe that after denominators that are multiple of 7 the next L is 3 units bigger as the previous H instead of 2. While I could explain myself why a range, for whatever denominator, seems to be only 1 unit large, I was curious about the +3 jump and so far I discovered that it is not only caused after denominators that are multiple of 7. The denominator that cause the next range to be 3 units apart is 113, from the famous 355/133. So thanks to the hp 50g and the following naive program Code:
and some manual manipulations directly on the hp50g I collected the denominators that shows L numerators with +3 difference from the previous H. The sequence is like: { 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 114, 121 ... }. The sequence is not yet in the OEIS database for what I know. To obtain it, after the \GDLIST pick all the positions that contains a 3 (with MPOS of the listEXT library it is easy) . Then divide the results by 2 and after that apply CEIL. It should return the related denominators of the range that was 3 unit away from the previous one. I am pretty sure this question was already explored, but still it is interesting for me to explore it myself. Does anyone has pointers to studies that explains what I am computing, so I can read them after I finish my personal attempt? (Edit: found two pointers, although I expected more https://oeis.org/A063438 -- https://oeis.org/A022844 ) Otherwise I should find the time to explain to myself, somehow, why the +2 distance? Why the +3 distances only after some denominators? Are there more distances? Etc... * related to the hp calculators (and calculators/math in general). Wikis are great, Contribute :) |
|||
10-31-2017, 03:12 PM
Post: #244
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(10-31-2017 02:22 PM)pier4r Wrote: Otherwise I should find the time to explain to myself, somehow, why the +2 distance? Why the +3 distances only after some denominators? Are there more distances? Etc... Start with the equality. A=number, not necessarily integer. L=Floor(A) and H=ceil(A). A/n=pi A=pi*n Therefore your L and H are: L=floor(n*pi) H=ceil(n*pi) This means in general, L and H both skip in pi steps as you increase n, but after you round with floor/ceil you only move 3 units, leaving a remainder of (pi-3) that accumulates for the next iteration. Once that reminder accumulates to 1 you'll skip 4 instead of 3. Turns out 1/(pi-3) = 7.06xxxx that's why you accumulate one unit every 7 iterations. |
|||
10-31-2017, 05:50 PM
(This post was last modified: 10-31-2017 05:51 PM by pier4r.)
Post: #245
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(10-31-2017 03:12 PM)Claudio L. Wrote: Start with the equality. A=number, not necessarily integer. L=Floor(A) and H=ceil(A). Nice idea, I should reflect on it to see if I can explain all the non-7-based skips. For the next time I ask you if you could put it in spoilers though, like this: Code:
Wikis are great, Contribute :) |
|||
10-31-2017, 06:23 PM
(This post was last modified: 10-31-2017 06:24 PM by pier4r.)
Post: #246
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
On a side note, recently I was trying to find a minimalist wallpaper with the German flag. My search skills did not help.
Since at the end a desktop wallpaper is a 2d image, I decided to attack the problem with some math, 50g and highcharts.js for plotting (or html5 canvas when things get rough, although highcharts.js is quite neat). So far I got this, that for me is quite satisfying. https://i.imgur.com/THesJyE.png preview the problem is that the canvas is pretty big, 3840 x 2880 and the points I used from a sine function are not much. hp50g code Code:
highcharts.js code Code:
Wikis are great, Contribute :) |
|||
11-05-2017, 04:05 PM
(This post was last modified: 11-05-2017 07:19 PM by pier4r.)
Post: #247
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
I am slowly continuing to explore the "integer numerator ranges that enclose pi" (I post it here and not in another thread because I already mentioned the exploration here).
At the moment I'd like to see how the numerators approaches pi keeping a dynamic TopX of approximations. The program I assembled so far does a lot of list processing and the listExt library of DavidM is super helpful. Especially KSORT is great. The program has the following idea: create a list that contains quintuplets { D NL NH VL VH } D: denominator NL: numerator low (minimum of the range given the denominator) NH: numerator high (maximum of the range given the denominator) VL: value NL/D VH: value NH/D I do not just add to the result all the quintuplets between firstDenominator (say 1) and maxDenominator (say 10). Instead I want to add those approximations that make it to the "actual top5", where actual means: considering the quintuplets computed so far. This excluding quintuplets that produce the same best approximation. For example 14 43 44 3.071... 3.14285... is considered equal to 7 21 22 3 3.14285... because the best approximation produced ( 44/14 ) is already in the top 5, since 22/7 was the first instance found for that approximation. (I may later on check if also the second approximation is worth the top5) The program is the following Code:
The program runs on my hp50g in 646 seconds for the first 1000 denominators. And uses 10232 seconds for the first 10k denominators. Seeing the fraction slowly closing in pi is satisfying. The values so far: Code:
I do not use heavy stack manipulations, although I use them more than before. For example I build the list only at the end of the iterations, as suggested by John Keith. I avoid too much stack acrobatics due to readability of the code but I am pretty sure other people could make the program way faster. Therefore I posted it because I am curious to see how it can be optimized. Wikis are great, Contribute :) |
|||
11-05-2017, 10:28 PM
(This post was last modified: 11-05-2017 10:29 PM by Joe Horn.)
Post: #248
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(11-05-2017 04:05 PM)pier4r Wrote: I am slowly continuing to explore the "integer numerator ranges that enclose pi" ... Although the following does not "optimize" your code per se, but rather replaces its algorithm with a much faster one, it still might be of some interest to you. Given any decimal fraction in level 2, and a maximum denominator in level 1, it returns the best fraction, much faster than the brute-force search method. Example: pi, 1000, DEC2FRAC --> 355/113 in 0.39 seconds pi, 100000, DEC2FRAC --> 312689/99532 in 0.43 seconds This program is a slight modification of a program on HP48 Goodies Disk #3. Everything after each "@" is a comment. Code: %%HP:T(3); HP 50g BYTES: 298.5 #ED4h <0|ɸ|0> -Joe- |
|||
11-07-2017, 07:33 PM
(This post was last modified: 11-07-2017 07:39 PM by pier4r.)
Post: #249
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Thanks Joe.
I do not really want a "brute force search" , rather to see how the improvements progresses (therefore keeping a dynamic topX of values). Nevertheless your code is interesting. I'll try to analyze it asap. Other question. As I wrote some weeks ago, I am collecting data in lists that are contained in a directory. Then I have a simple backup script that puts the directory on the SD card of the 50g. The other day I finally copied all the backups (150, one for each day) on the pc. With cygwin I can see, with the command file, that the files are HP 49 files, but they are not made by plain text as I would have expected. Is there a preferred convert tool that converts hp49 directories in their text equivalent on the pc? Otherwise I will check what I can do with the 50g, to store something that is "text editor friendly". Edit: if I store the directory as a string object. It works. So now I need a program similar to some I saw on this forum. The one I saw inspected directory and sub directories to order them by type and what not - it is quite a nice challenge; I'll have to go recursively in a directory and subdirectories to convert files from HPDIR to STR. The hp50g does everything, not only math and programming, it is even a platform for system administrators. Wikis are great, Contribute :) |
|||
11-07-2017, 09:26 PM
Post: #250
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(11-07-2017 07:33 PM)pier4r Wrote: The other day I finally copied all the backups (150, one for each day) on the pc. With cygwin I can see, with the command file, that the files are HP 49 files, but they are not made by plain text as I would have expected. You've probably already realized that →STR will help you out with this conversion. Note that it's not a 100% safe conversion, though. →STR will convert objects into strings which are similar to the object's representation when recalled to the stack, which doesn't necessarily contain an exact copy of the underlying data. (11-07-2017 07:33 PM)pier4r Wrote: Is there a preferred convert tool that converts hp49 directories in their text equivalent on the pc? Some objects stored on your calculator may not have an exact "text equivalent". In those cases, you may find that →STR creates placeholders for the parts it can't directly convert. (11-07-2017 07:33 PM)pier4r Wrote: Otherwise I will check what I can do with the 50g, to store something that is "text editor friendly". Back in this thread, we discussed another issue that you might run into with this. In particular, the names of objects on the calculator may not be compatible with the SD card's file system, so you might run into trouble saving the files. I also recall finding that I would run into sporadic "invalid DOS name" errors when attempting to copy objects to the SD card, even when there was no compatibility issue with the name in question. But that may have been isolated to some sort of file system corruption on the SD card (see the thread I referenced). I never was able to find a sequence of steps that would recreate those errors, though. |
|||
11-07-2017, 09:33 PM
(This post was last modified: 11-07-2017 09:33 PM by pier4r.)
Post: #251
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Thanks for the link, I saved in the bookmark to read it soon. Of course thanks for the general hint as well.
Wikis are great, Contribute :) |
|||
12-12-2017, 10:30 PM
(This post was last modified: 12-12-2017 10:43 PM by pier4r.)
Post: #252
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Today, while searching for a live stream on youtube regarding Berlin, I found a peculiar stream (regarding Tempelhof). It is a stream pointed for half of the image on an highway. I realized that with the view on the highway I could investigate myself, from home, one of the questions that I had during courses at the university: whether the frequency of "arrivals" on the highway would match easily the theoretical distributions that I studied (Poisson for example).
Problem: how do I collect the data? Aside from the errors of manual collection (that more or less should be systematic) , doing it completely in a manual way won't be fast enough. So once again the trusty calculator (50g) saves the day. With a rough but working program like the following Code:
I could collect timings for a short while. Then I did: DEPTH \->LIST to save them in a list. After that: 4 RND To shorten the timings to seconds. \GDLIST (delta list) to get the difference in seconds between entries. (it does not really work when the time distance is over 60 seconds) Then DUP LDDUP to get the single values Saving the list of values (the one done with \GDLIST ) in a variable, say TLIST1 and then having: L1: list with delta of timestamps 1 \<< DUP TLIST SWAP LCNT \>> DOSUBS One can get the value of how many times arrivals where within a certain amount of seconds. But the fun part is to collect data from the stream as "relaxing" activity. The entire process can be greatly improved, but I always think that the initial input/question can be useful (as input) when shared. Wikis are great, Contribute :) |
|||
12-17-2017, 10:05 AM
Post: #253
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
I thought a bit about it but with my (seemingly limited) experience I am not able to find a solution.
Is it possible to produce textbook notes for the hp 50g? I mean I know one can save text as a string. My point is, can one insert in a string also formulas, in a way that when they are viewed by the viewer in the 50g (or a 3rd party viewer library if needed) the formula appear as rendered in the textbook format? Similarly as instead of writing x+5=3 one can invoke mathjax in the forum writing \( x+5=3 \) . Because such notes may be useful to keep a readily explanation of some formulas. Thanks for the help Wikis are great, Contribute :) |
|||
12-18-2017, 02:26 AM
Post: #254
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
'expr' 0 →GROB turns any algebraic object 'expr' into a grob in EquationWriter format. The 0 is what tells →GROB to do this.
<0|ɸ|0> -Joe- |
|||
12-18-2017, 07:08 AM
Post: #255
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Thanks Joe , I will have to check it. Although for clarification I mean to convert a text, containing formulas, to a pretty format.
Something like "This text will contain a prettified traction 5/(3+x) More text" Wikis are great, Contribute :) |
|||
12-19-2017, 04:20 AM
Post: #256
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(12-18-2017 07:08 AM)pier4r Wrote: Thanks Joe , I will have to check it. Although for clarification I mean to convert a text, containing formulas, to a pretty format. No, there is no way for the 50g to magically know which parts of your text you want to be interpreted as an algebraic expression. I'd suggest handling the plain text separately from the algebraic expressions, then combining the results. <0|ɸ|0> -Joe- |
|||
12-19-2017, 09:15 PM
Post: #257
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Thanks. I expected that but I hoped in a simpler way than packing grobs together.
Another observation. In my data collection I observed that two lists of the same length, 193 elements, both holding reals, have two different sizes . One list has values between 0 and 4 (integers expressed as reals) and uses less than 500 bytes. The other holds integers expressed as reals from 0 to 520 and uses more than 2000 bytes. I thought that the size of a real number was always the same as long as the number could be saved as real. Wikis are great, Contribute :) |
|||
12-19-2017, 09:27 PM
(This post was last modified: 12-19-2017 10:38 PM by DavidM.)
Post: #258
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(12-19-2017 09:15 PM)pier4r Wrote: Another observation. In my data collection I observed that two lists of the same length, 193 elements, both holding reals, have two different sizes . One list has values between 0 and 4 (integers expressed as reals) and uses less than 500 bytes. Some reals are built-in to ROM (as are some exact integers), and are usually referenced in a list by their 2.5 byte address instead of the actual raw data (which consumes 10.5 bytes). In particular, all integer reals in the range -9..35 can be referenced this way. There's others, too, but that should give you some idea of where the size differences come from. |
|||
02-19-2018, 08:03 PM
(This post was last modified: 02-19-2018 08:25 PM by pier4r.)
Post: #259
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Is John H Meyers still active? It is impressive how many 48/50g-based contributions he made that pop ups in searches (same with DavidM, Joe Horn, James Prager and the like)!
I was searching about Inform (only 4 values per column) and I found this: https://groups.google.com/forum/#!topic/...2VOANxBLIs Impressive the dedication. And adding it to the userRPL entries. edit: if someone knows better replacements to INFORM, please share! edit2: if you wish to put INFORML and INLIST in port2, remember to edit INFORML to call :2:INLIST and your program to call :2:INFORML . (on the calculator :2:INLIST shows up as :2: INLIST with a space. Dunno why) Wikis are great, Contribute :) |
|||
02-19-2018, 09:25 PM
Post: #260
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(02-19-2018 08:03 PM)pier4r Wrote: Is John H Meyers still active? It is impressive how many 48/50g-based contributions he made that pop ups in searches (same with DavidM, Joe Horn, James Prager and the like)! A (possibly too) quick search seems to indicate that this was his last post in comp.sys.hp48 in late 2013, and I agree his contributions are amazing. I've learned it's generally necessary to read them several times to both follow and appreciate everything he's saying, and even then often I cannot fully do so. Also, he's quite acerbic, in an entertaining way, when annoyed. One of my favorite posts John contributed is this one about implementing the PI (Product) function on the 48/49/50. The short program listings are misleading regarding the elegance of his implementation. At least for me they are, ymmv. Dissecting this helped teach me about some of the subtleties of RPL. --Bob Prosperi |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)