Thanks, that's what I was asking. I agree that the problem could
be impossible. But there are methods better than random search
or brute force to generate the candidates. That sistematic search
is what I want to know.
Best regards,
Linear equations can be solved directly
y = x - 1;
x = y + 1
Single term polynomial's can be solved directly
y = x**2 - 16
x = sqrt(y+16) or (y+16) to the power of 1/n for roots
Multiple term polynomial, for a given y, x cannot be solved directly.
One equation, one unknown (given y), but multiple terms.
y = x**2 + 2*x + 1
y = x(x + 2) + 1
x(x+2) = y-1
x = (y-1)/(x+2)
Here an itteration is required on each given y. If it converges
there is a single solution if y is not 0 where there are two.
And X will probably end up being a non-whole number.
---------------------------
y = some value (constant);
diff = 1;
cnt = 0
Xold = Xnew = 1;
while ( fabs (diff) > .01 && cnt < 20)
{
Xnew = x = (y-1)/(Xold+2);
++cnt;
dif = Xnew - Xold;
}
printf ("count = %d, diff = %d, Xnew = %d\n", cnt, diff, Xnew);
-----------------------------
So when an itteration is required, it could happen that an exact solution is
found quickly, within 7-20 itterations.
If you don't plan to do itterations, some things to think about when your
just guessing trying to solve it, which by the way, is totally illogical.
However it is likely that the solution will be a non-whole number so
@results = grep (f($_) == XXX, @candidates
^^
this would not be reasonable
You would want to get the results of f($_) and compare it to within +/- some percentage
of XXX in range. Or round to a whole number at least. You could flag multiple candidates
that are close to the solution. But, its still not the solution because its a blind,
directionless series of calculations that don't even constitute an itteration.
-sln