**Econometrics by Simulation**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

There are four claims made in the video about the magic of nine.

1. Partition a circle as many times and its digits add up to nine

2. Add the sides of a regular polygon together and their digits sum to 9

3. Add all of the digits up to 9 and they sum to 9

4. Add 9 to any other digit and it returns that digit.

In this post I will address all of these patterns and demonstrate conclusively that 9 is not special but only a feature of using a base 10 system (that is we count to 9 before starting over again for example 9 10 11 or 19 20 21 etc).

This may seem like a silly issue to address. However, a lot of people have watched this video (6 million plus either on youtube or the original facebook post). In this post I will support my arguments by use of some custom R functions built for this task. You need not have R or run the functions to understand the results.

### 1: Magic 9 is embedded in the circle

At the beginning of the video, the author suggests that there is something special about 9 because when you divide the degrees of a circle in half all of the digits add up to 9. No only that but when you divide each of those halves each digit adds up to nine.

360 … 3+6+0=9

180 … 1+8+0=9

90 … 9+0=9

45 … 4+5=9

22.5 … 2+2+5=9

11.25…1+1+2+5=9

Up to double digits which you then add together. So the pattern continues.

5.625 … 5+6+2+5=18 … 1+8=9

At 150 splits (ignoring 0s and decimals) you get a series of numbers that look like this:

1261168617892335712057451360671424133527367330073300513283903262277297315100935657007585133880800115163136

And when you add them all together they equal: 396 … 3+9+6=18 … 1+8=9

So, as far as I am willing to explore, the pattern seems to hold.

First look at this, I said, “okay, but is this pattern just for 9s?”

After some exploration I came to the conclusion “yes” (at least with a base 10 system). There seems to be some other patterns but nothing as straightforward as the 9s.

In order to accomplish this efficiently I programmed a “splitter” algorithm in R. This will split any number in half, take the digits and add them together. See below:

library(magrittr)

library(gmp)

splitter <- function(X, it, nest, noisy=TRUE) {

Ys <- matrix(NA, nrow=it, ncol=nest)

options(digits=22,scipen=999)

esum <- function(x)

x %>% toString %>% sub(".", "", ., fixed = TRUE) %>% strsplit("") %>% unlist %>% as.numeric

for (i in 0:(it-1)) {

x <- as.bigz(X)

x <- x*10^(i)/2^i

Y <- x %>% esum

if (noisy) print(sprintf("%s: %s -> sum(%s)=%s",i, x ,paste(Y, collapse=" "), sum(Y)))

Ys[i+1, 1] <- sum(Y)

for (j in 2:nest) Ys[i+1, j] <- Ys[i+1, j-1] %>% esum %>% sum

}

Ys

}

# So let's first examine 9

splitter(X=9, it=150, 3)

# The first column is the sum of the digits

# The second column is the sum of the sum of the digits

# The third column is the sum of the sum of the sum of the digits

# Yes the first 4 halves produce a situation in which the digits all add up to 9

# If you combine the next 5 through 30 splits then the sum of the sum must be

# added together to also produce the designated 9.

# As we get deeper there is no reason to suspect that this will not carry to the

# next level.

splitter(8, 50, 3, noisy = FALSE)

splitter(7, 50, 3, noisy = FALSE)

splitter(6, 50, 3, noisy = FALSE)

splitter(5, 50, 3, noisy = FALSE)

splitter(4, 50, 3, noisy = FALSE)

splitter(3, 50, 3, noisy = FALSE)

splitter(2, 50, 3, noisy = FALSE)

splitter(1, 50, 3, noisy = FALSE)

# Looking at 1-8 we do not ever get the same number out as with 9.

# Does this make 9 unique, special, or even magical?

So, does this mean there is something to 9s? Well, maybe, but maybe it is a pattern that naturally emerges because we are using a base 10 system. What would happen if we switched to base 9? Or base 8?

In order to test this idea, I first programmed a function to switch numbers from base 10 to any other base.

