# Sierpinski Triangle and Benford's Law (Edit)

I would like some help solving the following problem using Mathematica: Show that, no matter what the initial area of an equilateral triangle is, the sequence of areas (painted in black) of the figures produced by the iterations that transform the original triangle into the Sierpinski triangle satisfies [Benford's Law][1]. [1]: https://mathworld.wolfram.com/BenfordsLaw.html

To demonstrate that the sequence of areas (painted black) of the figures produced by the iterations that transform the original equilateral triangle into the Sierpinski triangle satisfies Benford's Law, follow these steps:

Step 1: First, I defined a function that generates the Sierpinski triangle by iterations. I tried to use recursion for this purpose, but it didn't work:

sierpinski[triangle_] := Module[{midpoints},

midpoints = (#[[1]] + #[[2]])/2 & /@ Partition[triangle, 2, 1];


Join @@ (Flatten /@ {{triangle[[1]], midpoints[[1]],

midpoints[[3]]},
{midpoints[[1]], triangle[[2]], midpoints[[2]]},
{midpoints[[3]], midpoints[[2]], triangle[[3]]}})]


Step 2: Generating Sierpinski Triangles

I tried to generate a series of Sierpinski triangles by iteratively applying the sierpinski function. I started with an equilateral triangle and tried to generate several iterations. Again, I was not successful:

    initialTriangle = {{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}};
iterations = 7;sierpinskiTriangles = NestList[sierpinski, initialTriangle, iterations];


Step 3: Calculating and Displaying Areas

Calculate the areas of the Sierpinski triangles and then extract the first digit of each area:

    areas = Area /@ sierpinskiTriangles;
firstDigits = IntegerDigits[First@RealDigits[areas, 10, 1], 10];


Step 4: Analyze Compliance with Benford's Law

To verify if the sequence of first digits satisfies Benford's Law, I tried to create a histogram and compare it to the expected distribution:

    expectedDistribution = Table[Log10[1 + 1/n], {n, 1, 9}];

Histogram[firstDigits, {0.5, 9.5, 1}, "Probability",
Epilog -> {Red, PointSize[0.02],
Point /@ Transpose[{Range[1, 9], expectedDistribution}]}]

• First, it is not clear whether you are just looking for some hand-waving demonstration that the statement is true, or you are looking for a proper mathematical proof. Second, you have to do some coding and thinking yourself. Try searching this StackExchange for Sierpinski triangle, then edit the question and include the code that you have tried so far. Oct 2, 2023 at 15:29

As Benford's Law is an empirical law, there will be no analytic proof.

The only thing one can do is to try it out.

Assume we start with a triangle of area 1. Then the colored part of the next iteration is 3/4, and in the nth iteration 3/4^n. With this we calculate 100 steps and get the first non zero digits and calculate the relative frequencies:

n = 100;
SeedRandom[1];
d = Table[3/4^n, {n, 1, n}] // N;
d = Tally[RealDigits[d][[All, 1, 1]]] // N;
d[[All, 2]] = d[[All, 2]] / n;
Sort@d

{{1., 0.3}, {2., 0.18}, {3., 0.12}, {4., 0.09}, {5., 0.08}, {6.,
0.07}, {7., 0.06}, {8., 0.05}, {9., 0.05}}


We can compare this against The probabilities of Benford's law from Wikipedia:

probWiki = {30.1, 17.6, 12.5, 9.7, 7.9, 6.7, 5.8, 5.1, 4.6}


Starting with another area than 1 does not change much.

• I'd expect a number-theoretic approach could possibly arrive at the exact distribution of the first non-zero digits of the powers of $3/4$; then one could compare with a logarithmic distribution of digits $D$, called Benford's law: $\log\left(1+\frac{1}{D} \right)$. Oct 2, 2023 at 20:45

The Sierpinski triangle area decreases by 3/4 on each step:

(SierpinskiMesh[#] // Area) & /@ Range[5];
Ratios[%]
(*{0.75, 0.75, 0.75, 0.75}*)


So the area at the nth step (starting with n=0) is $$A_0 \left(\frac{3}{4}\right)^n ~~.$$

On the wiki:

Benford's law is sometimes stated in a stronger form, asserting that the fractional part of the logarithm of data is typically close to uniformly distributed between 0 and 1; from this, the main claim about the distribution of first digits can be derived

this might help understand this fact.

The fractional part of the log (base 10) of $$A_0 \left(\frac{3}{4}\right)^n$$ is $$\left(\log_{10}{A_0} + n \left(\log_{10}{3} - \log_{10}{4}\right) \right) \mod 1 ~~.$$

Since $$\frac{3}{4}$$ is not a rational power of 10, $$(\log_{10}{3} - \log_{10}{4})$$ is irrational, and Equidistribution theorem tells us that the fractional part of integer multiples of an irrational number is uniformly distributed on [0,1]. Shifting by $$\log_{10}A_0$$ does not change the uniform distribution.

Therefore, $$A_0 \left(\frac{3}{4}\right)^n$$

follows Benford's law for any initial area $$A_0$$

Edit Any positive, non-zero $$A_0$$