Hi, Rupert. You write:
The way real and complex are used at the moment (I think)
is that
featurep (x, real) = true => x is real
featurep (x, complex) = true => x might not be real
Both false => x is real
Yes, I think that's correct.
As such, declaring x complex after declaring it real (or vice versa)
should clear the previous flag.
I'm not sure I agree here. Just as x<1 and x<2 are not "incompatible",
declare(x,real) and declare(x,complex) are not "incompatible" -- declaring
both should simply mean the *and* of the two conditions, which is
equivalent to declare(x,real) alone.
We probably need an "undeclare" function.... (I don't think there is one
now).
We probably should also clean up the context system, and integrate
declarations into it....
-s
On Wed, Feb 6, 2013 at 6:42 AM, Rupert Swarbrick <rswarbrick at gmail.com>wrote:
> I've just pushed partial fix for bug #2528. The problem there was that
> if you write:
>
> declare(rrcc,real)$ declare(rrcc,complex)$
>
> then Maxima "considers rrcc to be complex". In particular, things like
> imagpart(rrcc) failed to give zero. The root cause of this weirdness was
> that risplit (responsible for splitting an expression into real and
> imaginary parts) was treating the symbol "rrcc" as a complex number.
>
> The patch I pushed makes risplit check that rrcc isn't also declared as
> real - a bit hacky, but definitely an improvement. However, Stavros also
> wrote:
>
> > What is less clear is whether featurep(rrcc,complex) should be true
> > (which it curently is).
>
> In my opinion, the answer is that it probably shouldn't be true, but
> putting logic about real and complex numbers into the feature system is
> probably Doing It Wrong.
>
> My proposal is that we allow features to be declared to be
> incompatible. The way real and complex are used at the moment (I think)
> is that
>
> featurep (x, real) = true => x is real
> featurep (x, complex) = true => x might not be real
> Both false => x is real
>
> As such, declaring x complex after declaring it real (or vice versa)
> should clear the previous flag.
>
> Maybe the interface could be something like
>
> declare ([real, complex], incompatible);
>
> (to go with the "declare (foo, feature)" syntax).
>
> One advantage of this proposal is that it won't slow Maxima down when
> checking for features. Indeed, I can remove the extra property check
> that I just added in risplit! The only time when "extra thought" would
> be required is when making declarations, but that shouldn't be on any
> fast path...
>
> A disadvantage is that:
>
> (%i1) declare (rrcc, real)$
> (%i2) declare (rrcc, complex)$
> (%i3) featurep (rrcc, real);
> (%o3) true
>
> would change. I guess this alters the behaviour of the program (cue
> incompatibilities...), but I can't believe anyone relies on this rather
> odd behaviour in real life...
>
> Does anyone have any comments?
>
> Rupert
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>