base10to <- function(x, newbase=10, sep='') {

if (length(dim(x))==0) xout <- rep("", length(x))

if (length(dim(x))==2) xout <- matrix("", dim(x)[1], dim(x)[2])

for (j in 1:length(x)) {

x2 <- x[j]

digits <- ((1+x2) %>% as.bigz %>% log(newbase) %>% floor)

d <- rep(NA, digits+1)

for (i in 0:(digits)) {

d[i+1] <- (x2/newbase^(digits-i)) %>% as.numeric %>% floor

x2 <- x2-d[i+1]*newbase^(digits-i)

}

xout[j] <- paste(d, collapse=sep)

}

xout

}

x <- matrix(1:100, 10, 10)

base10to(x)

base10to(x, 5)

base10to(x, 9)

base10to(x, 2)

Seems to be working

Note, it does not work with decimals

Then I integrated it with my switcher:

# Now let’s redefine our splitter allowing for non-base 10

splitter2 <- function(X, it, nest, noisy=TRUE, base=10) {

Ys <- matrix(NA, nrow=it, ncol=nest)

esum <- function(x, base)

x %>% base10to(base) %>% strsplit("") %>% unlist %>% as.numeric

for (i in 0:(it-1)) {

x <- as.bigz(X)

x <- (x*10^(i)/2^i)

Y <- x %>% esum(base)

if (noisy)

print(sprintf("%s: %s -> sum(%s)=%s base %s",

i, x,

paste(Y, collapse=" "),

base10to(sum(Y), base),

base))

Ys[i+1, 1] <- sum(Y) %>% base10to(base)

for (j in 2:nest) Ys[i+1, j] <- Ys[i+1, j-1] %>% as.numeric %>% esum(10) %>%

sum %>% base10to(base)

}

Ys

}

splitter2(9, 15, 3, noisy = TRUE)

Output:

[,1] [,2]

[1,] "9" "9"

[2,] "9" "9"

[3,] "9" "9"

[4,] "9" "9"

[5,] "18" "9"

[6,] "18" "9"

[7,] "18" "9"

[8,] "18" "9"

[9,] "27" "9"

[10,] "36" "9"

[11,] "45" "9"

[12,] "36" "9"

[13,] "45" "9"

[14,] "45" "9"

[15,] "45" "9"

splitter2(8, 15, 2, noisy = TRUE, base=9)

Output:

[,1] [,2]

[1,] "8" "8"

[2,] "8" "8"

[3,] "8" "8"

[4,] "8" "8"

[5,] "26" "8"

[6,] "26" "8"

[7,] "17" "8"

[8,] "17" "8"

[9,] "35" "8"

[10,] "26" "8"

[11,] "26" "8"

[12,] "35" "8"

[13,] "35" "8"

[14,] "53" "8"

[15,] "35" "8"

splitter2(7, 15, 2, noisy = TRUE, base=8)

Output:

[,1] [,2]

[1,] "07" "07"

[2,] "07" "07"

[3,] "16" "07"

[4,] "16" "07"

[5,] "16" "07"

[6,] "25" "07"

[7,] "34" "07"

[8,] "25" "07"

[9,] "34" "07"

[10,] "34" "07"

[11,] "34" "07"

[12,] "43" "07"

[13,] "52" "07"

[14,] "52" "07"

[15,] "70" "07"

splitter2(6, 15, 2, noisy = TRUE, base=7)

[,1] [,2]

[1,] "6" "6"

[2,] "6" "6"

[3,] "6" "6"

[4,] "6" "6"

[5,] "24" "6"

[6,] "24" "6"

[7,] "24" "6"

[8,] "33" "6"

[9,] "33" "6"

[10,] "24" "6"

[11,] "33" "6"

[12,] "33" "6"

[13,] "51" "6"

[14,] "60" "6"

[15,] "51" "6"

splitter2(1, 15, 4, noisy = TRUE, base=2)

Output:

[,1] [,2] [,3] [,4]

[1,] "01" "01" "01" "01"

[2,] "10" "01" "01" "01"

[3,] "11" "10" "01" "01"

[4,] "110" "10" "01" "01"

[5,] "101" "10" "01" "01"

[6,] "110" "10" "01" "01"

[7,] "0111" "11" "10" "01"

[8,] "1000" "01" "01" "01"

[9,] "1100" "10" "01" "01"

[10,] "1101" "11" "10" "01"

[11,] "1011" "11" "10" "01"

