Subject: Adding new object types WAS: Operations on inf
From: Stavros Macrakis
Date: Thu, 8 Mar 2007 10:37:06 -0500
On 3/8/07, Barton Willis <willisb at unk.edu> wrote:
>
> I've always hoped for a straightforward way to add new objects to
> simplus and friends -- arrays, intervals, big oh, little oh, quad
> precision floats, ... By straightforward, I mean a way to add new
> objects without hacking simplus and friends.
>
For objects with number-like behavior, I believe the easiest way we can do
this is to piggyback on the existing bfloat code. By "number-like
behavior", I mean that operations f(n1,n2) where n1 and n2 are number-like
usually result in a single object n3 which is itself number-like, and that
there are few or no simplifications involving non-number-like objects.
Current number-like objects are integers, rats, floats, and bigfloats. When
you (say) multiply any object of one of these types with any other, you
always get a single object. I say "usually" because there are cases like (-
1.0b0)^(1/2) => 1.0b0 * %i, (-1)^3.4 => (-1)^3.4, and (-1)^3.4b0 =>
-9.5b-1%i -
3.1b-1.
Let's use ((bigfloat simp interval) ...), ((bigfloat simp quadfloat) ...)
etc. to represent new data types. We have the bigfloat package take care of
dispatching. There are some places in Maxima which break the bigfloat
abstraction (notably checking for sign or zero by looking inside), but we
should be able to remove those pretty easily.
This seems to me by far the simplest way of handling extensions like the
ones you're talking about. What is unavoidable, though, is going through
the code to remove incorrect assumptions, such as trichotomy (compare the
interval [2,5] with [3,4] or [1,3]) and realness (currently, all things that
Maxima considers to be "numbers" are real).
This technique could be applied to Gaussian integers, bfloat complexes,
float intervals, even distributions (with various rules of combination) etc.
etc.
Thoughts?
-s