# [Maxima] Symbolic pseudo-inverse

Stavros Macrakis macrakis at alum.mit.edu
Tue Aug 25 08:43:46 CDT 2009

Yes, indeed.

It appears that limit assumes that critical constants are non-zero:

limit(x/(x+a),x,0)
Is a positive or negative?

Actually, whether a is positive or negative doesn't matter.  What matters is
whether a is zero or nonzero, but the question shows limit assumes it is
nonzero (it isn't asking pnz, but just pn).

Using assume doesn't help (though at least it causes an error to be
signalled showing that the result is invalid):

assume(equal(zzz,0))\$
limit(x/(x+zzz),x,0);
Division by zero detected in `sign':
1/zzz
-- an error.  To debug this try debugmode(true);

All this of course makes the Moore-Penrose pseudoinverse wrong in many
cases:

moore_penrose_pseudoinverse(matrix([1,1],[a,b]));
=> matrix([b/(b-a),-1/(b-a)],[-a/(b-a),1/(b-a)])

... if a=b, the correct value is

matrix([1/(2*b^2+2),b/(2*b^2+2)],[1/(2*b^2+2),b/(2*b^2+2)])

Pretty serious limit bug, I'd say.

-s

On Mon, Aug 24, 2009 at 6:52 PM, Barton Willis <willisb at unk.edu> wrote:

> This bug is due to a limit bug:
>
>  (%i38) e : (2*sin(x)*z+cos(x)*sin(2*x)-2*cos(x)^2*sin(x))/(z^2+(-sin
>  (2*x)^2-4*sin(x)^2-cos(x)^2-1)*z+sin(2*x)^2-4*cos(x)*sin(x)*sin(2*x)+4*cos
>  (x)^2*sin(x)^2);
>
>  (%o38) (2*sin(x)*z+cos(x)*sin(2*x)-2*cos(x)^2*sin(x))/(z^2+(-sin
>  (2*x)^2-4*sin(x)^2-cos(x)^2-1)*z+sin(2*x)^2-4*cos(x)*sin(x)*sin(2*x)+4*cos
>  (x)^2*sin(x)^2)
>
> Bogus:
>
>  (%i39) limit(e,z,0);
>  (%o39) cos(x)/(sin(2*x)-2*cos(x)*sin(x))
>
>  (%i40) trigexpand(%);
>  Division by 0 -- an error.  To debug this try debugmode(true);
>
> Correct, I think:
>
>  (%i41) limit(trigexpand(e),z,0);
>  (%o41) -(2*sin(x))/((4*cos(x)^2+4)*sin(x)^2+cos(x)^2+1)
>
>  (%i42) trigexpand(%);
>  (%o42) -(2*sin(x))/((4*cos(x)^2+4)*sin(x)^2+cos(x)^2+1)
>
>
> Barton
>
> -----maxima-bounces at math.utexas.edu wrote: -----
>
>
> >This seems to work nicely except for one very big problem: it does not
> >check for expression zero equivalence except syntactically.  See below for
> >an example.
> >
> >              -s
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.math.utexas.edu/pipermail/maxima/attachments/20090825/c52f7a15/attachment-0001.htm