1

I'm looking for a word to describe the relationship (or perhaps paradigm) wherein two functions go together and are meant to act as opposites to one-another, or to reverse each-other's behaviour - especially in programming.

For example:

  • Read and Write
  • Serialize and Deserialize
  • Encrypt and Decrypt
  • Perhaps more of a stretch: Constructor vs.Destructor or alloc vs. free

More specifically (or perhaps more generically), I am striving for words that capture a certain guarantee or expectation that any set of 'paired' functions, when given the same configuration (or complimentary configurations), can operate on one-another's output. In the above examples:

  • Write(data, format) => file such that Read(file, format) => data
  • Serialize(object, settings) => string such that Deserialize(string, settings) => object
  • Encrypt(string, privateKey) => data such that Decrypt(data, publicKey) => string

When using such functions there's an "expectation" that if e.g. a given library is used to write out a file to storage, such as:

hive.write.format('csv').header(true).partitionBy('date').save(path)

That the output of that function call can be read back in by its 'opposite', when provided the same configuration:

hive.read.format('csv').header(true).partitionBy('date').load(path)

If the above didn't work - that would be weird, and might be considered a bug in the function design or implementation. It would violate some pattern or common-sense expectation, I'm just not sure what one would call it.


There are other words in programming to describe guaranteed behaviours (such as "orthogonality" and "immutability") and relationships functions/operators have with one another or their outputs (such as "commutative" and "isomorphic"). I was hoping there would be a similar word for this.

In mathematics, I'm familiar with the concept of an "inverse function" which can consume the output of another function to restore its input (e.g. unary functions such as log and exp) such that F(x) = y, F'(y) = x, or perhaps more interestingly F'(F(x)) = x (e.g. they 'cancel one-another out'). It is quite close to the concept I'm thinking of.

Some words that come to mind are "pair", "symmetrical", "complimentary", or "opposite" functions, but I'm not seeing anything in academia using these words in this way.


I'd settle for a word or set of words that works in any of the following contexts:

  • The Biggify and Smallify functions are (adjective)
  • The Biggify function (verb or phrasal verb) the Smallify function.
  • Biggify is the (noun) (preposition) Smallify
1
  • 1
    You can't use the simplest, as you said, paired functions, or complementary? Aug 21 '20 at 19:27
4

Inverse Function/Operator/Procedure

Inverse function

Inverse operator

Inverse procedure

In mathematics, an inverse function (or anti-function[1]) is a function that "reverses" another function: if the function f applied to an input x gives a result of y, then applying its inverse function g to y gives the result x, and vice versa, i.e., f(x) = y if and only if g(y) = x.[2][3]

https://en.wikipedia.org/wiki/Inverse_function

I see no reason you couldn't extend this idea.

EDIT

As pointed out by @Pax, "operator" may be a better term than "function" in this case. I've also added "procedure"

2
  • I would suggest "inverse operation" rather than "inverse function". An inverse function is specifically a function that returns as value the original argument of the function which it is the inverse of. Complementary operations like open/close, insert/delete, alloc/free, do not manipulate their arguments in that way, but they may reasonably be described as inverse operations, inasmuch as they reverse each others' effects.
    – Pax
    Aug 22 '20 at 2:13
  • @Pax - Good point. I'll add that. Aug 22 '20 at 9:12
0

I'm going to proffer one of your thoughts:

complementary functions

1: serving to fill out or completetheir economies are more complementary than competitive … — William Petersen

2: mutually supplying each other's lack … the complementary relationship that binds the two. — Colin S. Gray

3: relating to or constituting one of a pair of contrasting colors that produce a neutral color when combined in suitable proportions

4: being complements of each other complementary acute angles

5: characterized by the capacity for precise pairing of purine and pyrimidine bases between strands of DNA and sometimes RNA such that the structure of one strand determines the other

(Source: M-W)

A brief search on scholar.google.com listed about 4 million hits for complementary functions, but most were in the domain of definition 5, differential equations being the exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.