[12,] "01111" "100" "01" "01"

[13,] "1101" "11" "10" "01"

[14,] "1110" "11" "10" "01"

[15,] "10001" "10" "01" "01"

Now we can see that by changing the base, the same pattern emerges. With base 9, the “magic” number is 8. With base 8, 7 etc. All the way down to base 2 where the “magic” number is 1.

### 2. Sides of the polygon

What about the other claims put forward in the video? That is, that all sides of all polygons angles add up to 9. That is for a regular polygon

triangle 60+60+60=180…1+8+0=9

square 90+90+90+90=360…3+6=9

pentagon 108+108+108+108+108=540…5+4=9

etc.

We can think of any equilateral polygon forming n identical triangles. The tips of those triangles meet at the center with angle 360/n where n is the number of sides of the polygon. To find the other angles we reflect on knowing that the two other angles are equal and since all of the sides of a triangle add up to 180 we can figure their size is (180-360/n)/2. Nowever, the triangles formed by the polygons only represent half the triangle’s edge so we need to double that giving:

$$theta(n)=180-(360/n) =180(1-2/n)$$ with n being the number of sides.

We can see that this could be written: 9*20(1-2/n):

So the question is, using an alternative base system will we get the same pattern?

Let’s try base 9 instead of 10. Let’s define the angles of the polygon as now: 8*20(1-2/n) base 10. Making a circle now 320 degrees base 10 or 385 base 9. Now let’s see about the sum of the sides.

triangle 53+53+53=160 base 10 or 187 base 9 … 1+8+7 = 16 base 10 or 17 base 9 … 1+7=8

square 80+80+80+80=320 base 10 or 385 base 9 … 3+8+5 = 16 … 8

pentagon 96+96+96+96+96=480 base 10 or 583 base 9 … 5+8+3 = 16 … 8

Hail the magical 8!

Do I need to do this again with a different base?

### 3. All of the digits less than 9 add up to 9 (1+2+3+4+5+6+7+8=36…3+6=9)

Base 10 magic 9:1+2+3+4+5+6+7+8=36 base 10 … 3+6=9 YES!

Base 9 magic 8: 1+2+3+4+5+6+7=28 base 10 or 31 base 9… 3+1=4 nope!

Base 8 magic 7: 1+2+3+4+5+6=21 base 10 or 25 base 8 … 2+5=7 YES!

Base 7 magic 6: 1+2+3+4+5=15 base 10 or 21 base 7 … 2+1=3 nope!

Base 6 magic 5: 1+2+3+4=10 base 10 or 14 base 6 … 1+4=5 YES!

etc.

I think the pattern is pretty obvious here as well.

### 4. Nine plus any digit returns that digit (9+7=16…1+6=7)

Base 10 magic 9: 9+5=14…1+4=5

Base 9 magic 8: 8+5=13 base 10 or 14 base 9…1+4=5

Base 8 magic 7: 7+5=12 base 10 or 14 base 8…1+4=5

Base 7 magic 6: 6+5=11 base 10 or 14 base 7…1+4=5

Base 6 magic 5: 5+5=10 base 10 or 14 base 6…1+4=5

etc.

Need I say more?

### 5. The Magical Marvelous Mystery of Base 10

Clearly, we can see that there is nothing special about 9. If there is any mystery, it is in the base 10 since as soon as we change the system from base 10 to base 9 the “magic” moves to another number.

We must ask ourselves therefore, “why we are using base 10?”

This is an excellent question! Other systems have developed such as the binary and corresponding hexidecimal system which are powerful systems that intuitively are more consistent than the tens system. With hexidecimals, everything can be written as a series of four binaries reducing all communication to 0 or 1 signals. If you think about it, this is a much more intuitive communication system than a 10 digit one.

As for why we are using the 10 digit system. My best guess is that we are using base 10 because most people have 10 fingers and it is therefore easier to teach someone to count on a 10 digit system.

So, yes, 9 is special but only because 10 is special and that is only special because our hands developed in such a way as that we have typically have 5 fingers on each hand summing to 10.

So YAY, MAGIC US!

**leave a comment**for the author, please follow the link and comment on their blog:

**Econometrics by Simulation**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.