bessel.lisp error codes and noisy quad_qagi



On Sat, Nov 12, 2011 at 1:02 PM, Edwin Woollett <woollett at charter.net>wrote:

>
> I agree that a wider and deeper approach would be valuable.
>
> A possible approach to quiet mode error handling
>   with Maxima special functions is sketched out
>  below:
>
> We need:
>
> 1.  a global list,   spfun_errL,   by default empty
>
> 2.  a global flag,  spfun_quiet_mode,   by default false
>

[snip some details]

>
> When a Maxima special function (such as bessel-k) detects an error code
> such as is returned from zbesk.lisp, and if spfun_quiet_mode
> is true, then instead of printing an error message to
> the console, bessel-k conses the sublist [id-num,
> bessel-fun-order,bessel-fun-**arg,ierr]
> into spfun_errL and returns something appropriate
> (perhaps 0.0)  to quad_qagi.
>

I don't think this would work out very well.  I think this implies that
everything everywhere needs to know how to deal with your new lists.  If
they don't, then zbesk would silently return 0.0 to the caller and
everything would appear to be fine.  That would be a great source of
erroneous results being returned.

I haven't given this a lot of thought, but I was thinking of just signaling
an error.  We could have a small set of numerical errors that routines
could catch and do something with.  For the routines that don't know how to
deal with the error, the error would propagate to the top and you'd get a
maxima error.  In this way, the routines that care can do something
appropriate, and the routines that don't care or don't yet know will never
return an erroneous result because they don't handle the error.

This also means there's no need to ever print an error message.  The error
message (and routine name, etc.) could be part of the error object itself.
(This is from the Lisp side.  I'm not sure how that would work from the
maxima side.  Maybe we can provide a way for maxima to deal with these
error objects.)

Ray