Opened 12 years ago

Last modified 5 months ago

#6862 new defect

Mixing of different domains for symbolic variables

Reported by: gmhossain Owned by:
Priority: major Milestone:
Component: symbolics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


From suge-support

On Sep 1, 11:35 pm, Mani chandra <mchan...@…> wrote:

Mani chandra 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

Change History (6)

comment:1 Changed 12 years ago by kcrisman


Also, based on the hint there from Robert Dodier, here is the eventual way a fix will have to occur, perhaps as outlined in the thread:

sage: assume(a,'complex')
sage: x.conjugate().simplify()
-I*b + conjugate(a)

comment:2 Changed 8 years ago by kcrisman

  • Report Upstream set to N/A

See also this closely related question, where the following example occurs.

sage: var('a')
sage: b=a*a.conjugate()-a*a
sage: b
-a^2 + a*conjugate(a)
sage: simplify(b)

I think this is a little weird, though, since in Maxima

(%i1) domain:complex;
(%o1)                               complex
(%i2) -a^2+a*conjugate(a);
(%o2)                                  0

and sadly, the Maxima manual says that all this is expected to do is

Option variable: domain
Default value: real

When domain is set to complex, sqrt (x^2) will remain sqrt (x^2) instead of returning abs(x).

William says in the thread above that

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.

and perhaps that could be part of the initialization process of any variable - without actually calling Maxima at that time, of course!

Last edited 8 years ago by kcrisman (previous) (diff)

comment:3 Changed 8 years ago by kcrisman

#14628 is somewhat related, though this would not fix it, as far as I can tell.

comment:4 Changed 8 years ago by kcrisman

Let's make sure to also test #11656, which was a dup, when (?!) we fix this:

var('c', domain='complex')
var('x', domain='real')
C = c * exp(-x^2)
print (C)

print (C.imag())

print (C.imag().simplify_full()) 

comment:5 Changed 8 years ago by zimmerma

see also #14305


comment:6 Changed 5 months ago by kcrisman

  • Priority changed from critical to major
Note: See TracTickets for help on using tickets.