Showing posts with label cubes. Show all posts
Showing posts with label cubes. Show all posts

Monday, February 18, 2019

Perspective, Silhouettes, and Taxi-Cab Geometry

In a drawing with one-point perspective, all lines perpendicular to the picture plane converge to a single point on the horizon called the vanishing point.  In this picture of some railroad tracks, for example, it would appear that the railroad tracks meet at some point far off in the distance, even though they are actually parallel.

one-point perspective of railroad tracks

Now imagine that you are looking down at some cubes on a level surface, and that you draw them using one-point perspective.  The top of each cube will not only appear larger than the bottom of each cube, but also be drawn further away from the vanishing point.

one-point perspective of some level cubes
  
Next, you create a silhouette of each cube by coloring inside each of the drawn outlines.  The resulting shapes are either irregular hexagons, pentagons, or quadrilaterals.

the silhouettes of some level cubes drawn with one-point perspective

Amazingly, the area of each silhouette can be determined by just four variables – the side length a of the top square of the drawn cube, the side length b of the bottom square of the drawn cube, the horizontal shift x of the cube from a cube directly over the vanishing point, and the vertical shift y of the cube from a cube directly over the vanishing point.

The center of the top square of a cube in the first quadrant would be drawn at (ax, ay) and its vertices at (a(x ± ½), a(y ± ½)).


Likewise, the center of the bottom square of a cube in the first quadrant would be drawn at (bx, by) and its vertices at (b(x ± ½), b(y ± ½)). 

Each silhouette is a hexagon (or a degenerate hexagon) that is the difference between the area of a rectangle with sides c = a(x + ½) – b(x – ½) and d = a(y + ½) – b(y – ½) and the areas of the two opposite triangles, one with sides ca and db, and the other with sides cb and da. 


In other words, the area of the silhouette is A = cd – ½(ca)(db) – ½(cb)(da), and letting p = ½(a2b2) and q = ½(a2 + b2), this simplifies to A = p(x + y) + q.  A similar argument can be made for the other quadrants to give the general formula of A = pd + q, where d = |x| + |y|. 

Surprisingly, d = |x| + |y| is also the equation for distances in taxicab geometry, a seemingly unrelated mathematical topic.  In taxicab geometry, segments are limited to being either vertical or horizontal, just like roads in a city block.  Since a taxicab cannot drive through city blocks along a hypotenuse, the distance it must travel to get to an intersection that is 4 blocks east and 3 blocks north is at least |3| + |4| = 7 blocks (whereas a flying bird not limited to the roads can do it in (32 + 42) = 5). 

taxicab geometry paths from (0, 0) to (4, 3)

In general, the distance a taxicab must travel to get to an intersection that is x blocks east or west and y blocks north or south is at least d = |x| + |y|.

Therefore, there is a surprising connection between one-point perspective drawings and taxicab geometry.  The area of the silhouette of a cube drawn in one-point perspective is A = pd + q, where d = |x| + |y|, the same distance a taxicab must at least travel to get to an intersection that is x blocks east or west and y blocks north or south.  This means that the area of the silhouette is a linear function of its own taxicab distance.

Tuesday, March 7, 2017

Perfect Numbers

A perfect number is a number which is equal to the sum of all its divisors less than itself.  For example, 6 is a perfect number because all of its divisors less than itself are 1, 2, and 3; and 1 + 2 + 3 = 6.  The number 28 is another perfect number because all of its divisors less than itself are 1, 2, 4, 7, and 14; and 1 + 2 + 4 + 7 + 14 = 28.

Another way to define a perfect numbers is to state that is a number whose sum of all of its factors (including itself) is equal to twice its value.  For example, 6 is a perfect number because all of its factors are 1, 2, 3, and 6; and 1 + 2 + 3 + 6 = 12, which is twice its value.  The number 28 is another perfect number because all of its factors are 1, 2, 4, 7, 14, and 28; and 1 + 2 + 4 + 7 + 14 + 28 = 56, which is also twice its value.

A visual representation of the perfect number 6
(from Wikipedia)

A computer can be used to quickly find other perfect numbers.  The following program goes through every integer (less than a user-defined integer), finds its factors, adds them up, and displays the ones that are perfect along with its factors:

01
# Perfect Numbers
02
# Python 2.7.3
03
# To find all perfect numbers less than n, type "perfects(n)".  For example,
04
#   to find all perfect numbers less than 1000, type "perfects(1000)".
05

06
# prints a string with a hanging indentation
07
import textwrap
08
def hprint(string):
09
    print textwrap.fill(textwrap.dedent(
10
        string).strip(), initial_indent = "", subsequent_indent = "  ")
11

12
# returns a list of factors of n
13
def factor(n):
14
    arrFactors = []
15
    # go through all the numbers < or = the square root of n
16
    for i in range(1, int(n ** 0.5) + 1):
17
        # if the numbers divides into n, add it to the list
18
        if (n % i == 0):
19
            arrFactors.append(i)
20
            # it is different, add the other factor to the list, too
21
            if (i != n / i):
22
                arrFactors.append(n / i)
23
    # return the sorted list
24
    return sorted(arrFactors)
25

26
# returns the sum of all the factors of n
27
def o(n):
28
    intO = 0
29
    # get the factors of n
30
    arrFactors = factor(n)
31
    # go through all the factors and add them up
32
    for i in range(0, len(arrFactors)):
33
        intO += arrFactors[i]
34
    # return the sum
35
    return intO
36

37
# determines if n is a perfect number
38
def perfect(n):
39
    # if sigma of n (the sum of the factors) equals 2n, then it is a
40
    #  perfect number, so display it and its factors, and return True
41
    if (o(n) == 2 * n):
42
        hprint(str(n) + ": " + str(factor(n)))
43
        return True
44
    # if not, return False
45
    else:
46
        return False
47

48
# find all the perfect numbers less than n
49
def perfects(n):
50
    # go through all the numbers between 1 and n and test them for being
51
    #   a perfect number
52
    for i in range(1, n):
53
        perfect(i)

Typing in “perfects(10000)” results in all the perfect numbers less than 10,000, and there are only 4: 6, 28, 496, and 8128.

>> perfects(10000)
6: [1, 2, 3, 6]
28: [1, 2, 4, 7, 14, 28]
496: [1, 2, 4, 8, 16, 31, 62, 124, 248, 496]
8128: [1, 2, 4, 8, 16, 32, 64, 127, 254, 508, 1016, 2032, 4064, 8128]

Amazingly, the Ancient Greeks knew about all 4 of these perfect numbers in an age without computers.  In fact, around 300 B.C. Euclid proved that if 2p – 1 is prime, then 2p – 1(2p – 1) is a perfect number.  For example, 3 is a prime number for p = 2 (2p – 1 = 22 – 1 = 3), so 2p – 1(2p – 1) = 22 – 1(22 – 1) = 2(3) = 6 is a perfect number.  Also, 7 is a prime number for p = 3 (2p – 1 = 23 – 1 = 7), so 2p – 1(2p – 1) = 23 – 1(23 – 1) = 4(7) = 28 is a perfect number.  Euclid’s proof can be found here (Proof PNP01).

Euclid

Since many perfect numbers are in the form 2p – 1(2p – 1), the following functions can be added to improve the above computer program to test 2p – 1(2p – 1) as a perfect number for any given p value:

55
# determines if (2 ** (p - 1)) * (2 ** p - 1) is a perfect number
56
def pperfect(p):
57
    if perfect((2 ** (p - 1)) * (2 ** p - 1)) == False:
58
        return False
59

60
# find all the perfect numbers in the form of (2 ** (p - 1)) * (2 ** p - 1)
61
#   less than the given value of p
62
def pperfects(p):
63
    # go through all the numbers between 1 and p and test
64
    #   (2 ** (p - 1)) * (2 ** p - 1) for being a perfect number
65
    for i in range(1, p):
66
        pperfect(i)

Typing in “pperfects(25)” quickly gives 3 more perfect numbers 33,550,336 and 8,589,869,056 and 137,438,691,328:

>> pperfects(25)
6: [1, 2, 3, 6]
28: [1, 2, 4, 7, 14, 28]
496: [1, 2, 4, 8, 16, 31, 62, 124, 248, 496]
8128: [1, 2, 4, 8, 16, 32, 64, 127, 254, 508, 1016, 2032, 4064, 8128]
33550336: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096,
  8191, 16382, 32764, 65528, 131056, 262112, 524224, 1048448, 2096896,
  4193792, 8387584, 16775168, 33550336]
8589869056: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096,
  8192, 16384, 32768, 65536, 131071L, 262142L, 524284L, 1048568L,
  2097136L, 4194272L, 8388544L, 16777088L, 33554176L, 67108352L,
  134216704L, 268433408L, 536866816L, 1073733632L, 2147467264L,
  4294934528L, 8589869056L]
137438691328: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,
  4096, 8192, 16384, 32768, 65536, 131072, 262144, 524287L, 1048574L,
  2097148L, 4194296L, 8388592L, 16777184L, 33554368L, 67108736L,
  134217472L, 268434944L, 536869888L, 1073739776L, 2147479552L,
  4294959104L, 8589918208L, 17179836416L, 34359672832L, 68719345664L,
  137438691328L]

Unfortunately, testing p ≥ 29 results in a “MemoryError” on my current personal computer, but supercomputers can be used to find more perfect numbers.

Euclid’s proof showed that perfect numbers are directly related to prime numbers in the form of 2p – 1, and these prime numbers later became known as Mersenne primes, named after the French mathematician who studied them extensively in the 17th century.  Over the years since, there have been many clever tricks developed to find larger and larger Mersenne prime numbers with the help of computers (see here for more details), and currently the largest known Mersenne prime is 274,207,281 – 1, a number with 22,338,618 digits!  According to Euclid’s proof, since 274,207,281 – 1 is a prime number, 274,207,280(274,207,281 – 1) must be a perfect number, currently making it the largest known perfect number, a number with 44,677,235 digits!

Mersenne

Interesting Facts

Here are some more interesting facts about perfect numbers:
-          Euler proved that all even perfect numbers must be in the form of 2p – 1(2p – 1) (Proof PNP02).

Euler

-          There are no known odd perfect numbers.  Computers have verified that there are no odd perfect numbers below 101500.
-          It is not known if there is an infinite number of perfect numbers.  (It is also not known if there is an infinite number of Mersenne primes.  Proving one would prove the other.)
-          All even perfect numbers (in the form of 2p – 1(2p – 1)) can be represented in binary as p ones followed by p − 1 zeros (Proof PNP03):

perf
binary
6
110
28
11100
496
111110000
8128
11111111000000

-          All even perfect numbers (in the form of 2p – 1(2p – 1))are the sum of all the integers from  1 to 2p – 1 (also called 2p – 1 triangular numbers) (Proof PNP04):

perf
Sum
6
1 + 2 + 3
28
1 + 2 + 3 + 4 + 5 + 6 + 7
496
1 + 2 + 3 + … + 29 + 30 + 31
8128
1 + 2 + 3 + … + 125 + 126 + 127

-          All even perfect numbers except for 6 (in the form of 2p – 1(2p – 1)) are the sum of the first 2(p−1)/2 odd cubes (Proof PNP05):

perf
Sum
28
13 + 33
496
13 + 33 + 53 + 73
8128
13 + 33 + 53 + 73 + 93 + 113 + 133 + 153

-          All even perfect numbers except for 6 (in the form of 2p – 1(2p – 1)) are in the form of 1 + 9(T(2^p-2)/3), where T(2^p-2)/3 is the sum of all the integers from 1 to 2^p – 2 / 3 (also called 2^p – 2 / 3 triangular numbers) (Proof PNP06):

perf
sum
28
1 + 9(1 + 2)
496
1 + 9(1 + 2 + 3 + … + 8 + 9 + 10)
8128
1 + 9(1 + 2 + 3 + … + 40 + 41 + 42)

-          All even perfect numbers except 6 have a digital root of 1 (to find a digital root of a number, add the digits, then add the digits of the resulting number, then repeat the process until there is a single digit) (Proof PNP07):

perf
digit sum
28
2 + 8 = 10, 1 + 0 = 1
496
4 + 9 + 6 = 19, 1 + 9 = 10, 1 + 0 = 1
8128
8 + 1 + 2 + 8 = 19, 1 + 9 = 10, 1 + 0 = 1

-          The sum of reciprocals of all the divisors of every perfect number is equal to 2 (Proof PNP08)

perf
reciprocal sum
6
1/1 + 1/2 + 1/3 + 1/6 = 2
28
1/1 + 1/2 + 1/4 + 1/7 + 1/14 + 1/28 = 2
496
1/1 + 1/2 + 1/4 + … + 1/248 + 1/496 = 2
8128
1/1 + 1/2 + 1/4 + … + 1/4064 + 1/8128 = 2
                                                                                                                                            
-          Any number raised to a perfect number exponent is equal to the product of all its perfect roots.  For example, 6 is a perfect number, 26 = 64, the perfect roots of 64 are 6√64 = 2, 3√64 = 4, and √64 = 8, and the product of 2, 4, and 8 is 2 ∙ 4 ∙ 8 = 64 (Proof PNP09).

perf
root product
6
6√x6 3√x6 2√x6 = x6
28
28√x2814√x287√x284√x282√x28 = x28
496
496√x496248√x496∙…∙4√x4962√x496 = x496
8128
8128x81284064x8128∙…∙4x81282x8128 = x8128

-          All even perfect numbers end in 6 or 8 (Proof PNP10).  All even perfect numbers with more than 1 digit end in 16, 28, 36, 56, 76, or 96 (Proof PNP11).

perf
last digit
last 2 digits
6
6
n/a
28
8
28
496
6
96
8128
8
28


Related Concepts

Like perfect numbers, there are many other types of numbers defined by the sum of their divisors:
-          In the book Cutting for Stone by Abraham Verghese, one of the characters explains about a set of numbers whose sum of divisors is a perfect square:
“’Sixty-six is my second-favorite number,’ Shiva said. ‘Pray, why is it your second favorite?’ said Bailey. ‘Because if you take the numbers you can divide into sixty-six, including sixty-six, and add them up, what you have is a square.’ Mr. Bailey couldn't resist. He wrote down 1, 2, 3, 6, 11, 22, 33, and 66 – all the numbers that went into 66 – and then he totaled. What he got was 144, at which point both he and Shiva said, ‘Twelve squared!’ ‘That's what makes sixty-six special,’ Shiva said. ‘It's also true of three, twenty-two, sixty-six, seventy – their divisors add up to a square.’”
Cutting for Stone

-          An abundant number is a number in which the sum of all its divisors less than itself is greater than the number itself.  For example, 12 is an abundant number because its divisors less than itself are 1, 2, 3, 4, and 6; and 1 + 2 + 3 + 4 + 6 = 16 which is greater than 12.
-          A deficient number is a number in which the sum of all its divisors less than itself is less than the number itself.  For example, 8 is a deficient number because its divisors less than itself are 1, 2, and 4; and 1 + 2 + 4 = 7 which is less than 8.
-          Amicable numbers are a pair of numbers in which the sum of all the divisors less than itself of the first number is equal to the second number, and the sum of all the divisors less than itself of the second number is equal to the first number.  For example, 220 and 284 are amicable numbers because all of the factors less than itself of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, and 110; and  1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110 = 284; and all the factors less than itself of 284 are 1, 2, 4, 71, and 142; and 1 + 2 + 4 + 71 + 142 = 220.  Other amicable numbers include 1184 and 1210, 2620 and 2924, 5020 and 5564, 6232 and 6368, and many more.

Conclusion

Perfect numbers have a simple definition but a wealth of related facts.  Yet despite the plethora of postulates concerning perfect numbers, there is still much to prove, including whether or not an odd perfect number exists, and whether or not there is an infinite number of perfect numbers.  Hopefully these mysteries will inspire mathematical works in the future.

Many of the facts about perfect numbers presented in this article were inspired by information found at Wolfram Mathematics and Wikipedia.