cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A139250 Toothpick sequence (see Comments lines for definition).

This page as a plain text file.
%I A139250 #396 Dec 18 2024 14:59:06
%S A139250 0,1,3,7,11,15,23,35,43,47,55,67,79,95,123,155,171,175,183,195,207,
%T A139250 223,251,283,303,319,347,383,423,483,571,651,683,687,695,707,719,735,
%U A139250 763,795,815,831,859,895,935,995,1083,1163,1199,1215,1243,1279,1319,1379
%N A139250 Toothpick sequence (see Comments lines for definition).
%C A139250 A toothpick is a copy of the closed interval [-1,1]. (In the paper, we take it to be a copy of the unit interval [-1/2, 1/2].)
%C A139250 We start at stage 0 with no toothpicks.
%C A139250 At stage 1 we place a toothpick in the vertical direction, anywhere in the plane.
%C A139250 In general, given a configuration of toothpicks in the plane, at the next stage we add as many toothpicks as possible, subject to certain conditions:
%C A139250 - Each new toothpick must lie in the horizontal or vertical directions.
%C A139250 - Two toothpicks may never cross.
%C A139250 - Each new toothpick must have its midpoint touching the endpoint of exactly one existing toothpick.
%C A139250 The sequence gives the number of toothpicks after n stages. A139251 (the first differences) gives the number added at the n-th stage.
%C A139250 Call the endpoint of a toothpick "exposed" if it does not touch any other toothpick. The growth rule may be expressed as follows: at each stage, new toothpicks are placed so their midpoints touch every exposed endpoint.
%C A139250 This is equivalent to a two-dimensional cellular automaton. The animations show the fractal-like behavior.
%C A139250 After 2^k - 1 steps, there are 2^k exposed endpoints, all located on two lines perpendicular to the initial toothpick. At the next step, 2^k toothpicks are placed on these lines, leaving only 4 exposed endpoints, located at the corners of a square with side length 2^(k-1) times the length of a toothpick. - _M. F. Hasler_, Apr 14 2009 and others. For proof, see the Applegate-Pol-Sloane paper.
%C A139250 If the third condition in the definition is changed to "- Each new toothpick must have at exactly one of its endpoints touching the midpoint of an existing toothpick" then the same sequence is obtained. The configurations of toothpicks are of course different from those in the present sequence. But if we start with the configurations of the present sequence, rotate each toothpick a quarter-turn, and then rotate the whole configuration a quarter-turn, we obtain the other configuration.
%C A139250 If the third condition in the definition is changed to "- Each new toothpick must have at least one of its endpoints touching the midpoint of an existing toothpick" then the sequence n^2 - n + 1 is obtained, because there are no holes left in the grid.
%C A139250 A "toothpick" of length 2 can be regarded as a polyedge with 2 components, both on the same line. At stage n, the toothpick structure is a polyedge with 2*a(n) components.
%C A139250 Conjecture: Consider the rectangles in the sieve (including the squares). The area of each rectangle (A = b*c) and the edges (b and c) are powers of 2, but at least one of the edges (b or c) is <= 2.
%C A139250 In the toothpick structure, if n >> 1, we can see some patterns that look like "canals" and "diffraction patterns". For example, see the Applegate link "A139250: the movie version", then enter n=1008 and click "Update". See also "T-square (fractal)" in the Links section. - _Omar E. Pol_, May 19 2009, Oct 01 2011
%C A139250 From _Benoit Jubin_, May 20 2009: The web page "Gallery" of Chris Moore (see link) has some nice pictures that are somewhat similar to the pictures of the present sequence. What sequences do they correspond to?
%C A139250 For a connection to Sierpiński triangle and Gould's sequence A001316, see the leftist toothpick triangle A151566.
%C A139250 _Eric Rowland_ comments on Mar 15 2010 that this toothpick structure can be represented as a 5-state CA on the square grid. On Mar 18 2010, _David Applegate_ showed that three states are enough. See links.
%C A139250 Equals row sums of triangle A160570 starting with offset 1; equivalent to convolving A160552: (1, 1, 3, 1, 3, 5, 7, ...) with (1, 2, 2, 2, ...). Equals A160762: (1, 0, 2, -2, 2, 2, 2, -6, ...) convolved with 2*n - 1: (1, 3, 5, 7, ...). Starting with offset 1 equals A151548: [1, 3, 5, 7, 5, 11, 17, 15, ...] convolved with A078008 signed (A151575): [1, 0, 2, -2, 6, -10, 22, -42, 86, -170, 342, ...]. - _Gary W. Adamson_, May 19 2009, May 25 2009
%C A139250 For a three-dimensional version of the toothpick structure, see A160160. - _Omar E. Pol_, Dec 06 2009
%C A139250 From _Omar E. Pol_, May 20 2010: (Start)
%C A139250 Observation about the arrangement of rectangles:
%C A139250 It appears there is a nice pattern formed by distinct modular substructures: a central cross surrounded by asymmetrical crosses (or "hidden crosses") of distinct sizes and also by "nuclei" of crosses.
%C A139250 Conjectures: after 2^k stages, for k >= 2, and for m = 1 to k - 1, there are 4^(m-1) substructures of size s = k - m, where every substructure has 4*s rectangles. The total number of substructures is equal to (4^(k-1)-1)/3 = A002450(k-1). For example: If k = 5 (after 32 stages) we can see that:
%C A139250 a) There is a central cross, of size 4, with 16 rectangles.
%C A139250 b) There are four hidden crosses, of size 3, where every cross has 12 rectangles.
%C A139250 c) There are 16 hidden crosses, of size 2, where every cross has 8 rectangles.
%C A139250 d) There are 64 nuclei of crosses, of size 1, where every nucleus has 4 rectangles.
%C A139250 Hence the total number of substructures after 32 stages is equal to 85. Note that in every arm of every substructure, in the potential growth direction, the length of the rectangles are the powers of 2. (See illustrations in the links. See also A160124.) (End)
%C A139250 It appears that the number of grid points that are covered after n-th stage of the toothpick structure, assuming the toothpicks have length 2*k, is equal to (2*k-2)*a(n) + A147614(n), k > 0. See the formulas of A160420 and A160422. - _Omar E. Pol_, Nov 13 2010
%C A139250 Version "Gullwing": on the semi-infinite square grid, at stage 1, we place a horizontal "gull" with its vertices at [(-1, 2), (0, 1), (1, 2)]. At stage 2, we place two vertical gulls. At stage 3, we place four horizontal gulls. a(n) is also the number of gulls after n-th stage. For more information about the growth of gulls see A187220. - _Omar E. Pol_, Mar 10 2011
%C A139250 From _Omar E. Pol_, Mar 12 2011: (Start)
%C A139250 Version "I-toothpick": we define an "I-toothpick" to consist of two connected toothpicks, as a bar of length 2. An I-toothpick with length 2 is formed by two toothpicks with length 1. The midpoint of an I-toothpick is touched by its two toothpicks. a(n) is also the number of I-toothpicks after n-th stage in the I-toothpick structure. The I-toothpick structure is essentially the original toothpick structure in which every toothpick is replaced by an I-toothpick. Note that in the physical model of the original toothpick structure the midpoint of a wooden toothpick of the new generation is superimposed on the endpoint of a wooden toothpick of the old generation. However, in the physical model of the I-toothpick structure the wooden toothpicks are not overlapping because all wooden toothpicks are connected by their endpoints. For the number of toothpicks in the I-toothpick structure see A160164 which also gives the number of gullwing in a gullwing structure because the gullwing structure of A160164 is equivalent to the I-toothpick structure. It also appears that the gullwing sequence A187220 is a supersequence of the original toothpick sequence A139250 (this sequence).
%C A139250 For the connection with the Ulam-Warburton cellular automaton see the Applegate-Pol-Sloane paper and see also A160164 and A187220.
%C A139250 (End)
%C A139250 A version in which the toothpicks are connected by their endpoints: on the semi-infinite square grid, at stage 1, we place a vertical toothpick of length 1 from (0, 0). At stage 2, we place two horizontal toothpicks from (0,1), and so on. The arrangement looks like half of the I-toothpick structure. a(n) is also the number of toothpicks after the n-th. - _Omar E. Pol_, Mar 13 2011
%C A139250 Version "Quarter-circle" (or Q-toothpick): a(n) is also the number of Q-toothpicks after the n-th stage in a Q-toothpick structure in the first quadrant. We start from (0,1) with the first Q-toothpick centered at (1, 1). The structure is asymmetric. For a similar structure but starting from (0, 0) see A187212. See A187210 and A187220 for more information. - _Omar E. Pol_, Mar 22 2011
%C A139250 Version "Tree": It appears that a(n) is also the number of toothpicks after the n-th stage in a toothpick structure constructed following a special rule: the toothpicks of the new generation have length 4 when they are placed on the infinite square grid (note that every toothpick has four components of length 1), but after every stage, one (or two) of the four components of every toothpick of the new generation is removed, if such component contains an endpoint of the toothpick and if such endpoint is touching the midpoint or the endpoint of another toothpick. The truncated endpoints of the toothpicks remain exposed forever. Note that there are three sizes of toothpicks in the structure: toothpicks of lengths 4, 3 and 2. A159795 gives the total number of components in the structure after the n-th stage. A153006 (the corner sequence of the original version) gives 1/4 of the total of components in the structure after the n-th stage. - _Omar E. Pol_, Oct 24 2011
%C A139250 From _Omar E. Pol_, Sep 16 2012: (Start)
%C A139250 It appears that a(n)/A147614(n) converges to 3/4.
%C A139250 It appears that a(n)/A160124(n) converges to 3/2.
%C A139250 It appears that a(n)/A139252(n) converges to 3.
%C A139250 Also:
%C A139250 It appears that A147614(n)/A160124(n) converges to 2.
%C A139250 It appears that A160124(n)/A139252(n) converges to 2.
%C A139250 It appears that A147614(n)/A139252(n) converges to 4.
%C A139250 (End)
%C A139250 It appears that a(n) is also the total number of ON cells after n-th stage in a quadrant of the structure of the cellular automaton described in A169707 plus the total number of ON cells after n+1 stages in a quadrant of the mentioned structure, without its central cell. See the illustration of the NW-NE-SE-SW version in A169707. See also the connection between A160164 and A169707. - _Omar E. Pol_, Jul 26 2015
%C A139250 On the infinite Cairo pentagonal tiling consider the symmetric figure formed by two non-adjacent pentagons connected by a line segment joining two trivalent nodes. At stage 1 we start with one of these figures turned ON. The rule for the next stages is that the concave part of the figures of the new generation must be adjacent to the complementary convex part of the figures of the old generation. a(n) gives the number of figures that are ON in the structure after n-th stage. A160164(n) gives the number of ON cells in the structure after n-th stage. - _Omar E. Pol_, Mar 29 2018
%C A139250 From _Omar E. Pol_, Mar 06 2019: (Start)
%C A139250 The "word" of this sequence is "ab". For further information about the word of cellular automata see A296612.
%C A139250 Version "triangular grid": a(n) is also the total number of toothpicks of length 2 after n-th stage in the toothpick structure on the infinite triangular grid, if we use only two of the three axes. Otherwise, if we use the three axes, so we have the sequence A296510 which has word "abc".
%C A139250 The normal toothpick structure can be considered a superstructure of the Ulam-Warburton celular automaton since A147562(n) equals here the total number of "hidden crosses" after 4*n stages, including the central cross (beginning to count the crosses when their "nuclei" are totally formed with 4 quadrilaterals). Note that every quadrilateral in the structure belongs to a "hidden cross".
%C A139250 Also, the number of "hidden crosses" after n stages equals the total number of "flowers with six petals" after n-th stage in the structure of A323650, which appears to be a "missing link" between this sequence and A147562.
%C A139250 Note that the location of the "nuclei of the hidden crosses" is very similar (essentially the same) to the location of the "flowers with six petals" in the structure of A323650 and to the location of the "ON" cells in the version "one-step bishop" of the Ulam-Warburton cellular automaton of A147562. (End)
%C A139250 From _Omar E. Pol_, Nov 27 2020: (Start)
%C A139250 The simplest substructures are the arms of the hidden crosses. Each closed region (square or rectangle) of the structure belongs to one of these arms. The narrow arms have regions of area 1, 2, 4, 8, ... The broad arms have regions of area 2, 4, 8, 16 , ... Note that after 2^k stages, with k >= 3, the narrow arms of the main hidden crosses in each quadrant frame the size of the toothpick structure after 2^(k-1) stages.
%C A139250 Another kind of substructure could be called "bar chart" or "bar graph". This substructure is formed by the rectangles and squares of width 2 that are adjacent to any of the four sides of the toothpick structure after 2^k stages, with k >= 2. The height of these successive regions gives the first 2^(k-1) - 1 terms from A006519. For example: if k = 5 the respective heights after 32 stages are [1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1]. The area of these successive regions gives the first 2^(k-1) - 1 terms of A171977. For example: if k = 5 the respective areas are [2, 4, 2, 8, 2, 4, 2, 16, 2, 4, 2, 8, 2, 4, 2].
%C A139250 For a connection to Mersenne primes (A000668) and perfect numbers (A000396) see A153006.
%C A139250 For a representation of the Wagstaff primes (A000979) using the toothpick structure see A194810.
%C A139250 For a connection to stained glass windows and a hidden curve see A336532. (End)
%C A139250 It appears that the graph of a(n) bears a striking resemblance to the cumulative distribution function F(x) for X the random variable taking values in [0,1], where the binary expansion of X is given by a sequence of independent coin tosses with probability 3/4 of being 1 at each bit. It appears that F(n/2^k)*(2^(2k+1)+1)/3 approaches a(n) for k large. - _James Coe_, Jan 10 2022
%D A139250 D. Applegate, Omar E. Pol and N. J. A. Sloane, The Toothpick Sequence and Other Sequences from Cellular Automata, Congressus Numerantium, Vol. 206 (2010), 157-191
%D A139250 L. D. Pryor, The Inheritance of Inflorescence Characters in Eucalyptus, Proceedings of the Linnean Society of New South Wales, V. 79, (1954), p. 81, 83.
%D A139250 Richard P. Stanley, Enumerative Combinatorics, volume 1, second edition, chapter 1, exercise 95, figure 1.28, Cambridge University Press (2012), p. 120, 166.
%H A139250 N. J. A. Sloane, <a href="/A139250/b139250.txt">Table of n, a(n) for n = 0..65535</a>
%H A139250 AlgoMotion, <a href="https://www.youtube.com/watch?v=_7oxzD9SFKo">Toothpick Sequence Visualized with Circle of Fifths Harmony | 256 Steps</a>, Youtube video (2024).
%H A139250 David Applegate, <a href="/A139250/a139250.anim.html">The movie version</a>
%H A139250 David Applegate, <a href="/A139250/a139250.anim.32.gif">Animation of first 32 stages</a>
%H A139250 David Applegate, <a href="/A139250/a139250.anim.64.gif">Animation of first 64 stages</a>
%H A139250 David Applegate, <a href="/A139250/a139250.anim.128.gif">Animation of first 128 stages</a>
%H A139250 David Applegate, <a href="/A139250/a139250.anim.256.gif">Animation of first 256 stages</a>
%H A139250 David Applegate, <a href="/A139250/a139250ps.cc">C++ program to generate these animations - creates postscript for a specific n</a>
%H A139250 David Applegate, <a href="/A139250/a139250_gengif.txt">Generates many postscripts, converts them to gifs, and glues the gifs together into an animation</a>
%H A139250 David Applegate, <a href="/A139250/a139250_bfiles.cc">Generates b-files for A139250, A139251, A147614</a>
%H A139250 David Applegate, <a href="/A139250/a139250_b.txt">The b-files for A139250, A139251, A147614 side-by-side</a>
%H A139250 David Applegate, <a href="/A139250/a139250_3state.txt">A three-state CA for the toothpick structure</a>
%H A139250 David Applegate, Omar E. Pol and N. J. A. Sloane, <a href="/A000695/a000695_1.pdf">The Toothpick Sequence and Other Sequences from Cellular Automata</a>, Congressus Numerantium, Vol. 206 (2010), 157-191. [There is a typo in Theorem 6: (13) should read u(n) = 4.3^(wt(n-1)-1) for n >= 2.], which is also available at <a href="http://arxiv.org/abs/1004.3036">arXiv:1004.3036v2</a>
%H A139250 Joe Champion, <a href="http://boisemathcircles.org/bmc-sessions/toothpicks">Ultimate toothpick pattern</a>, <a href="http://web.archive.org/web/20171110234607/http://i1.wp.com/boisemathcircles.org/wp-content/uploads/2015/09/IMG_0004.jpg">Photo 1</a>, <a href="http://web.archive.org/web/20171110234732/http://i2.wp.com/boisemathcircles.org/wp-content/uploads/2015/09/IMG_0003.jpg">Photo 2</a>, <a href="http://web.archive.org/web/20171110234538/http://i2.wp.com/boisemathcircles.org/wp-content/uploads/2015/09/IMG_0006.jpg">Photo 3</a>, <a href="http://web.archive.org/web/20171110234402/http://i1.wp.com/boisemathcircles.org/wp-content/uploads/2015/09/IMG_0005.jpg">Photo 4</a>, Boise Math Circles, Boise State University. [Links updated by _P. Michael Hutchins_, Mar 03 2018]
%H A139250 Barry Cipra, <a href="http://home.gwu.edu/~maxal/943.pdf">What comes next?</a>, Science (AAAS) 327: 943.
%H A139250 Steven R. Finch, <a href="/A139250/a139250_1.pdf">Toothpicks and Live Cells</a>, July 21, 2015. [Cached copy, with permission of the author]
%H A139250 Ulrich Gehmann, Martin Reiche, <a href="http://dump.artofdata.de/wmm_book_hq.pdf">World mountain machine</a>, Berlin, (2014), first edition, p. 205, 238, 253.
%H A139250 Mats Granvik, <a href="/A139250/a139250c.jpg">Additional illustration</a>: Number blocks where each number tells how many times a point on the square grid is crossed or connected to by a toothpick, Jun 21 2009.
%H A139250 Gordon Hamilton, <a href="http://youtu.be/7efCz2FvUDI">Three integer sequences from recreational mathematics</a>, Video (2013?).
%H A139250 J. K. Hamilton, I. R. Hooper, and C. R. Lawrence, <a href="https://doi.org/10.7716/aem.v10i3.1803">Exploring microwave absorption by non-periodic metasurfaces</a>, Advanced Electromagnetics, 10(3), 1-6 (2021).
%H A139250 M. F. Hasler, <a href="/A139250/a139250.pdf">Illustration of initial terms</a>
%H A139250 M. F. Hasler, <a href="http://docs.google.com/Presentation?id=d34bxwj_236hcjnm6dc">Illustrations (Three slides)</a>
%H A139250 Brian Hayes, <a href="http://bit-player.org/2013/joshua-trees-and-toothpicks">Joshua Trees and Toothpicks</a>
%H A139250 Brian Hayes, <a href="/A139250/a139250_Hayes.png">Idealized Joshua tree</a>, a figure from "Joshua Trees and Toothpicks" (see preceding link)
%H A139250 Brian Hayes, <a href="http://bit-player.org/extras/toothpicks/toothpicks.html">The Toothpick Sequence - Bit-Player</a>
%H A139250 Benoit Jubin, <a href="/A139250/a139250.txt">Illustration of initial terms</a>
%H A139250 Mathemaesthetics, <a href="https://www.youtube.com/watch?v=-OxLqcGLdqI">2'796'203 Toothpicks, 2'048 Generations</a>, Youtube video (2021).
%H A139250 Ayliean McDonald, <a href="https://www.youtube.com/watch?v=8z1_8ZVGhwo">Toothpick fractal and breaking rules</a>, Youtube video (2021)
%H A139250 Chris Moore, <a href="http://www.santafe.edu/~moore/gallery.html">Gallery</a>, see the section on David Griffeath's Cellular Automata.
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp4d4.jpg">Illustration of initial terms</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp6d4.jpg">Illustration of initial terms using "gulls" (or G-toothpicks)</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp7d4.jpg">Illustration of initial terms using quarter-circles (or Q-toothpicks)</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp283.jpg">Illustration of the toothpick structure (after 23 steps)</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp683.jpg">Illustration of patterns in the toothpick structure (after 32 steps)</a>
%H A139250 Omar E. Pol, <a href="/A139250/a139250.jpg">Illustration of patterns in the toothpick structure (after 32 steps)</a> [Cached copy, with permission]
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/polca001.jpg">Illustration of initial terms of A139250, A160120, A147562 (Overlapping figures)</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp120.jpg">Illustration of initial terms of A160120, A161206, A161328, A161330 (triangular grid and toothpick structure)</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp684.jpg">Illustration of the substructures in the first quadrant (As pieces of a puzzle), after 32 stages</a>
%H A139250 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp685.jpg">Illustration of the potential growth direction of the arms of the substructures, after 32 stages</a>
%H A139250 Olbaid Fractalium, <a href="https://www.youtube.com/watch?v=kc8mzwzRyHo">Toothpick sequence Part 1</a>, (Watch from minute 0:00 until 3:13), Youtube video (2023).
%H A139250 Programing Puzzles & Code Golf Stack Exchange, <a href="http://codegolf.stackexchange.com/questions/64650/generate-toothpick-sequence">Generate toothpick sequence</a>
%H A139250 L. D. Pryor, <a href="http://www.biodiversitylibrary.org/item/108709#page/155/mode/1up">Illustration of initial terms (Fig. 2a)</a>
%H A139250 L. D. Pryor, <a href="http://www.biodiversitylibrary.org/item/108709#page/151/mode/1up">The Inheritance of Inflorescence Characters in Eucalyptus</a>, Proceedings of the Linnean Society of New South Wales, V. 79, (1954), p. 79-89.
%H A139250 E. Rowland, <a href="/A139250/a139250_Rowland.txt">Toothpick sequence from cellular automaton on square grid</a>
%H A139250 E. Rowland, <a href="/A139250/a139250_Rowland.jpg">Initial stages of toothpick sequence from cellular automaton on square grid (includes Mathematica code)</a>
%H A139250 K. Ryde, <a href="http://search.cpan.org/~kryde/Math-PlanePath-Toothpick-18/lib/Math/PlanePath/ToothpickTree.pm">ToothpickTree</a>.
%H A139250 Daniel Shiffman, <a href="https://www.youtube.com/watch?v=-OL_sw2MiYw&amp;t=152s">Coding Challenge #126: Toothpicks</a>, The Coding Train video (2018)
%H A139250 N. J. A. Sloane, <a href="/wiki/Catalog_of_Toothpick_and_CA_Sequences_in_OEIS">Catalog of Toothpick and Cellular Automata Sequences in the OEIS</a>
%H A139250 N. J. A. Sloane and Brady Haran, <a href="https://www.youtube.com/watch?v=_UtCli1SgjI">Terrific Toothpick Patterns</a>, Numberphile video (2018)
%H A139250 Alex van den Brandhof and Paul Levrie, <a href="https://www.pyth.eu/uploads/user/ArchiefPDF/Pyth55-6.pdf">Tandenstokerrij</a>, Pythagoras, Wiskundetijdschrift voor Jongeren, 55ste Jaargang, Nummer 6, Juni 2016, (see the cover, pages 1, 18, 19 and the back cover).
%H A139250 Lu Wang, <a href="https://www.youtube.com/watch?v=l4bULIk9AAc">Minecraft Toothpicks N = 53</a>
%H A139250 Wikipedia, <a href="https://en.wikipedia.org/wiki/Cairo_pentagonal_tiling">Cairo pentagonal tiling</a>
%H A139250 Wikipedia, <a href="http://en.wikipedia.org/wiki/H_tree">H tree</a>
%H A139250 Wikipedia, <a href="http://en.wikipedia.org/wiki/Toothpick_sequence">Toothpick sequence</a>
%H A139250 Wikipedia, <a href="http://en.wikipedia.org/wiki/T-square_(fractal)">T-square (fractal)</a>
%H A139250 <a href="/index/To#toothpick">Index entries for sequences related to toothpick sequences</a>
%H A139250 <a href="/index/Ce#cell">Index entries for sequences related to cellular automata</a>
%F A139250 a(2^k) = A007583(k), if k >= 0.
%F A139250 a(2^k-1) = A006095(k+1), if k >= 1.
%F A139250 a(A000225(k)) - a((A000225(k)-1)/2) = A006516(k), if k >= 1.
%F A139250 a(A000668(k)) - a((A000668(k)-1)/2) = A000396(k), if k >= 1.
%F A139250 G.f.: (x/((1-x)*(1+2*x))) * (1 + 2*x*Product_{k>=0} (1 + x^(2^k-1) + 2*x^(2^k))). - _N. J. A. Sloane_, May 20 2009, Jun 05 2009
%F A139250 One can show that lim sup a(n)/n^2 = 2/3, and it appears that lim inf a(n)/n^2 is 0.451... - _Benoit Jubin_, Apr 15 2009 and Jan 29 2010, _N. J. A. Sloane_, Jan 29 2010
%F A139250 Observation: a(n) == 3 (mod 4) for n >= 2. - _Jaume Oliver Lafont_, Feb 05 2009
%F A139250 a(2^k-1) = A000969(2^k-2), if k >= 1. - _Omar E. Pol_, Feb 13 2010
%F A139250 It appears that a(n) = (A187220(n+1) - 1)/2. - _Omar E. Pol_, Mar 08 2011
%F A139250 a(n) = 4*A153000(n-2) + 3, if n >= 2. - _Omar E. Pol_, Oct 01 2011
%F A139250 It appears that a(n) = A160552(n) + (A169707(n) - 1)/2, n >= 1. - _Omar E. Pol_, Feb 15 2015
%F A139250 It appears that a(n) = A255747(n) + A255747(n-1), n >= 1. - _Omar E. Pol_, Mar 16 2015
%F A139250 Let n = msb(n) + j where msb(n) = A053644(n) and let a(0) = 0. Then a(n) = (2 * msb(n)^2 + 1)/3 + 2 * a(j) + a(j+1) - 1. - _David A. Corneth_, Mar 26 2015
%F A139250 It appears that a(n) = (A169707(n) - 1)/4 + (A169707(n+1) - 1)/4, n >= 1. - _Omar E. Pol_, Jul 24 2015
%e A139250 a(10^10) = 52010594272060810683. - _David A. Corneth_, Mar 26 2015
%p A139250 G := (x/((1-x)*(1+2*x))) * (1 + 2*x*mul(1+x^(2^k-1)+2*x^(2^k),k=0..20)); # _N. J. A. Sloane_, May 20 2009, Jun 05 2009
%p A139250 # From _N. J. A. Sloane_, Dec 25 2009: A139250 is T, A139251 is a.
%p A139250 a:=[0,1,2,4]; T:=[0,1,3,7]; M:=10;
%p A139250 for k from 1 to M do
%p A139250 a:=[op(a),2^(k+1)];
%p A139250 T:=[op(T),T[nops(T)]+a[nops(a)]];
%p A139250 for j from 1 to 2^(k+1)-1 do
%p A139250 a:=[op(a), 2*a[j+1]+a[j+2]];
%p A139250 T:=[op(T),T[nops(T)]+a[nops(a)]];
%p A139250 od: od: a; T;
%t A139250 CoefficientList[ Series[ (x/((1 - x)*(1 + 2x))) (1 + 2x*Product[1 + x^(2^k - 1) + 2*x^(2^k), {k, 0, 20}]), {x, 0, 53}], x] (* _Robert G. Wilson v_, Dec 06 2010 *)
%t A139250 a[0] = 0; a[n_] := a[n] = Module[{m, k}, m = 2^(Length[IntegerDigits[n, 2]] - 1); k = (2m^2+1)/3; If[n == m, k, k + 2 a[n - m] + a[n - m + 1] - 1]]; Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Oct 06 2018, after _David A. Corneth_ *)
%o A139250 (PARI)
%o A139250 A139250(n,print_all=0)={my(p=[], /* set of "used" points. Points are written as complex numbers, c=x+iy. Toothpicks are of length 2 */
%o A139250 ee=[[0,1]], /* list of (exposed) endpoints. Exposed endpoints are listed as [c,d] where c=x+iy is the position of the endpoint, and d (unimodular) is the direction */
%o A139250 c,d,ne, cnt=1); print_all && print1("0,1"); n<2 && return(n);
%o A139250 for(i=2,n, p=setunion(p, Set(Mat(ee~)[,1])); /* add endpoints (discard directions) from last move to "used" points */
%o A139250 ne=[]; /* new (exposed) endpoints */
%o A139250 for( k=1, #ee, /* add endpoints of new toothpicks if not among the used points */
%o A139250 setsearch(p, c=ee[k][1]+d=ee[k][2]*I) || ne=setunion(ne,Set([[c,d]]));
%o A139250 setsearch(p, c-2*d) || ne=setunion(ne,Set([[c-2*d,-d]]));
%o A139250 ); /* using Set() we have the points sorted, so it's easy to remove those which finally are not exposed because they touch a new toothpick */
%o A139250 forstep( k=#ee=eval(ne), 2, -1, ee[k][1]==ee[k-1][1] && k-- && ee=vecextract(ee,Str("^"k"..",k+1)));
%o A139250 cnt+=#ee; /* each exposed endpoint will give a new toothpick */
%o A139250 print_all && print1(","cnt));cnt} \\ _M. F. Hasler_, Apr 14 2009
%o A139250 (PARI)
%o A139250 \\works for n > 0
%o A139250 a(n) = {my(k = (2*msb(n)^2 + 1) / 3); if(n==msb(n),k , k + 2*a(n-msb(n)) + a(n - msb(n) + 1) - 1)}
%o A139250 msb(n)=my(t=0);while(n>>t>0,t++);2^(t-1)\\ _David A. Corneth_, Mar 26 2015
%o A139250 (Python)
%o A139250 def msb(n):
%o A139250     t = 0
%o A139250     while n>>t > 0:
%o A139250         t += 1
%o A139250     return 2**(t - 1)
%o A139250 def a(n):
%o A139250     k = (2 * msb(n)**2 + 1) / 3
%o A139250     return 0 if n == 0 else k if n == msb(n) else k + 2*a(n - msb(n)) + a(n - msb(n) + 1) - 1
%o A139250 [a(n) for n in range(101)]  # _Indranil Ghosh_, Jul 01 2017, after _David A. Corneth_'s PARI script
%Y A139250 Cf. A000079, A002450, A006519, A139251, A139252, A139253, A147614, A139560, A152968, A152978, A152980, A152998, A153000, A153001, A153003, A153004, A153006, A153007, A000217, A007583, A007683, A000396, A000225, A000668, A006516, A006095, A019988, A160570, A160552, A000969, A001316, A151566, A160406, A160408, A160702, A078008, A151548, A001045, A147562, A160124, A160120, A160160, A160170, A160172, A161206, A161328, A161330, A171977, A194810, A296510, A296612, A299476, A299478, A323650, A336532.
%K A139250 nonn,look,nice
%O A139250 0,3
%A A139250 _Omar E. Pol_, Apr 24 2008
%E A139250 Verified and extended, a(49)-a(53), using the given PARI code by _M. F. Hasler_, Apr 14 2009
%E A139250 Edited by _N. J. A. Sloane_, Apr 29 2009, incorporating comments from _Omar E. Pol_, _M. F. Hasler_, _Rob Pratt_, _Jaume Oliver Lafont_, _Franklin T. Adams-Watters_, _R. J. Mathar_, _David W. Wilson_, _David Applegate_, _Benoit Jubin_ and others.
%E A139250 Further edited by _N. J. A. Sloane_, Jan 28 2010