2017-03-25, post № 164

**mathematics**, **PIL**, **programming**, **Python**, #alpha, #chaos, #chaos theory, #delta, #Feigenbaum, #fractal, #iterations, #Mandelbrot set, #modelling, #population

Generating the famous fractal, which can be used to model populations with various cycles, generate pseudo-random numbers and determine one of nature’s fundamental constants, the Feigenbaum constant 𝛿.

The fractal nature comes from iteratively applying a simple function, with , and looking at its poles.

The resulting image looks mundane at first, when looking at , though the last quarter section is where the interesting things are happening (hence the image below only shows the diagram for ).

From 𝜆 = 𝟥 on, the diagram bifurcates, always doubling its number of poles, until it enters the beautiful realm of chaos and fractals.

For more on bifurcation, fractals and 𝛿, I refer to this Wikipedia entry and WolframMathworld.

2017-03-14, post № 163

**mathematics**, **programming**, **Python**, #approximation, #dimensions, #four, #four dimensions, #generator, #higher dimensions, #hyperspheres

Every year on March the 14th, for one day the world gets irrationally excited about the famous constant 𝜋. As is tradition, you try to calculate 𝜋 in unusual ways, demonstrating the constant’s ubiquity as it crops up in the most unexpected circumstances.

lnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nJ$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$w
`v$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$z
u$$mnn: Y$$$i .@$$$$$,
$$n )$$$* W$$$$$m
-n[ $$$$. ]$$$$$$
h$$$w $$$$$$Y
[$$$$ X$$$$$$
"$$$$n '$$$$$${
.$$$$$ 8$$$$$$
*$$$$} :$$$$$$+
#$$$$u $$$$$$%
t$$$$$$ ;$$$$$$`
u$$$$$$! $$$$$$W
Y$$$$$$M .$$$$$$,
f$$$$$$$$. Z$$$$$Z nn
`w$$$$$$$$| $$$$$$( v$z
n$$$$$$$$$W $$$$$$$1 'X$8
Y$$$$$$$$$$ *$$$$$$$8nnnn$$$p
$$$$$$$$$@. W$$$$$$$$$$$$$n
_$$$$$$${ x$$$$$$$$$0>
-n{. !|nt_.

A fairly well-known way to approximate 𝜋 is to randomly choose points in a square (often thought of as throwing darts at a square piece of cardboard), determine their distance to a circle’s center and do a division, as I did in my 𝜋 Generator post.

However, 𝜋 does not only appear in the formula for a circle’s area, , yet also in the formula for a sphere’s volume, , and for all the infinite hyperspheres above dimension three (view this Wikipedia article for more about volumes of higher-dimensional spheres).

In particular, the formula for the hypervolume of a hypersphere in four dimensions is defined as being . Using this formula, my Python script randomly chooses four-dimensional points (each in the interval ), calculates their distance to the point and determines if they are in the hypersphere around that point with radius 𝟢.𝟧.

By dividing the number of random points which lie in the hypersphere by the number of iterations used ( in the example below), the script approximates the hypersphere’s hypervolume. By then rearranging the equation with 𝑟 = 𝟢.𝟧 to , the desired constant can be approximated.

$ python pi.py
3.14196371717

2017-03-11, post № 162

**mathematics**, **programming**, **Python**, #2016, #decimal reverse, #difference, #integer, #OEIS, #On-Line Encyclopedia of Integer Sequences, #palindrome, #reverse, #sequence, #square

The On-Line Encyclopedia of Integer Sequences (also known by its acronym, OEIS) is a database hosting hundreds of thousands of — as the name implies — integer sequences. Yet, despite the massive number of entries, I contributed a new integer sequence, A278328.

A278328 describes numbers whose absolute difference to their decimal reverse are square. An example would be 𝟣𝟤 or 𝟤𝟣 (both are the decimal reverse to each other), since and .

Not a whole lot is known about the sequence, partly due to its definition only resulting in the sequence when using the decimal system, though it is known that there are infinitely many numbers with said property. Since there are infinitely many palindromes (numbers whose reverse is the number itself), and .

Due to there — to my knowledge — not being a direct formula for those numbers, I wrote a Python script to generate them. On the sequence’s page, I posted a program which endlessly spews them out, though I later wrote a Python two-liner, which only calculates those members of the sequence in the range from 𝟢 to 𝟫𝟪 (shown below entered in a Python shell).

>>> import math
>>> filter(lambda n:math.sqrt(abs(n-int(str(n)[::-1])))%1 == 0, range(99))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 21, 22, 23, 26, 32, 33, 34, 37, 40, 43, 44, 45, 48, 51, 54, 55, 56, 59, 62, 65, 66, 67, 73, 76, 77, 78, 84, 87, 88, 89, 90, 95, 98]

Posts:

242-240, 239-237, 236-234, 233-231, 230-228, 227-225, 224-222, 221-219, 218-216, 215-213, 212-210, 209-207, 206-204, 203-201, 200-198, 197-195, 194-192, 191-189, 188-186, 185-183, 182-180, 179-177, 176-174, 173-171, 170-168, 167-165, **164-162**, 161-159, 158-156, 155-153, 152-150, 149-147, 146-144, 143-141, 140-138, 137-135, 134-132, 131-129, 128-126, 125-123, 122-120, 119-117, 116-114, 113-111, 110-108, 107-105, 104-102, 101-99, 98-96, 95-93, 92-90, 89-87, 86-84, 83-81, 80-78, 77-75, 74-72, 71-69, 68-66, 65-63, 62-60, 59-57, 56-54, 53-51, 50-48, 47-45, 44-42, 41-39, 38-36, 35-33, 32-30, 29-27, 26-24, 23-21, 20-18, 17-15, 14-12, 11-9, 8-6, 5-3, 2-1Jonathan Frech's blog; built 2021/04/16 20:21:20 CEST