Re: A general problem with numerical functions defined in a messy way
- To: mathgroup at smc.vnet.net
- Subject: [mg108708] Re: A general problem with numerical functions defined in a messy way
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 28 Mar 2010 04:08:42 -0500 (EST)
On 3/27/10 at 5:10 AM, rjovale at gmail.com (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? No, this simply cannot be done with an arbitrary f[x]. Mathematica does both numerical computations and symbolic computations. Some built-in functions will handle one but not the other. You simply cannot feed say NIntegrate a symbolic result and expect an answer. But this doesn't mean a specific problem cannot be dealt with. For example, FindMinimum has more than one way to search for the minimum. Rather than doing FindMinimum[f[x], x] I could do FindMinimum[f[x], {x, x1, x2}] Using this last method, FindMinimum avoids taking derivatives. That might just be the difference between finding the minimum of a "messy" f[x] or not.