it turns out that if my starting values are in an okay range, then I think my if statement inside the function sort of/almost works. ( i realy can't know for sure because I don't know what the optimal values should be ). the optimal value returned is is sometimes exactly on the boundary. for example, if I want my range for one parameter to be the open interval (0,2) , the function returns the optimal value as 2 which isn't really right. I can fix this by switching the if statement to 1.9 or 1.85 so I guess this is just a numerical thing. If someone knows if this "if method" is the best way to go, I would appreciate knowing this. Thanks a lot. Mark