Jump to content

Talk:Happy number: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
done
add Oleg's Matlab program, for the record
Line 39: Line 39:


Done. For what it's worth, it was never about strictness. The problem was simply that no justification for the claims at the top of this thread were given. [[User:Dbenbenn|dbenbenn]] | [[User talk:Dbenbenn|talk]] 23:54, 28 Jan 2005 (UTC)
Done. For what it's worth, it was never about strictness. The problem was simply that no justification for the claims at the top of this thread were given. [[User:Dbenbenn|dbenbenn]] | [[User talk:Dbenbenn|talk]] 23:54, 28 Jan 2005 (UTC)

== Checking up to 163 ==

The following program by [[User:Oleg Alexandrov]] can be used to check the claim in the article about 1 to 163:
<pre>
% Find the happy numbers, and the cycles which do not lead to happy numbers.
% Assume that we start at some integer between 1 and 163.
% It can be proved that the sequence t_0, t_1, ... as in the article,
% always stabilizes in this interval.

function main(m)

A=zeros(163, 20); % row i will store the cyclical sequence starting at i
for i=1:163
N=i; % current term
for j=1:20 % can prove that at most 18 iterations are necessary to start repeating the cycle
A(i, j)=N;
N=sum_digits(N);
end
if (N ~= 1 & N ~= 4 & N~= 16 & N ~= 37 & N ~= 58 & N ~= 89 & N ~= 145 & N ~= 42 & N ~= 20 & N ~= 4)
disp('We have a problem! We neither got a happy number nor are we');
disp('in the cycle 4 16 37 58 89 145 42 20 4 ');
end
end

A(1:163, 1:20) % display a table showing in each row the with all the cycles (please ignore the trailing zeros)

function sum=sum_digits(m)

sum=0;
p=floor(log(m)/log(10)+0.1)+1; % number of digits
for i=1:p
d=rem(m, 10);
sum=sum+d^2;
m=(m-d)/10;
end
</pre>

Revision as of 23:57, 28 January 2005

I removed the text:

It can be shown mathematically that no matter what the initial number t is, the sequence t0,t1,t2,.. will eventually settle between 1 and 163. What happens to this sequence after it is inside this interval can be estimated by a simple computation.
It turns out that the only alternative to ending up at 1 is to be stuck in the cycle
4, 16, 37, 58, 89, 145, 42, 20, 4, ...

as I couldn't find these claims in either reference, and I strongly doubt they've been proved. dbenbenn | talk 21:23, 28 Jan 2005 (UTC)

The second part is in the references. The first one I proved. I did not know on Wikpedia you must submit the proofs. What is a good way of proceeding about that? Assuming that the text fragment is accurate, and since it adds value to the article, maybe it should be left. What do you think? Oleg Alexandrov | talk 21:39, 28 Jan 2005 (UTC)
I should have given you more time to explain yourself. :) I got your message. I think, in the fragment above I said that it can be proved that things will settle between 1 to 163, and only from there on one can do some computerized checking. So, you want me to include the proof? It is not that hard.
Which reference do these facts appear in? Note that the second claim implies the first. I agree that if you can show any number eventually goes below 163, then it's simply a matter of checking those cases. dbenbenn | talk 21:48, 28 Jan 2005 (UTC)
OK, I made a mistake. In those references it was mentioned only that we either are in the cycle 4, 16, .... 4, or otherwise end up at 1.
You are right, it was not mentioned that you get stuck in 1 to 163, and what happens next.
So, I can prove that you get stuck in 1 to 163, and I had written a code to show what happens next, but that one was voted for deletion (which I think was appropriate).
So, we have 2 options. (a) Keep things the way they are now. (b) Put back the statement with the proof. What to do about the "fact" of what happens after you are between 1 to 163 I don't know. That can be checked only computationally.
Suggestions welcome. Oleg Alexandrov | talk 21:54, 28 Jan 2005 (UTC)
Are you referring to the MathWorld article? It says
"Unhappy numbers have eventually periodic sequences ... which do not reach 1 (e.g., 4, 16, 37, 58, 89, 145, 42, 20, 4, ...)."
E.g. means for example. The article does not say that unhappy numbers always end up in the 4, 16, ... cycle.
If you have a proof of this fact, I suggest that you should publish it. You're a postdoc, you need to publish papers! And once it's been peer reviewed, we can refer to it here no problem.
Additionally, I invite you to write your proof here on this talk page. I would be interested in seeing it. But I don't think it would be appropriate to include in the article until it's been peer reviewed. dbenbenn | talk 22:06, 28 Jan 2005 (UTC)
Got it! I did not know you guys are so strict about things, but that makes sense. So, let's drop it.
About the proof. The idea is quite simple. If you start with a large number, and sum the squares of its digits, then, as you might guess, what you get is much smaller than the original. If you do it several times, you keep on getting much smaller number each time, until you are between 1 and 1000. From there on, a bit more care is needed with calculations (but is still simple) to see how much further you can drop. For example, for 999 you end up after one step with 81+81+81 obviously, which is 243. From the range 1-243 the number with the largest sum of squares of digits is 199, for which you get 1+81+81=163. And from here on, a little program can check where you end up after several iterations.
This could make a nice math competition problem. But I agree with you, not worth the trouble puttin on Wikipedia. Oleg Alexandrov | talk 23:07, 28 Jan 2005 (UTC)

Er, um, let me back-pedal please. I hadn't actually thought about this sequence at all when I wrote the above. I had just assumed that things were difficult. Now having thought about it for a few minutes, I agree it's quite simple. Any number above 999 goes to a number with fewer digits, so you eventually get to something 999 or below. Then it's just a matter of checking. This level of reasoning can certainly go in the article. I'll start adding it right now. dbenbenn | talk 23:18, 28 Jan 2005 (UTC)

Done. For what it's worth, it was never about strictness. The problem was simply that no justification for the claims at the top of this thread were given. dbenbenn | talk 23:54, 28 Jan 2005 (UTC)

Checking up to 163

The following program by User:Oleg Alexandrov can be used to check the claim in the article about 1 to 163:

% Find the happy numbers, and the cycles which do not lead to happy numbers.
% Assume that we start at some integer between 1 and 163.
% It can be proved that the sequence t_0, t_1, ... as in the article,
% always stabilizes in this interval.

function main(m)

   A=zeros(163, 20); % row i will store the cyclical sequence starting at i
   
   for i=1:163
      N=i; % current term
      for j=1:20 % can prove that at most 18 iterations are necessary to start repeating the cycle
	 A(i, j)=N;
	 N=sum_digits(N);
      end
      
      if  (N ~= 1 & N ~= 4  & N~= 16  & N ~=  37 & N ~=    58 & N ~=    89 & N ~=   145   & N ~=  42   & N ~=  20   & N ~=   4)
	 disp('We have a problem! We neither got a happy number nor are we');
	 disp('in the cycle 4    16    37    58    89   145    42    20     4 ');
      end
   end

   
   A(1:163, 1:20) % display a table showing in each row the with all the cycles (please ignore the trailing zeros)

function sum=sum_digits(m)

   sum=0;
   p=floor(log(m)/log(10)+0.1)+1; % number of digits
   for i=1:p
      d=rem(m, 10);
      sum=sum+d^2;
      m=(m-d)/10;
   end