# Findminimum fails in loops

## Introduction to the problem: the function F[x][u,v,w]

I'm currently dealing with a very strange minimalization problem. I have a function

F[x][u,v,w]


which is defined by a series of integrals, solutions of sets of equations and so on (2 pages of formulas). Despite this fact, the values of F are calculated in only a few seconds.

Now given the values for {u,v,w}, I want to know what value of x minimizes the function F[x][u,v,w]. This minimum exists, it's also the only minimum and it's not an extremely steep minimum. A plot of the minimum is given in the figure below. It took me about 30 seconds to make this plot, just to give an idea of timing.

Other remarks about the function F[x][u,v,w] are:

• F[x][u,v,w] is an even function in x
• The domain of x is restricted to the positive (real) values

## The problem itself

In order to minimize the function F[x][u,v,w], given different values of {u,v,w}, I wrote a program that takes a list of {u,v,z} and minimizes it for all combinations of {u,v,w}. So first I define my list of u,v and w values that I want to run through:

ulist={*list of u input values*}
vlist={*list of v input values*}
wlist={*list of w input values*}


And then I write a small program that minimizes F[x][u,v,w] for all combinations of u,v,w. This program is given by:

minx[u_,v_,w_]:=
Block[{results={},u=ulist,v=vlist,w=wlist,x},
Do[
xmin=x/.(FindMinimum[F[x,u[[i]],v[[j]],w[[k]]],{x,RandomReal[{0.95,1.05}]}]//Part[#,2]&)
AppendTo[results,{u[[i]],v[[j]],w[[k]],xmin}],
{i,Length[u]},{j,Length[v]},{k,Length[w]}];
results
]


So basically the program runs trough the lists ulist, vlist and wlist and returns a matrix with on each row the supplied values of u,v and w together with the found minimum.

When I run the minimalisation without the loop it takes me less than 20 seconds and it yields the correct answer. The moment I put my minimalsation in the loop it takes me double the amount of time and yields $xmin\approx 0$ every time, which is (clearly from the plot) totally not the case.

My biggest question is thus what is going wrong? Is there something wrong with my definition of my variables, does this construct in general not work? I'm really puzzled. I have made som attempts in order to get the looping-construct going, but all failed.

## Futile attempts towards a solution

A summary of my tried attempts are:

• I tried using Table in stead of do to immediately construct the matrix
• I tried using Module in stead of Block, to not mix up variables
• I tried to write the minimalization af a seperate program outside of the loop
• I tried using With[] around the minimalization

but all of these attempts failed. I'm clueless here and I don't know what to do to get rid of my wrong results ?