• 1 Vote(s) - 5 Average
• 1
• 2
• 3
• 4
• 5
 My favorite integer sequence jaydfox Long Time Fellow Posts: 440 Threads: 31 Joined: Aug 2007 09/11/2014, 01:33 AM As promised previously, here's a version that initializes the SeqParts array to an arbitrary non-negative index in the sequence:   jdf_seq_v6.gp (Size: 13.35 KB / Downloads: 451) (08/20/2014, 02:11 PM)sheldonison Wrote: (...) I figured out how to initialize the SeqParts array for a power of 2, and then it is fast for numbers not to much bigger than that exact power of 2. What is the algorithm for initialization halfway to the next power of 2? For example (2^24+2^23)? I don't understand the polynomials well enough to write my own SeqPowers2 initialization starting with 3,6,12,24.... (08/20/2014, 07:57 PM)jaydfox Wrote: I'm still getting around to writing the code that calculates arbitrary terms of the sequence. It's actually a bit complicated, which is why I've been putting it off. Okay, I've updated quite a few functions, mostly to make them compatible with the new InitSeq() functions (which replace InitBinPartSeq() ). There's a new PrevSeq() function, which runs the sequence backwards. As such, the Seq() function can now take negative arguments, and will handle them accordingly. The InitSeq() function should demonstrate how the polynomials are used to calculate terms in the sequence. It is not optimized, but the sub-calls are, so it should still be reasonably fast. The InitSeq2() function is optimized. There are two main optimizations. First, the SeqPowers2() function is used to initialize the SeqParts array for the highest power of 2 in the provided index. Second, "negative" bits are used to reduce the number of calculations required. Between these two optimizations, you can quickly calculate terms which have low information. For example, InitSeq2(2^100) takes about 10 ms on my computer. InitSeq2(2^100 - 2^95) takes about 90 ms. However, InitSeq2(2^100\3) takes about 640 ms. Note that the binary representation of 2^100\3 has alternating 1's and 0's, and the use of negative bits cannot simplify this. For the InitSeq2() funciton, set the "show" parameter to 2 to view the bits. (Set the show parameter to "3" to get a printout of the SeqParts array at completion of the function call.) The output will look something like this: Code:(15:02) gp > InitSeq2(2^27-2^23-2^17+2^11-2^7, 2) size=27, bits=List([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]) size=28, bits=List([0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1]) A(125699968)=13989020196114224701143563476000978180153807452722418367111885874553950782754824115506668 (15:03) gp > In the example above, the first size/bits printout is using only positive bits. The second size/bits printout shows the same number, using negative bits. The left-most bit is the least significant. Once the sequence is initialized with InitSeq() or InitSeq2(), you can then use Seq() with positive or negative counts, or use NextSeq() and PrevSeq() directly. For example, to calculate the terms from 2^13-5 to 2^13+5 (which you can validate against this list at OEIS):     Now let's check out 2^60-5 through 2^60+5:     Final disclaimer: this was a complicated set of logic to pull together, and it doesn't help that I'm still getting used to indexing arrays from 1 instead of from 0 (PARI/gp is an outlier in this regard). So, I expect there are still a few bugs. Indeed, I had to re-edit the file several times while writing this post, as I found bugs while making screenshots or validating what I was writing. If I find any more bugs in the coming days, I'll post a small update, perhaps version "6b". ~ Jay Daniel Fox « Next Oldest | Next Newest »

 Messages In This Thread My favorite integer sequence - by tommy1729 - 07/27/2014, 08:44 PM RE: My favorite integer sequence - by jaydfox - 07/31/2014, 01:51 AM RE: My favorite integer sequence - by jaydfox - 08/01/2014, 01:53 AM RE: My favorite integer sequence - by Gottfried - 08/01/2014, 03:25 PM RE: My favorite integer sequence - by jaydfox - 08/01/2014, 05:04 PM RE: My favorite integer sequence - by sheldonison - 08/01/2014, 11:36 PM RE: My favorite integer sequence - by jaydfox - 08/01/2014, 11:57 PM RE: My favorite integer sequence - by jaydfox - 08/05/2014, 04:49 PM RE: My favorite integer sequence - by jaydfox - 08/05/2014, 05:57 PM RE: My favorite integer sequence - by Gottfried - 08/06/2014, 04:38 PM RE: My favorite integer sequence - by jaydfox - 08/07/2014, 01:19 AM RE: My favorite integer sequence - by jaydfox - 08/07/2014, 01:34 AM RE: My favorite integer sequence - by jaydfox - 08/09/2014, 09:42 AM RE: My favorite integer sequence - by Gottfried - 08/09/2014, 02:27 PM RE: My favorite integer sequence - by tommy1729 - 09/09/2014, 12:55 AM RE: My favorite integer sequence - by jaydfox - 08/08/2014, 12:55 AM RE: My favorite integer sequence - by Gottfried - 08/08/2014, 02:27 AM RE: My favorite integer sequence - by jaydfox - 09/09/2014, 07:43 PM RE: My favorite integer sequence - by jaydfox - 09/09/2014, 09:45 PM RE: My favorite integer sequence - by jaydfox - 08/02/2014, 12:08 AM RE: My favorite integer sequence - by tommy1729 - 08/03/2014, 11:38 PM RE: My favorite integer sequence - by sheldonison - 08/04/2014, 11:49 PM RE: My favorite integer sequence - by jaydfox - 09/16/2014, 05:32 AM RE: My favorite integer sequence - by Gottfried - 09/17/2014, 07:39 PM RE: My favorite integer sequence - by jaydfox - 10/02/2014, 10:53 PM RE: My favorite integer sequence - by Gottfried - 08/03/2014, 03:32 PM RE: My favorite integer sequence - by tommy1729 - 08/03/2014, 11:44 PM RE: My favorite integer sequence - by sheldonison - 08/02/2014, 05:48 AM RE: My favorite integer sequence - by tommy1729 - 09/10/2014, 08:57 PM RE: My favorite integer sequence - by Gottfried - 08/02/2014, 07:43 PM RE: My favorite integer sequence - by Gottfried - 08/02/2014, 09:29 PM RE: My favorite integer sequence - by Gottfried - 08/02/2014, 09:36 PM RE: My favorite integer sequence - by tommy1729 - 08/05/2014, 11:16 PM RE: My favorite integer sequence - by tommy1729 - 08/08/2014, 11:02 PM RE: My favorite integer sequence - by jaydfox - 08/09/2014, 07:02 PM RE: My favorite integer sequence - by jaydfox - 08/09/2014, 10:51 PM RE: My favorite integer sequence - by sheldonison - 08/11/2014, 04:51 PM RE: My favorite integer sequence - by jaydfox - 08/11/2014, 05:19 PM RE: My favorite integer sequence - by jaydfox - 08/19/2014, 01:36 AM RE: My favorite integer sequence - by jaydfox - 08/19/2014, 02:05 AM RE: My favorite integer sequence - by jaydfox - 08/19/2014, 05:31 PM RE: My favorite integer sequence - by sheldonison - 08/19/2014, 07:56 PM RE: My favorite integer sequence - by jaydfox - 08/20/2014, 07:42 AM RE: My favorite integer sequence - by sheldonison - 08/20/2014, 02:11 PM RE: My favorite integer sequence - by jaydfox - 08/20/2014, 07:57 PM RE: My favorite integer sequence - by jaydfox - 08/21/2014, 01:15 AM RE: My favorite integer sequence - by jaydfox - 08/21/2014, 05:25 AM RE: My favorite integer sequence - by jaydfox - 08/22/2014, 05:39 PM RE: My favorite integer sequence - by jaydfox - 09/11/2014, 01:33 AM RE: My favorite integer sequence - by tommy1729 - 08/09/2014, 09:16 PM RE: My favorite integer sequence - by jaydfox - 08/09/2014, 10:19 PM RE: My favorite integer sequence - by tommy1729 - 08/09/2014, 10:52 PM RE: My favorite integer sequence - by jaydfox - 08/09/2014, 11:46 PM RE: My favorite integer sequence - by tommy1729 - 08/09/2014, 11:10 PM RE: My favorite integer sequence - by jaydfox - 08/10/2014, 12:30 AM RE: My favorite integer sequence - by tommy1729 - 08/11/2014, 12:17 PM RE: My favorite integer sequence - by Gottfried - 08/22/2014, 12:30 AM Amazing variant - by tommy1729 - 08/26/2014, 08:57 PM RE: My favorite integer sequence - by tommy1729 - 09/01/2014, 10:37 PM RE: My favorite integer sequence - by tommy1729 - 10/02/2014, 11:24 PM RE: My favorite integer sequence - by jaydfox - 10/02/2014, 11:29 PM RE: My favorite integer sequence - by tommy1729 - 02/10/2015, 12:15 AM RE: My favorite integer sequence - by tommy1729 - 02/15/2015, 05:19 PM RE: My favorite integer sequence - by tommy1729 - 10/07/2015, 08:22 AM RE: My favorite integer sequence - by tommy1729 - 10/07/2015, 09:10 PM RE: My favorite integer sequence - by tommy1729 - 03/13/2016, 12:31 AM

 Possibly Related Threads... Thread Author Replies Views Last Post My favorite theorem tommy1729 0 4,154 08/15/2015, 09:58 PM Last Post: tommy1729

Users browsing this thread: 2 Guest(s)