Algorithm to determine function which maps integers to values that are in the images of two functions

15 Views Asked by At

I'm trying to find an algorithm that given a pair of functions with images that intersect, will map the integers to the elements of that intersection. Is this possible, and if so, how should i approach it?

Let me state the problem a little more exact: given two functions $f$ and $g$, which each map the integers onto an arbitrary set (they both have their own set), is there an algorithm which produces a function $h$ (assuming it exists), such that for all integers $x$, an integer $y$ exists, that satisfies $f(h(x)) = g(y)$? Note the image of $f(h(x))$ should be the intersection of $f$ and $g$, i am not entirely sure how to phrase that though.

An example of the kind of results that are needed follows. We define $f$ as $f(x) = 2x$, and $g$ as $g(x) = 10 - |x|$, so $f$ gives us even numbers, and $g$ gives us numbers smaller than or equal to $10$. Now we can define $h$ as $h(x) = 5 - |x|$, and it will be true that for all $x$, there exists a $y$, such that $f(h(x)) = g(y)$. Here it will also be the case that $x = y$, but that's not a requirement.