Re: Limits & predicates with options.
- To: mathgroup at smc.vnet.net
- Subject: [mg7049] Re: [mg6999] Limits & predicates with options.
- From: seanross at worldnet.att.net
- Date: Sat, 3 May 1997 22:04:43 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Jack Goldberg wrote: > > Hi folks: > > I need some guidance in handling this call: > > Limit[f[x,a],x->0] > > because the function f[x,a] is constructed deep inside other code. > I want to take different actions depending on whether this limit exists. > However, I don't know how to distinguish these alternatives without > staring at the result. The problem seems to be that Limit can return a > far larger set of outputs than I initially (and somewhat naively) > thought. Besides the obvious, Limit can return this > > a*Inteval[-1,1] > > whose Head is Times. So "head" testing doesn't seem like a good idea. I > am stuck here. > > What I would like ideally is a Predicate, say, LimitQ[...] which > returns True if the limit exists and False otherwise. Of course, at > this level of generality, one might have to wait forever for an answer! > Which leads me to a second question. > > Can Predicates have options? In this case and obvious option would be a > time constraint: The output is False, if CPU time exceeds a preset > upper bound. > > Thanks all > > Jack Goldberg > Mathematics > University of Michigan By "this Limit Exists", you seem to mean that it can be represented as a real number for real values of the arguments. I suggest something like NumberQ[N[Evaluate[limitvariable=Limit[f[x,a],x->0]/.a->anyrealvalue]]]. This should test whether or not the Limit "exists" and store the unmodified result in the limitvariable symbol. The only hitch would be that anyrealvalue should not be near any suspected infinities. About timing issues: Check out the TimeConstrained function. You can modify the above line of code with it to provide a time limit and return a default value if the time limit is exceeded.