Opened 11 years ago

# Mixing of different domains for symbolic variables

Reported by: gmhossain major symbolics N/A

### Description

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
```

### comment:1 Changed 11 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

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

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 7 years ago by kcrisman

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

### comment:4 Changed 7 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)
c*e^(-x^2)

print (C.imag())
e^(-x^2)*imag_part(c)

print (C.imag().simplify_full())
0
```