Re: Testing for unevaluated functions

• To: mathgroup at yoda.physics.unc.edu
• Subject: Re: Testing for unevaluated functions
• From: David Withoff <withoff>
• Date: Tue, 29 Sep 1992 09:02:05 -0500

```> I would like to build a function that uses FindMinimum to search for a
> minimum (obviously).  The problem is that as one varies one of the parameters
> of the function, a definite min. will move outside of the range of the search.
>
> I would like to test for this condition, and if Find Minimum cannot find a
> minimum=, then use one of the endpoints.
>
> The question is, is there no general mechanism for testing the return status
> of a function, or at least a built-in function?
>
> Thanks in advance for any info/suggestions.
>
> jake

This isn't a direct answer to your question, but it
might be useful anyway:

In[17]:= f[s_] := Check[FindMinimum[(x-s)^2, {x, 0, -1, 1}],
{(Abs[s] - 1)^2, {x -> Sign[s]}},
FindMinimum::regex]

In[18]:= f[.5]

Out[18]= {0., {x -> 0.5}}

In[19]:= f[2]

FindMinimum::regex:
Reached the point {0.} + 1. {1.} which is outside the region {{-1., 1.}}.

Out[19]= {1, {x -> 1}}

In[20]:= f[-3]

FindMinimum::regex:
Reached the point 1. {-1.} + {0.} which is outside the region {{-1., 1.}}.

Out[20]= {4, {x -> -1}}

```

• Prev by Date: Functional Derivatives
• Next by Date: Boolean algebra?
• Previous by thread: Testing for unevaluated functions
• Next by thread: Functional Derivatives