Thursday, July 26, 2012


"There are more real numbers between 0 and 1 than all the integers"

Ever since I came across the statement that the set of real numbers between 0 and 1 (eg: 0, 0.1, 0.2) is larger than the set of integers (0, 1, 2), I was curious to understand why it is so.

To understand this, I was reading about "Cantor's Diagonal Argument" here and here.

In very simple terms, these articles provide the below explanation.

Every integer is tried to be mapped to every real number with one-to-one correspondence.
   1 --> 0.1
   2 --> 0.2
   3 --> 0.3
   and so on... till infinity.

The above gives an impression that we should always be able to easily map an integer to a real number as the left-side (real numbers) is simply right-side multiplied by 10. In other words, multiply real number by 10 and you should get the integer number which it maps to. For 0.11, multiply by 100 and so on. You get one-to-one correspondence. Then how can there be more real numbers between 0 and 1 as described in the first statement?!

This one-to-one correspondence is only true for:
1. real numbers which are not having repeating decimal (eg. 0.1111..., 0.123123123...) or
2. if they are not irrational numbers (eg. pi=3.1415..., e, square root of 2, 0.1234...)
And why is that? It is because of the definition of "Integer", which states that it has to be a complete number. It cannot be incomplete and hence, has to be well-defined. But, real numbers do not have this limitation and they can have an infinite representation even in a single real number. Eg: Real number 0.333... has infinite 3s after the decimal point. (But, it can be also be easily represented as a fraction: 1/3). Similarly, we have pi, which is an irrational number (which cannot be represented by fraction of whole numbers).

So, with our earlier logic of multiplying an integer by 10, we will not be able to map an integer to the real number represented by 0.333... as there is no integer called 333... We have 333 and 3333 and 33333, and this can continue till infinity. But, all these numbers would always be complete in themselves as per the definition of "integer".

What this means is that, we cannot have an integer to represent irrational numbers, repeating decimals and real numbers which having a representation which in itself is infinite (eg: 0.1234...). This breaks the one-to-one correspondence and shows that there should be more real numbers between 0 and 1 than all the integers.

Also, the multiplication logic for mapping may not work to begin with as we will not know what power of 10 to use to multiply as a single real number's representation can be infinite (Eg: 0.123456789101112..., 0.111...).

There can be infinite such real numbers which cannot be mapped to integers. The integers would get exhausted before being mapped to these real numbers.

Hence, "There are more real numbers between 0 and 1 than all the integers".

The same can be extrapolated for:
"There are more real numbers between 0.1 and 0.2 than all the integers"
"There are more real numbers between 0.01 and 0.02 than all the integers"
"There are more real numbers between 0.001 and 0.002 than all the integers"
... and so on.

So, the infinity in integers isn't very big at all. In fact, it is stated that the smallest ordinal infinity is that of the (postive/negative) integers, and any set which has the cardinality of the integers is countably infinite. Read more about Infinity.

Additional points to ponder upon:

If pi (3.1415..) is irrational, then we can never have a circle which has both diameter and circumference) as a rational number. This is because: pi is defined as ratio of Circumference of a circle to its diameter.
If C is circumference of the circle and d is diameter. Then, pi = C/d.
Now, since pi is proved to be irrational, by definition, it cannot be represented as a fraction of integers. Hence, either C or d has to be irrational.


If, an = b  -->  a to the power n = b

Then, loga b = n  -->  log b to the base a = n
   Now, if a=1
then, 1n = 1, for all n
=> b=1

Hence, log1 1 = Any value of n. Hence, undefined.

Conclusion: Logarithm to the base 1 is undefined!

Wednesday, July 25, 2012

Windows recursive copy and cksum

Option 1  [Recommended – as it gives output in a consistent format of cksum, filesize, filename without path]
USING rcopy to copy all files into a single directory and then cksum
  1. Open notepad and copy-paste the below rcopy part into it.
  2. Save file as “rcopy_cmd.cmd”
  3. To copy all files to a single directory, execute the following command:  rcopy_cmd.cmd [SVN_LATEST_FILE_PATH_ON_LOCAL_MACHINE]
  4. Finally, run the command from “D:\TESTCOPY” directory: [CKSUM.EXE_PATH]\cksum.exe * > cksum_off.txt
  5. Zip the cksum_off.txt and email it.

         cksum.exe can be from
         Do not forget the dependencies (libintl3.dll, libiconv2.dll) available on same site.

      Standalone recursive copy command execution

@REM  Batch file to recursively get copy files to "D:\TESTCOPY" in Windows
@REM  Usage: rcopy_cmd.cmd [DIR]

@echo off

echo START: %date% %time%

@REM  Go to input DIR
pushd "%1"

@REM  For every file in current dir do (...) [/r = Recursively for every directory]
for /r %%f in (*) do (
  copy "%%f" "D:\TESTCOPY"

@REM  Get back to present working directory

echo END: %date% %time%

@echo on

cksum.exe "D:\TESTCOPY" > cksum_out.txt

Option 2

      Standalone recursive cksum command execution

@REM  Batch file to recursively get cksum in Windows
@REM  Usage: cksum_cmd.cmd [DIR] > cksum_out.txt

@echo off

echo START: %date% %time%

@REM  Go to input DIR
pushd "%1"

@REM  For every file in current dir do (...) [/r = Recursively for every directory]
for /r %%f in (*) do (
  D:\work\bin\cksum.exe "%%f"

@REM  Get back to present working directory

echo END: %date% %time%

@echo on


Process to copy all files stated in one list file to one directory.

@REM Create the directory to which the files are to be copied to
mkdir D:\TESTCPY2

@REM Assuming all files are present in one directory called “All_Files”
@REM Read one line at a time from the list file
for /F "tokens=*" %L in (list_of_files.txt) do (
  copy All_Files\%L D:\TESTCPY2

Note:  To use the above command in a batch file, change %L to %%L