Search code examples
functionbitwise-operatorsterminology

What is the term for a function/operation that is reversible by using the same function again?


What do we call a function or operation that follows the same steps for transforming a value in either direction?

XOR is a simple example of this. Let's say my operation to prepare a byte for I/O is that I need to do "XOR 0x0F" for some reason. I can get back my original value by reapplying that same "XOR 0x0F".

By contrast, if I need to prepare the byte by rotating all bits left one position with wraparound, then rotating it all left again will not get me back my original value. But there is a symmetrically inverse operation available: rotate right one position. This is just a standard "encode"/"decode" pair of functions.

By contrast yet again, if my operation is to AND with 0x0F, then that operation is idempotent (i.e., I can apply it as many times as I want with the same result) but it is not reversible at all.

What is the formal or informal term for the first kind of operation, where the decode is done by just running it through the encode function again?


Solution

  • Self inverse is the informal name for such functions where f(f(x)) == x or if you prefer a more formal mathematical description involution as described on Wiki which includes more examples.

    ROT13 is another programming related one.