This is from sage-support
On Sep 1, 11:35 pm, Mani chandra <mchan...@iitk.ac.in> wrote:
>
--------
sage: x = a + I*b
sage: real(x.conjugate().simplify())
real_part(a) + imag_part(b)
sage: real(x.conjugate())
real_part(a) - imag_part(b)
---------
This seems to be happening because maxima(via simplify)
treats variables as real whereas pynac treats as complex.
----------
sage: x.conjugate()
conjugate(a) - I*conjugate(b)
sage: x.conjugate().simplify()
a - I*b
----------
William mentioned in this thread
http://groups.google.com/group/sage-support/browse_thread/thread/7bf451cf8202e085/10e81a803518f17c
that Sage does attempt to make default domain for maxima
to be complex. So something must be going horribly wrong.
Here is the trac ticket
http://trac.sagemath.org/sage_trac/ticket/6862
Cheers,
Golam
On Wed, Sep 2, 2009 at 12:13 PM, kcrisman<kcri...@gmail.com> wrote:
>> FWIW in order for conjugate & friends to recognize variables as
>> complex, probably it is necessary to declare them as such
>> (i.e. declare(foo, complex)). I think domain:complex won't have
>> the same effect. Maybe Sage is already calling declare.
>
> Very interesting. Continuing from the above code:
>
> sage: assume(a,'complex')
> sage: x.conjugate().simplify()
> -I*b + conjugate(a)
>
> Clearly we were not calling declare. Is there any way to do this for
> ANY globally defined variable, though? It seems overkill to put it in
> var(), and one wouldn't want it to conflict with (say) assume
> (n,'integer') or something.
In any case, current var() needs an upgrade. We now have three
tickets against it
(1) Custom typesetting:
http://trac.sagemath.org/sage_trac/ticket/6403
(2) Custom domain:
http://trac.sagemath.org/sage_trac/ticket/6559
(3) Syncing domain of variables with maxima:
http://trac.sagemath.org/sage_trac/ticket/6862
I did bit of work on the first two and unless someone else
fixes the third one, may be I will have a look at it.
Cheers,
Golam
> On Wed, Sep 2, 2009 at 12:13 PM, kcrisman<kcri...@gmail.com> wrote:
>> Very interesting. Continuing from the above code:
>>
>> sage: assume(a,'complex')
>> sage: x.conjugate().simplify()
>> -I*b + conjugate(a)
>>
>> Clearly we were not calling declare. Is there any way to do this for
>> ANY globally defined variable, though? It seems overkill to put it in
>> var(), and one wouldn't want it to conflict with (say) assume
>> (n,'integer') or something.
I played around little bit to fix this bug. Unfortunately, it doesn't seem
that we can avoid calling "declare()" in maxima for each (complex)
variable defined in sage.
The best thing we can do is to delay the declaration into maxima until
we actually need to call maxima to do some computation. This way
can avoid slowing down stuffs.
Maxima-interface experts: Is it possible to append such declaration
statements into maxima init string or similar?
Thanks,
Golam
This is definitely possible.
> Maxima-interface experts: Is it possible to append such declaration
> statements into maxima init string or similar?
That's definitely not the way to do it.
What we need is to queue up (put in some list somewhere) all
declaration that could ever be needed, then whenever we do a Sage -->
calculus Maxima conversion, we would empty the queue if it is
nonempty. Also, if Maxima were to crash/get restarted (does that ever
happen anymore), we would need to make sure all var's get set again.
This seems very do-able.
William