Re: +-Inf and NaN
Richard Fateman <[email protected]> Thu, 22 Feb 2024 13:04:37 -0800
| Newsgroups | gmane.comp.mathematics.maxima.general,gmane.lisp.gcl.devel |
|---|---|
| Message-ID | <CADB8Zm7ZPCEQKCRiEf9L3zduwBYqhYXV0v+8n5seE7tpPyeZvw@mail.gmail.com> |
The answer for lisp is not the same as the answer for Maxima.
For example, in Maxima, the sum "command" works this way:
sum(i^2,i,1,10) returns 55. Same as lisp (loop for i from 1 to 10 sum
i)
but
sum(i^2,i,1,n) returns sum(i^2,i,1,n);
sum(i^2,i,1,n), simpsum returns (2*n^3+3*n^2+n)/6
while lisp would complain about undefined variable n...
Maxima tolerates symbolic stuff, and generally tries to defer reporting an
error.
For lisp, I would generally hope to push computations as far as possible
even if some inputs were NaN (etc.)
Some of this may be "free" in the sense that if you just follow the
arithmetic,
you are ok. Other examples, probably not.
Consider (cos NaN). Returning NaN is one option. How about returning
an interval [-1,1]?
{one way of implementing intervals may be to encode them ... e.g. NaN
payload is
a pointer to a hashtable entry. The entry is lower/upper bounds like
[-1,1].
}
RJF
On Thu, Feb 22, 2024 at 12:45 PM Camm Maguire <[email protected]>
wrote:
> Greetings! Several thoughts sent separately:
>
> Stavros Macrakis <[email protected]> writes:
>
> > > If NaN was truly 'not a number', the numerical functions would
> trigger
> > > an error on input only when compiled with safety, and might be
> arranged
> >
> > Don't agree. If you're doing a calculation with more than one result,
> > it is perfectly reasonable for some of the results to be NaNs and
> > other results to be valid. Aborting the calculation is not the right
> > thing to do.
> >
>
> Just curious, do you think a lisp function taking several numerical
> arguments and returning several numerical values should not trigger an
> error when passed a symbol as argument, presuming that some of the
> returned values might still be correctly computed?
>
> To my mind, type checking on arguments is done at the top of a
> function. If compiling without safety, the type checks can be dropped.
>
> Take care,
> --
> Camm Maguire [email protected]
> ==========================================================================
> "The earth is but one country, and mankind its citizens." -- Baha'u'llah
>
_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss