Opened 10 years ago

Closed 9 years ago

abs(a+b)^2 == (a+b)^2

Reported by: Owned by: jan burcin major sage-5.11 symbolics maxima abs kcrisman, mjo sage-5.11.beta3 Karl-Dieter Crisman Michael Orlitzky N/A

Description

sage: version()
'Sage Version 4.7, Release Date: 2011-05-23'
sage: var('a b', domain='real');
sage: A = abs((a+i*b))^2
sage: A
abs(a + I*b)^2
sage: imag(A)
0
sage: A.simplify_full()
a^2 + 2*I*a*b - b^2
sage: imag(A.simplify_full())
2*a*b


The last result is clearly wrong. abs() is real by definition. simplify_full() doesn't handle abs() correctly.

Demo Notebook: http://demo.sagenb.org/home/pub/181/

comment:1 Changed 10 years ago by jan

• Component changed from sage-mode to symbolics
• Owner changed from ncalexan to burcin

comment:2 Changed 10 years ago by kcrisman

The exact place is

sage: A.simplify_radical()
a^2 + 2*I*a*b - b^2


This is how radcan in Maxima does this over the real domain, which simplify_radical temporarily makes us in.

I'm not sure what the best thing to do here is. Two ideas:

• Change so that we stay in domain:complex in Maxima, sort of missing the point of simplify_radical
• Give lots of warnings not to trust simplification because (like most simplification) it is not always true, but useful. (Sort of like how \sqrt{x^2}\neq x but sometimes it's useful to simplify it that way.)

I do not think we pass the domain information from the (Pynac) variables in any case, or if that would be very easy to do.

comment:3 Changed 9 years ago by kcrisman

This has been fixed by #12780.

sage: var('a b')
(a, b)
sage: A = abs((a+i*b))^2
abs(a + I*b)^2
sage: imag(A)
0
sage: imag(A.simplify_full())
0


Patch probably coming up. This would also be dealt with by #12737, but that is orthogonal to having fixed the domain issues.

comment:4 Changed 9 years ago by kcrisman

• Authors set to Karl-Dieter Crisman
• Status changed from new to needs_review

comment:5 Changed 9 years ago by mjo

Two minor things, can you use a,b = SR.var('a,b') to create the variables? That will eliminate one line of unrelated output. And just a style preference, since sage outputs the complex unit as I, I think it's a tiny bit more consistent to use that for input as well, but I'll take it either way.

Changed 9 years ago by kcrisman

Based on 5.10.rc1

comment:6 Changed 9 years ago by kcrisman

Two minor things

Sure, no problem. I put the i instead of I just because I copied from the original example in the ticket, but that is unimportant. Thanks!

comment:7 Changed 9 years ago by mjo

• Reviewers set to Michael Orlitzky
• Status changed from needs_review to positive_review

comment:8 Changed 9 years ago by jdemeyer

• Merged in set to sage-5.11.beta3
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.