Showing posts with label Heinz. Show all posts
Showing posts with label Heinz. Show all posts

Thursday, 8 May 2025

Encoding Secret Numbers

The previous post about Heinz numbers got me thinking about how secret numbers that we might use as pass numbers for access to various services could be encoded. Let say we have a secret number 659347 that we want to encode using the one to one correspondence between Heinz numbers and integer sequences. Let's treat 659347 as a Heinz number, generate the corresponding integer sequence and then concatenate the numbers in the sequence:$$ \begin{align} \text{Heinz}(659347) &=(134, 19, 6) \\ &\rightarrow 134196 \end{align}$$If we concatenate the numbers in this sequence, there is ambiguity because the sequences (1341, 96) or (13419, 6) give the same result when the members are concatenated. It would thus be necessary to introduce a dot between the sequence members so as to resemble an IP address. An additional dummy 0 could be added so that it does indeed look like an IP address (0 cannot appear in any Heinz integer sequence). Thus we would have (permalink):$$ \begin{align} \text{Heinz}(659347) &= (134, 19, 6) \\ &\rightarrow 134.19.6  \text{ or} \\ &\rightarrow 134.19.6.0 \end{align}$$The point is that 134.19.6 or 134.19.6.0 can be written in plain sight and there's no way to decode the encrypted secret number (unless you know the magic word: Heinz).

An alternative method would be use the Gray Code. I've written about this in a post titled Gray Code in June of 2023. Here the secret number undergoes the following transformation:$$ \begin{align}659347 &= 10100000111110010011_2 \\ &\rightarrow 11110000100001011010_2 \\ &= 985178 \end{align} $$Again this number (985178) can be written in plain sight and there's no way to decode it without the magic phrase: Gray Code. Another encoding mechanism is Binary Complement. See my post Binary Complement from October of 2024. Here the encoding goes as follows:$$ \begin{align} 659347 &= 10100000111110010011_2\\ &\rightarrow 01011111000001101100_2\\ &=389228 \end{align} $$There is a problem once we try to decode from 389228. If we convert this number to binary then we don't have a leading zero anymore, we have 1011111000001101100. We need to add this leading zero because binary complements always have a leading zero. Once we do this, we can flip each 0 to 1 and each 1 to 0 to recover our secret number once we convert from binary. If one wanted to be really devious then two or even three encoding techniques could be used sequentially. 

Wednesday, 7 May 2025

The Heinz Number

I'm surprised that I've not had cause to mention the concept of Heinz numbers before. I've probably seen references to them but ignored them as not being all that interesting or relevant. Clearly, I misjudged them. Here is how Gemini described them:

The Heinz number of an integer partition is a way to map each integer partition to a unique positive integer. Given an integer partition \( (y_1, y_2, \dots ,y_k) \) where \(y_1 \geq y_2 \geq \dots \geq y_k \geq 1 \), the Heinz number is calculated as the product of the prime numbers corresponding to the parts of the partition. Specifically, if \(p_i\) denotes the \(i\)-th prime number where \(p_1=2, p_2=3, p_3=5 \) and so on, then the Heinz number of the partition is given by:$$\text{Heinz}(y_1, y_2, \dots ,y_k)=p_{y_1} \times p_{y_2} \times \dots \times p_{y_k}$$It's very simple to calculate the Heinz number. Let's take the partition (4, 2, 1, 1) of the integer 8 (permalink):$$ \begin{align} \text{Heinz}(4, 2, 1,1) &= 7 \times 3 \times 2 \times 2 \\ &=84  \end{align}$$Conversely it's easy to work back from a given number, regarding it as a Heinz number, and determine the corresponding integer sequence. For example, let's take the number 27792 (permalink):$$ \begin{align} 27792 &= 193 \times 3^2 \times 2^4 \\ &= \text{Heinz}(44,2,2,1,1,1,1) \end{align}$$because 193 is the 44th prime, 3 is the second prime and 2 is the first prime. So there is a one to one correspondence between every positive integer and a unique integer sequence. Prime numbers are associated with an integer partition that has only one member. For example:$$\text{Heinz}(27793)=3034$$because 27793 is the 3034th prime number. I'll include now some additional information that Gemini provided about these types of numbers.

Significance and Usefulness:

  1. Bijective Correspondence: The Heinz number establishes a one-to-one correspondence (a bijection) between the set of all integer partitions and the set of positive integers. This means every integer partition has a unique Heinz number, and every positive integer is the Heinz number of exactly one integer partition. This allows us to represent and study integer partitions through the lens of integers and their prime factorizations.

  2. Encoding Partitions: The Heinz number provides a compact way to encode an integer partition as a single integer. This can be useful in various contexts, such as storing or indexing partitions.

  3. Relating Additive and Multiplicative Structures: Integer partitions are inherently additive structures (the parts sum to the integer being partitioned). The Heinz number connects this additive structure to the multiplicative structure of integers (through the product of primes). This connection can sometimes reveal new properties or insights about partitions by leveraging our understanding of number theory.

  4. Ordering Partitions: The Heinz number can be used to define a specific ordering of integer partitions. Sorting partitions by their Heinz numbers yields a particular sequence.

  5. Connection to Other Mathematical Objects: The concept of the Heinz number has been extended and used in the study of related combinatorial objects. For example, it appears in the context of connected integer partitions and multisets.

I asked the following question of Gemini:

What do we know about the name (Heinz) that is used to identify these numbers? Does it refer to a mathematician who invented them?

Here was the response: 

It's a great question about the origin of the name "Heinz number" in the context of integer partitions!

Based on my current knowledge, the term "Heinz number" in relation to integer partitions does not refer to a specific mathematician named Heinz who invented or first studied this mapping.

The use of the name "Heinz" in this context appears to be a playful or informal assignment, likely stemming from the famous H.J. Heinz Company, known for its "57 Varieties" slogan.

Here's why this connection is plausible:

  • Uniqueness and Variety: Just as the Heinz company boasted a large number of unique food varieties, the Heinz number uniquely identifies each integer partition. This sense of a one-to-one correspondence or a unique label for a "variety" of partitions might have inspired the informal naming.  
  • Memorability: The name "Heinz" and the associated "57 Varieties" are widely recognizable, making "Heinz number" a somewhat catchy and memorable term, even if it's not a formal mathematical designation.

It's important to note that in formal mathematical literature, you are more likely to encounter this concept described as a bijection between integer partitions and positive integers based on the product of primes, without the specific name "Heinz number."

While there have been mathematicians named Heinz (for example, Heinz Prüfer who worked on abelian groups, and the Heinz mean is named after a different E. Heinz), there is no readily available information linking any of them to the specific construction of this prime-based mapping of integer partitions.

Therefore, the "Heinz number" for integer partitions is likely an informal, descriptive name that plays on the well-known "Heinz" brand and its association with variety and distinctness, rather than honoring a specific mathematical inventor.

It's a fascinating example of how informal language and cultural references can sometimes enter mathematical discussions, even if they don't become part of the formal nomenclature.