programming question



Robert Dodier wrote:
> On 4/11/10, Sheldon Newhouse <newhouse at math.msu.edu> wrote:
>
>   
>>  Suppose I have a real function f(x) of a a real variable x and a list,
>> say list_a of 1000 real numbers.
>> I know that on some numbers , x_0, in 'list_a' the evaluation f(x_0)
>> produces numerical overflow, but on others it does not.
>>  I would like to produce a sublist, list_b, of list of the numbers, y,
>> on which f(y) is less than 10^6.
>>
>>  I want to know how to find list_b.
>>
>> When I try to test each value in list_a, my program stops as soon as an
>> overflow is reached.  How do I tell maxima to record that an error was
>> produced and keep on going?
>>     
>
> Enclose the function evaluation within errcatch, which returns
> [foo] where foo is the result of a successful evaluation or []
> (empty list) when there is an error, but without stopping for
> the error.
>
> You could also evaluate the function as a bigfloat which won't
> overflow. Then you could compare the results to some limit.
>
> Be advised that Lisp implementations handle
> floating point overflow in various ways. Some (SBCL, CMUCL,
> maybe others) can handle non-numeric floating point values
> (i.e. positive and negative infinity, not-a-number) by setting
> a flag. That is a nonstandard extension: the CL spec appears
> to rule out the existence of non-numeric floats.
>
> Some other Lisps (Clisp, Allegro, maybe others) follow the
> spec to the letter and do not recognize non-numeric floats.
> Operations which would create such a float always trigger
> an error.
>
> Finally there is also GCL which handles non-numeric floats
> inconsistently; such floats can be created but not displayed.
> I guess that's a bug.
>
> Which Lisp implementation are you using?
>
> best
>
> Robert Dodier
> .
>
>   
Thanks for the info.  I am using cmucl at present because it was among
the fastest in execution, but I am not wedded to any particular lisp.  I
am tempted to try allegro, but I am a bit worried about proprietary
stuff.  Not for my own work, but for implementation for others is they
eventually try to use the code.

I'll play with your suggestions (and Jaime's) to see what happens.

Thanks,
-sen