From: Murray Eisenberg on
This kind of issue has been addressed before. See, e.g., mg39711.

The method: change the definition so that it reads:

f[x_?NumericQ]:= ....

On 3/27/2010 6:10 AM, ValeX wrote:
> let's say that i have a numerical function f[x] which is defined in a
> quite messy way.
> For example, it could be defined as a Module that contains If, Whiles,
> interpolation functions, Import, ..
> This function works well without any error if I simply evaluate it,
> for example if i write f[5] and hit the enter key.
>
> The (my) problem is that often when i plug such a function in other
> routines, like FindMinimum, i get all sorts of errors and it doesn't
> work.
> Is there a way to tell Mathematica to just compute f[x] and then use
> that result for other things?
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305