Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I've worked out similar mathematical statements and have grown to the opinion that it is impossible to encode this term into a functional. However, it was extremely helpful to read your exposition. So, thanks a bunch for taking the time to write all of this out!