%I
%S 0,1,3,7,15,23,31,47,71,87,95,111,135,159,191,247,311,343,351,367,391,
%T 415,447,503,567,607,639,695,767,847,967,1143,1303,1367,1375,1391,
%U 1415,1439,1471,1527,1591,1631,1663,1719,1791,1871,1991,2167,2327,2399,2431
%N Gullwing sequence (see Comments lines for precise definition).
%C The Gullwing (or Gtoothpick) sequence is a special type of toothpick sequence. It appears that this is a superstructure of A139250.
%C We define a "Gtoothpick" to consist of two arcs of length Pi/2 forming a "gullwing" whose total length is equal to Pi = 3.141592...
%C A gullwingshaped toothpick or Gtoothpick or simply "gull" is formed by two Qtoothpicks (see A187210).
%C A Gtoothpick has a midpoint and two endpoints. An endpoint is said to be "exposed" if it is not the midpoint or endpoint of any other Gtoothpick.
%C The sequence gives the number of Gtoothpicks in the structure after n stages. A187221 (the first differences) gives the number of Gtoothpicks added at nth stage.
%C a(n) is also the diameter of a circle whose circumference equals the total length of all gulls in the gullwing structure after n stages.
%C It appears that the gullwing pattern has a recursive, fractallike structure. An animation will show the likefractal behavior.
%C Note that the structure contains many different types of geometrical figures, for example: circles, hearts, etc. All figures are formed by arcs.
%C It appears that there are infinitely many types of circular shapes, which are related to the rectangles of the toothpick structure of A139250.
%C It also appears that the structure contains a nice pattern formed by distinct modular substructures: one central cross surrounded by several asymmetrical crosses (or "hidden crosses") of distinct sizes, and also several "nuclei" of crosses. This pattern is essentially similar to the crosses of A139250 but here the structure is harder to see. For example, consider the nucleus of a cross; in the toothpick structure a nucleus is formed by two squares and two rectangles but here a nucleus is formed by two circles and two hearts.
%C It appears furthermore that this structure has connections with the squarecross fractal and with the Tsquare fractal, just as in the case of the toothpick structure of A139250.
%C For more information see A139250 and A187210.
%C It appears this is also the connection between A147562 (the UlamWarburton cellular automaton) and the toothpick sequence A139250. The behavior of the function is similar to A147562 but here the structure is more complex. (see Plot 2 button: A147562 vs A187220).  _Omar E. Pol_, Mar 11 2011, Mar 13 2011
%C From _Omar E. Pol_, Mar 25 2011: (Start)
%C If we remove the first gull of the structure so we can see that there is a correspondence between the gullwing structure and the Itoothpick structure of A139250, for example: a pair of opposite gulls in horizontal position in the gullwing structure is equivalent to a vertical Itoothpick with length 4 in the Itoothpick structure, such that the midpoint of each horizontal gull coincides with the midpoint of each vertical toothpick of the Itoothpick. See A160164.
%C Also, Btoothpick sequence. We define a "Btoothpick" to consist of four arcs of length Pi/2 forming a "bell" similar to the Gauss function. A Bellshaped toothpick or Btoothpick or simply "bell" is formed by four Qtoothpicks (see A187210). A Btoothpick has length 2*Pi. The sequence gives the number of Btoothpicks in the structure after n stages.
%C Also, if we remove the first bell of the structure, we can find a correspondence between this structure and the Itoothpick structure of A139250. In this case, for example, a pair of opposite bells in horizontal position is equivalent to a vertical Itoothpick with length 8 in the Itoothpick structure, such that the midpoint of each horizontal bell coincides with the midpoint of each vertical toothpick of the Itoothpick. See A160164.
%C Also, for this sequence there is a third structure formed by isosceles right triangles since gulls or bells can be replaced by these triangles.
%C Note that the size of the gulls, bells and triangles can be adjusted such that two or three of these structures can be overlaid.
%C (End)
%C Also, it appears that if we let k=floor(log_2(n)), then for n >= 1, a(2^k) = (4^(k+1) + 5)/3  2^(k+1). Otherwise, a(n)=(4^(k+1) + 5)/3 + 8*A153006(n12^k).  _Christopher Hohl_, Dec 19 2018
%H Iain Fox, <a href="/A187220/b187220.txt">Table of n, a(n) for n = 0..10000</a>
%H David Applegate, <a href="/A139250/a139250.anim.html">The movie version</a>
%H David Applegate, <a href="/A187220/a187220.pdf">Illustration for a(16) = 311</a> [Created from the movie version, see previous link]
%H David Applegate, Omar E. Pol and N. J. A. Sloane, <a href="http://neilsloane.com/doc/tooth.pdf">The Toothpick Sequence and Other Sequences from Cellular Automata</a>, Congressus Numerantium, Vol. 206 (2010), 157191. [There is a typo in Theorem 6: (13) should read u(n) = 4.3^(wt(n1)1) for n >= 2.]
%H Brady Haran and N. J. A. Sloane, <a href="https://www.youtube.com/watch?v=_UtCli1SgjI">Terrific Toothpick Patterns</a>, Numberphile video (2018).
%H Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poltp050.jpg">Illustration of initial terms</a>
%H 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>
%F a(n) = 1 + 2*A139250(n1), for n >= 1.
%F a(n) = 1 + A160164(n1), for n >= 1.  [Suggested by _Omar E. Pol_, Mar 13 2011, proved by _Nathaniel Johnston_, Mar 22 2011]
%F The formula involving A160164 can be seen by identifying a Gullwing in the nth generation (n >= 2) with midpoint at (x,y) and endpoints at (x1,y+1) and (x+1,y+1) with a toothpick in the (n1)st generation with endpoints at (x,y1) and (x,y+1)  this toothpick from (x,y1) to (x,y+1) should be considered as having length ONE (i.e., it is HALF of an Itoothpick). The formula involving A139250 follows as a result of the relationship between A139250 and A160164.
%F a(n) = A147614(n1) + A160124(n1), n >= 2.  _Omar E. Pol_, Feb 15 2013
%F a(n) = 7 + 8*A153000(n3), n >= 3.  _Omar E. Pol_, Feb 16 2013
%e On the infinite square grid we start at stage 0 with no Gtoothpicks, so a(0) = 0.
%e At stage 1 we place a Gtoothpick:
%e Midpoint : (0,1)
%e Endpoints: (1,0) and (1,0)
%e So a(1) = 1. There are two exposed endpoints.
%e At stage 2 we place two Gtoothpicks:
%e Midpoint of the left Gtoothpick : (1,0)
%e Endpoints of the left Gtoothpick: (2,1) and (2,1)
%e Midpoint of the right Gtoothpick : (1,0)
%e Endpoints of the right Gtoothpick: (2,1) and (2,1)
%e So a(2) = 1+2 = 3. There are four exposed endpoints.
%e And so on...
%t Join[{0, 1}, Rest[CoefficientList[Series[(2 x / ((1  x) (1 + 2 x))) (1+2 x Product[1 + x^(2^k  1) + 2 x^(2^k), {k, 0, 20}]), {x, 0, 53}], x] + 1 ]] (* _Vincenzo Librandi_, Jul 02 2017 *)
%o (Python)
%o def msb(n):
%o t=0
%o while n>>t>0: t+=1
%o return 2**(t  1)
%o def a139250(n):
%o k=(2*msb(n)**2 + 1)/3
%o return 0 if n==0 else k if n==msb(n) else k + 2*a139250(n  msb(n)) + a139250(n  msb(n) + 1)  1
%o def a(n): return 0 if n==0 else 1 + 2*a139250(n  1)
%o print [a(n) for n in xrange(101)] # _Indranil Ghosh_, Jul 01 2017
%o (PARI) A139250(n) = my(msb(m) = 2^(#binary(m)1), k = (2*msb(n)^2 + 1) / 3); if(n==msb(n), k , k + 2*A139250(nmsb(n)) + A139250(n  msb(n) + 1)  1)
%o a(n) = if(n<2, n, 1 + 2*A139250(n1)) \\ _Iain Fox_, Dec 10 2018
%Y Cf. A002450, A139250, A147562, A160164, A187210, A187221, A187222.
%K nonn
%O 0,3
%A _Omar E. Pol_, Mar 07 2011, Mar 10 2011
