How can I create an inverse of a function with two inputs?

5 views (last 30 days)
I created a "distance" function, where I input two values and it finds the numerical distance between them. Is it possible to create a second function where I can input one of my original values and input a numerical value that used to serve as my output and get a new output of all the possible second "inputs" from my original function?

Answers (1)

Walter Roberson
Walter Roberson on 8 May 2015
Is there a finite limited alphabet? Is there a finite limit on how many characters to search through? Is the "distance" reported an integer or rational number?
If the answer to all three of those is Yes, then the answer is Yes: you simply iterate through all the possible words of up to the maximum length, and you calculate the distance of each to the target word, and compare the result to the given distance, retaining the ones that match.
If the answer to the first two is Yes but the third is No, that is if the "distance" is a floating point number, then in the general case, No, the general case says that there is the possibility of words whose distance calculates arbitrarily close to the given distance and might accidentally match, or that words which should match have their distance calculation slightly different than the given distance due to floating point round-off and so do not compare as equal.
If the answer to either of the first two is No, that either the alphabet is not finite or the maximum word length is not finite, then in the general case it would take an infinite amount of time to make the calculation.
The above discusses the general case. Given any particular distance algorithm, it may be possible to reason about its properties to determine the set of words that would match without having to try all the candidates. (Sometimes, though, the computation of which words to try gets so complicated that it is more efficient just to try them all!)
But you didn't ask about any particular distance algorithm, only about the theoretic possibilities for all (presumably finite) distances algorithms.
  6 Comments
bh
bh on 8 May 2015
yes, each word is inputted in lowercase English, and converted using ASCii.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!