Opened 10 years ago
Last modified 6 years ago
#6862 new defect
Mixing of different domains for symbolic variables
Reported by: | gmhossain | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
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
Change History (5)
comment:1 Changed 10 years ago by
comment:2 Changed 6 years ago by
- Report Upstream set to N/A
See also this closely related ask.sagemath.org question, where the following example occurs.
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!
comment:3 Changed 6 years ago by
#14628 is somewhat related, though this would not fix it, as far as I can tell.
comment:4 Changed 6 years ago by
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
comment:5 Changed 6 years ago by
see also #14305
Paul
See http://groups.google.com/group/sage-devel/browse_thread/thread/e25e03c9dba88a93
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: