Bitcoin Forum
July 17, 2024, 07:23:38 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Solution to the Collatz conjecture (in case there is a prize in BTC)  (Read 17 times)
ElonMusk_ia (OP)
Newbie
*
Online Online

Activity: 8
Merit: 1


View Profile
Today at 02:41:06 PM
Last edit: Today at 07:12:39 PM by ElonMusk_ia
Merited by NotATether (1)
 #1


The Collatz conjecture, also known as the 3n+1 conjecture or Ulam's conjecture, was stated by mathematician Lothar Collatz in 1937.
Although it has puzzled the mathematical community for decades, it has yet to be solved. The conjecture states the following:

Starting with any positive integer:
If the number is even, divide by 2.
If the number is odd, multiply by 3 and add 1.
A sequence is formed by applying this operation repeatedly, taking the result of each step as input for the next.
The conjecture says that we will always reach the number 1, regardless of what number we start with.

Code:
import random



def collatz(n):
    
    while n != 1:
        print(n)

        if n % 2 == 0:
            n = n // 2
            
        else:
            n = 3*n + 1
    print(n)
    return n

collatz(random.randint(1,100000000))


A conjecture is a statement that is based on observations or evidence, but that has not yet been proven or disproven. In mathematics,
a conjecture is a problem that seeks a solution, and there is a prize of almost 1 million dollars for this.


The prize will be given to whoever offers a mathematical solution that certifies whether or not this is true for all numbers, and that said solution
is not refuted by the mathematical guild.




My solution to the problem:




To understand how it works we must modify the formula 3n+1


3n+1= 3n+i

where "i" must be an odd number.

and these two rules must be followed:

1- "i" must be an odd number.

The reason we apply this rule is to force 3n+i to give an even result, as we saw in the original conjecture.

2- n/i= Z

where Z refers to an integer: Z= {... -3,-2,-1, 0,+1,+2,+3 ...}


The reason we ignore this rule in the Collatz conjecture is because n/1=n


In both cases our final loop will be:

( i*4, i*2, i)

Now let's take a look at the new code corresponding to 3n+i and respecting the rule.




Code:
import random

i=7


def collatz(n):
    
    while n != i:
        print(n)

        if n % 2 == 0:
            n = n // 2
            
        else:
            n = 3*n + i
    print(n)
    return n

collatz(i*random.randint(1,100000000))
                
print("final loop= "+str(i*4)+","+str( i*2)+","+str( i))


Why does it always reduce to "i"?

Forcing 3n+i to give an even result, as we can see in the original conjecture, statistically increases the number of times we divide by 2, leaving an approximate of 40-60% more divisions compared to multiplication by 3.

as you can see in the following code.


Code:
import random

i= 7

def collatz(n):
    even_count = 0
    odd_count = 0

    while n != i:
        if n % 2 == 0:
            even_count += 1
            n = n // 2
        else:
            odd_count += 1
            n = 3 * n + i

    return n, even_count, odd_count

random_number = i*random.randint(1, 100000000)
result, even, odd = collatz(random_number)

print(f"The Collatz sequence for {random_number} ends at {result}.")
print(f"Even numbers encountered: {even}")
print(f"Odd numbers encountered: {odd}")

update:


How do we verify huge numbers?

Suppose we use as target=10

Code:
import random
i=1
target=10
def collatz(n):
    even_count = 0
    odd_count = 0

    while n != i:
        print(n)
        if n % 2 == 0:
            even_count += 1
            n = n // 2
        else:
            odd_count += 1
            n = 3 * n + i
    print(n)
    return n, even_count, odd_count

random_number =i*target# i*random.randint(1, 10000)
result, even, odd = collatz(random_number)

print(f"The Collatz sequence for {random_number} ends at i {result}.")
print(f"Even numbers encountered: {even}")
print(f"Odd numbers encountered: {odd}")


we get the three results with i= 1,3,5. odd order
We appreciate that they have the same order or sequence: even, odd, even, even, even, even, odd. (because we maintained the target)

Code:
using i=1                                  using i=3                                     using i=5
10                                         |30                                         |50
5                                          |15                                         |25
16                                         |48                                         |80
8                                          |24                                         |40
4                                          |12                                         |20                                         |
2                                          |6                                          |10
1                                          |3                                          |5
The Collatz sequence for 10 ends at i 1.    The Collatz sequence for 30 ends at i 3.   The Collatz sequence for 50 ends at i 5.
Even numbers encountered: 5                 Even numbers encountered: 5                 Even numbers encountered: 5
Odd numbers encountered: 1                  Odd numbers encountered: 1                  Odd numbers encountered: 1

So if we want to search for numbers 4 to 6 using the traditional method with i=1 we obtain that the sequences are within the table.
Code:
4
2
1
The Collatz sequence for 4 ends at i 1.
Even numbers encountered: 2
Odd numbers encountered: 0

5
16
8
4
2
1
The Collatz sequence for 5 ends at i 1.
Even numbers encountered: 4
Odd numbers encountered: 1

6
3
10
5
16
8
4
2
1
The Collatz sequence for 6 ends at i 1.
Even numbers encountered: 6
Odd numbers encountered: 2


In this way we know that if we use i= 22**70 -1 it is not necessary to go through the entire section from 1 to 22**70 -1 with the original conjecture to verify that the sequence exists.
Code:
import random
i=22**70 -1
target=10
def collatz(n):
    even_count = 0
    odd_count = 0

    while n != i:
        print(n)
        if n % 2 == 0:
            even_count += 1
            n = n // 2
        else:
            odd_count += 1
            n = 3 * n + i
    print(n)
    return n, even_count, odd_count

random_number =i*target# i*random.randint(1, 10000)
result, even, odd = collatz(random_number)

print(f"The Collatz sequence for {random_number} ends at i {result}.")
print(f"Even numbers encountered: {even}")
print(f"Odd numbers encountered: {odd}")

Code:
93236863968449335445326143653683496321795363944175445348633354543780733426420385752394487562230
46618431984224667722663071826841748160897681972087722674316677271890366713210192876197243781115
149178982349518936712521829845893594114872582310680712557813367270049173482272617203831180099568
74589491174759468356260914922946797057436291155340356278906683635024586741136308601915590049784
37294745587379734178130457461473398528718145577670178139453341817512293370568154300957795024892
18647372793689867089065228730736699264359072788835089069726670908756146685284077150478897512446
9323686396844933544532614365368349632179536394417544534863335454378073342642038575239448756223

The Collatz sequence for 93236863968449335445326143653683496321795363944175445348633354543780733426420385752394487562230 ends at
 i 9323686396844933544532614365368349632179536394417544534863335454378073342642038575239448756223.
Even numbers encountered: 5
Odd numbers encountered: 1


So we can conclude that the Collatz conjecture is true for all numbers.




Thanks for reading, if there is a reward in BTC (I'm not sure there is) I'll leave my wallet to whoever might be interested in my profile, I also uploaded a paper on the official page for mathematicians.
NotATether
Legendary
*
Offline Offline

Activity: 1666
Merit: 7045


In memory of o_e_l_e_o


View Profile WWW
Today at 05:01:21 PM
 #2

I can't give you prize money, but I can give you a merit.

ElonMusk_ia (OP)
Newbie
*
Online Online

Activity: 8
Merit: 1


View Profile
Today at 07:14:04 PM
 #3

I can't give you prize money, but I can give you a merit.

thanks, I've updated the post!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!