Using a simple example with three equations in three unknowns,
{g1, g2, g3} = {x y - z^3 + x, x y z - 2, x^2 + y^2 + z^3 - 5};
subdomain = -1 < x < 1 && -3 < y < x - x^3 && y < z < x;
one can modify the functions in the equations so that the modified functions coincide with the original functions when the constraints are satisfied. One of many possible ways doing this is to use Boole (or some other Piecewise function) as follows:
neweqns = 1 - Boole[subdomain] + Boole[subdomain] {g1, g2, g3};
Without the domain restrictions,
FindRoot[{g1, g2, g3},
Transpose[{{x, y, z},{RandomReal[{-1, 1}], RandomReal[{-3, 2}], RandomReal[{-2, 0}]}}]]
possibly after several trials perturbing the initial points, gives one of the four roots:
(* {x->-0.5950097551413702`,y->2.6060720302882157`,z->-1.2897914523282767`} *)
subdomain /. %
(* False *)
The roots of neweqns are the roots of {g1, g2, g3} that also satisfy the constraints in subdomain. Again after possibly several trials with different initial points,
FindRoot[neweqns,
Transpose[{{x, y, z}, {RandomReal[{-1, 1}], RandomReal[{-3, 2}], RandomReal[{-2, 0}]}}]]
gives
(* {x -> 0.832027, y -> -2.32619, z -> -1.03335} *)
subdomain /. %
(* True *)
Update: If you have to use FindRoot, it is better to re-initialize automatically when a message is issued. For example:
init = {RandomReal[{-1, 1}], RandomReal[{-3, 2}],RandomReal[{-2, 0}]};
While[err == Quiet@Check[sol = FindRoot[neweqns, Transpose[{{x, y, z}, init}]], err],
init = {RandomReal[{-1, 1}], RandomReal[{-3, 2}], RandomReal[{-2, 0}]};];
sol
As always, there are alternative approaches like reformulating the problem as constrained optimization and using FindMinimum as suggested by PlatoManiac.
NSolve is another alternative that allows use of constraints directly:
NSolve[{g1, g2, g3} == {0, 0, 0}, {x, y, z}, Reals]
(* {{x -> 0.832027, y -> -2.32619, z -> -1.03335},
{x -> 1.98191, y -> -1.25951, z -> -0.801208},
{x -> -3.01335, y -> 0.409805, z -> -1.61958},
{x -> -0.59501, y -> 2.60607, z -> -1.28979}} *)
subdomain /. %
(* {True, False, False, False} *)
NSolve[subdomain && {g1, g2, g3} == {0, 0, 0}, {x, y, z}, Reals]
(* {{x -> 0.832027, y -> -2.32619, z -> -1.03335}} *)
FindRoot[]has no explicit support for restrictions like that, I'm afraid. What do your $g_k(w,x,y,z)$ and $f_k(x)$ look like? Maybe something could be tailored to your problem... – J. M.'s missing motivation Sep 06 '12 at 02:10