# Digit Based Algebra And Its Application To Palindromes

Posted by Bedaywi, Mark on August 21, 2019

After playing with my calculator in math class for some time I noticed a peculiar pattern in palindromic numbers. It seemed that some times the product of two palindromic numbers is another palindromic number. Why does this happen? I had to find out, and to do so I realised that I had to find a way to represent individual digits algebriacly in a number. The notation I developed to explain this phenomenum helped make the journey to understand it much easier.

Let A = 5 and B = 6.
.A.B = 56.
With this notation in any base b
.A.B.C.D = b3A + b2B + b1C + b0D.
In addition, let .A,B,C = b0A + b-1B + b-2C.

```From this we can develop a simple set of rules for basic arithmetic.

.A.B + .C.D = b1A + b0B + b1C + b0D
= b1(A+C) + b0(B+D)
= .(A+C).(B+D)

Multiplication -
.A.B * .C.D = (b1A + b0B)(b1C + b0D)
= b2AC + b1CB + b1AD + b0BD

Division -
.A.B / .C.D = (b1A + b0B)/(b1C + b0D)
= (b1A / (b1C + b0D)) + (b0B / (b1C + b0D))
= (A / (C + b-1D)) + (b0B / (b1C + b0D))
= (A/(C,D)) + (B/(C.D))
= (A/(C,D)),(B/(C,D))

We also have to consider numbers in which one of the digits is greater than b, numbers we shall call astable, like in base 10
.12.3.11 = 100*12 + 10*3 + 1*11
= 1000*1 + 100*2 + 10*3 + 10*1 + 1*1
= .1.2.4.1
It essentially is a carry to any digit that is too big.
```

There is a lot you can do with Digit Based Algebra(DBA), but for this application only multiplication will be necessary. We will use it to find out why palindromes multiply to give other palindromes like 11*11=121 and others do not like 55*55 = 3025.

```Firstly lets investigate 2 digit palindromes:
Using the definition of multiplication from above,
.A.A * .B.B = .AB.2AB.AB
```

Aha! We have a have a reason for two digit palindromes, they will always multiply to give a 3 digit palindrome, however not all palndromes obtained this way are stable, and since AB+1 != AB there cannot be a carry. This means sometimes when the product of two two digit palindromes is found, the number will be astable, and as such not be a palindrome when made stable, this occurs when 2AB > b.

```Before we get to the general case for palindromes of equal size lets look at 3 digit palindromes:
.A.B.A * .C.D.C = (b2A + b1B + b0A)(b2C + b1D + b0C)
= b4AC + b3AD + b2AC + b3BC + b2BD + b1BC + b2AC + b1AD + b0AC
The same thing can be seen here, if 2AC+BD is less than b then the product is a palindrome.
```

Observant readers may be able to notice a pattern here, the fact that it seems as if for two palindromes to multiply to a another palindrome the sum of the products of the digits in the same place must be less than the base.

```Essentially for a palindrome
.A0.B0.C0.D0...
and
.A1.B.1.C1.D1...
to multiply to a palindrome
A0*A1 + B0B1 + C0C1 + D0D1 + ... < b must be true.
```

This is true because the middle number of the product of two palindromes of size n is always in position bn and therefore will be the first digit of the first number times the last digit of the second number plus the second digit of the first number times the second last digit of the second number etc. Since a palindrome can be mirrored the point above is proven.

This is why palindromes multiply to give other palindromes. All this means that in base 10 the largest palindrome which can be written as the product of two equal palindromes without a zero is 1111111112 or 12345678987654321. Naturally, larger bases means more palindromes like this can be created.

I will explore further applications of DBA for gaining intuition and solving problems in future articles.