There is an error in the simplification of the abs function:
abs((%i+x)^2) ==> (x + %i)^2
Other examples work, e.g.
abs(%i^2) ==> 1
or
abs((%i+x)^2 + 1) ==> abs((%i+x)^2 + 1)
Maxima version: "5.28.0-2"
Maxima build date: "2012-08-27 23:16:48"
Host type: "i686-pc-mingw32"
Lisp implementation type: "GNU Common Lisp (GCL)"
Lisp implementation version: "GCL 2.6.8"
This worked in Version 5.19.02:
abs((%i+x)^2) ==> sqrt((x^2-1)^2 + 4 * x^2)
Robert Dodier
2013-03-24
For the record, declare(x, complex) doesn't change the result.
(%i2) declare (x, complex); (%o2) done (%i3) abs((x+%i)^2); (%o3) (x+%i)^2
Albrecht Mueller
2013-04-18
Maybe there are other problems related to this bug:
Bug #2549 function sqrt gives incorrect result
Discussion in wxMaxima: plot2d: expression evaluates to non-numeric value everywhere in plotting range
Albrecht Mueller
2013-04-19
If you try this with the Maxima Online Caluculator, you get:
(%i1) abs((x+%i)^2); 2 (%o1) x + 1
The online calculator reports the following build info:
(%i1) build_info();
Maxima version: 5.21.1
Maxima build date: 7:25 9/18/2010
Host type: x86_64-unknown-linux-gnu
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.7
Robert Dodier
2013-05-24
Robert Dodier
2013-05-24
Observed in current development version.
Maxima version: "branch_5_30_base_90_g122d48e_dirty"
Maxima build date: "2013-05-22 15:13:12"
Host type: "i686-pc-linux-gnu"
Lisp implementation type: "ECL"
Lisp implementation version: "12.12.1"
Paolo Bolognesi
2013-11-20
The same problem is observed also in a bit more generic case as shown in the attachment.
Basically, it seems that when evaluating abs(c)^2, or even when multiplying the latter by itself abs(c)abs(c), the core does not realize that c=a+ib is actually a complex quantity rather than a real one, so it cannot be simply squared as well.
The same even happens when either a or b are assigned a numerical real value; only when both of them are assigned real numerical values, the bug disappears.
The software version is:
wxMaxima version: 13.4.0
Maxima version: 5.31.2
Maxima build date: 2013-10-07 23:05:06
Host type: i686-pc-mingw32
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.8
Jaime E. Villate
2013-11-20
Why don't you use cabs instead of abs? abs is for real numbers
and cabs for complex numbers.
(%i2) cabs((%i+x)^2); 2 (%o2) x + 1
Albrecht Mueller
2013-11-21
The documentation of the abs function says: "If the argument, z, is a real or complex number, abs returns the absolute value of z. If possible, symbolic expressions using the absolute value function are also simplified." In the documentation of cabs I found: "cabs is a verb function and is not suitable for symbolic calculations."
It is not clear to me why there is a need for a cabs function if abs is working properly. If abs is restricted to real values then it should issue an error message when the argument is of wrong type instead of returning a wrong result.
Jaime E. Villate
2013-11-21
Yes I know, the situation with cabs vs. abs is very confusing; see for example this message in the list: http://www.math.utexas.edu/pipermail/maxima/2011/025213.html
Rupert Swarbrick
2013-11-21
That's a truly excellent write-up. Jaime: Do you think it would be work trying to distil it into improved documentation for abs and cabs?