Coding 2025-10-13

Tags:
By Max Woerner Chase

Okay, let's see how today is going. I was kind of out of it for some reason.

After last night, I want to figure out whether it's feasible to automate some of the work in doing weird base-dependant stuff. So far, I've got a sketch of table generation, but I can't really use that unless I figure out how to automate base representation. This isn't too hard for natural bases, but the whole point of this project is to mess around with stuff that's un-natural.

Let's see. I want to work with real algebraic bases, real integer bases, complex integer bases, and balanced versions of both.

Complex bases can be an issue due to moderately strange carries, algebraic bases can be an issue due to really strange carries and the minimal/maximal distinction (which totally changes the behavior of digital roots, at least in base phi), and anything long-division-like runs into some snags both in balanced bases, and I think in any base below phi. Although I'm mildly curious how other Pisot number bases work, I think I have to dial my initial expectations down to designing and using a toolbox, rather than getting it all to work perfectly for arbitrary bases. That said...

If a base is a root of a polynomial, it seems to me that representing a specific number should involve a Laurent polynomial that is a product of the base polynomial, provided that, if the target number is added to both sides, all of the coefficients are from the set of allowed digits. Or something like that. I'm not sure whether bringing in theory like this will make the implementation any easier, so I may just need to consider formal manipulations.

The naive implementation would be to repeatedly add one to the representation, but as I think about it, I wonder whether constructing the base representation from binary, by multiplying by two and adding one as needed, would be workable. The basic thing missing there for algebraic bases is how to canonicalize the representation. The multiplication and adding would potentially produce arbitrary digits, in addition to disallowed digit sequences. Waiting until the end to canonicalize would simply defer all of the actual work to the canonicalization step, so let's suppose we canonicalize early and canonicalize often. The problem I have visualizing this is that algebraic bases don't seem to have an obvious direction to work in, since triggering a carry will change less significant digits as well as more. Another possibility would be...

So, until the target number differs from a product of the base by one of the allowed digits, multiply the target number by the base. Then, do long division from the least significant digit, like something with p-adics. Getting this to work requires something like a vector representation of arbitrary digit sequences in the chosen base, along with matrix representations of multiplication and division by the base. I haven't done the legwork, so I'm going to just kind of hope that all of the bases I'm interested in have a diagonalizable matrix, although I'm not actually sure how helpful that would be; it just seems probably helpful.

I don't have a sense for how this would go in code, so I'm going to have to experiment with it by hand for a bit. (Maybe it needs normal long division, if I can somehow tell that there's no more division to do.)

Anyway, I want to wrap up and wind down. Maybe later I'll have some more ideas for this.

Good night.