Writing a program to illustrate a fractal

Richard Damon Richard at Damon-Family.org
Sun Aug 26 15:34:53 EDT 2018


On 8/26/18 1:58 PM, Musatov wrote:
> On Sunday, August 26, 2018 at 12:49:16 PM UTC-5, Richard Damon wrote:
>> On 8/26/18 12:48 PM, Dennis Lee Bieber wrote:
>>>> The sequence is defined by:
>>>>
>>>> For 1 <= n <= 3, a(n) = n; thereafter, a(2n) = a(n) + a(n+1), a(2n-1) = a(n) + a(n-2).
<snip>
>>> I am not sure what 'fractal' property this sequence has that he
>>> wants to 
>> display.
> I'm sorry, let me try to explain:
>
> Here is my output:
> 1, 2, 3, 5, 4, 8, 7, 9, 7, 12, 13, 15, 11, 16, 17, 16, 14, 19, 21, 25, 20, 28, 27, 26, 24, 27, 31, 33, 28, 33, 32, 30, 31, 33, 35, 40, 35, 46, 44, 45, 41, 48, 53, 55, 47, 53, 54, 50, 51, 51, 53,
>
> It is an OEIS sequence. 
>
> I was told this image of the scatterplot emphasizes the 'fractal nature' of my sequence:
>
> https://oeis.org/A292575/a292575.png

Something is wrong with that image compared to the sequence, as the
sequence is always positive, and in fact the lowest the sequence can get
to is always increasing (as it starts always positive, and each term is
the sum of two previous terms),while the graph is going negative.

(actually going to the definition of the sequence, the plot isn't of
a(n) but a(n)-n, which can go negative)

I normally think for fractals as a sequence of patterns of increasing
complexity, or a pattern looked at with increasing resolution revealing
the growth pattern. This sequence isn't quite like that, but I suppose
if you think of the sequence a(n) in the interval m <= n <= 2*m, and
then the interval 2*m <= n <= 4*m, that second interval is somewhat like
the first with some recursively added pattern (especially if you include
the -n in the sequence).

That graph is probably the best way to show that pattern.

One thing that might help, is to clean up the definition of a(n) to be
more directly computable, and  maybe even include the subtraction of n.

A rewriting of your rules would be:

a(n)

n=1,2,3:    a(n) = n

n>3, and even: a(n) = a(n/2) + a(n/2+1)

n>3 and odd: a(n) = a((n+1)/2) + a(n-3)/2)

If I have done my math right, this is the same sequence definition, but
always defining what a(n) is equal to.

If we want to define the sequence b(n) = a(n) - n, we can transform the
above by substitution

b(n)

n=1,2,3: b(n) = 0

n>3 and even: b(n) = a(n/2)+a(n/2+1)-n

        = b(n/2)+b(n/2+1) + n/2 + n/2+1 -n

        = b(n/2) + b(n/2+1) + 1

n>3 and odd: b(n) = a((n+1)/2) + a((n-3)/2) - n

        = b((n+1)/2) + b((n-3)/2) + (n+1)/2 + (n-3)/2 -n

        = b((n+1)/2) + b((n-3)/2) -1

-- 
Richard Damon




More information about the Python-list mailing list