how about we use same method for invert(A) as for A^^-1 ?
- Subject: how about we use same method for invert(A) as for A^^-1 ?
- From: Barton Willis
- Date: Tue, 11 Dec 2012 19:50:12 +0000
--Barton
________________________________________
That's good, although invert_by_lu isn't entirely successful with
nonscalar elements. E.g.:
declare ([a, b, c, d], nonscalar);
matrix_element_mult : ".";
matrix_element_transpose : 'transpose;
A : matrix ([a, b], [c, d]);
A1 : invert_by_lu (A, noncommutingring);
=> matrix([a^^(-1) . (b . (d-c . a^^(-1) . b)^^(-1) . c . a^^(-1)+1),
-a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1)],
[-(d-c . a^^(-1) . b)^^(-1) . c . a^^(-1),
(d-c . a^^(-1) . b)^^(-1)])
Try this:
(%i12) (declare ([a, b, c, d], nonscalar),
matrix_element_mult : ".",
matrix_element_transpose : 'transpose,
A : matrix ([a,b],[c,d]))$
(%i13) invert_by_lu(A,'noncommutingring);
(%o13) matrix([a^^(-1) . (b . (d-c . a^^(-1) . b)^^(-1) . c . a^^(-1)+1),-a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1)],[-(d-c . a^^(-1) . b)^^(-1) . c . a^^(-1),(d-c . a^^(-1) . b)^^(-1)])
(%i14) ratsubst(zzz,(d-c . a^^(-1) . b),%);
(%o14) matrix([a^^(-1) . (b . zzz^^(-1) . c . a^^(-1)+1),-a^^(-1) . b . zzz^^(-1)],[-zzz^^(-1) . c . a^^(-1),zzz^^(-1)])
(%i15) expand(%.A);
(%o15) matrix([1,-a^^(-1) . b . zzz^^(-1) . d+a^^(-1) . b . zzz^^(-1) . c . a^^(-1) . b+a^^(-1) . b],[0,zzz^^(-1) . d-zzz^^(-1) . c . a^^(-1) . b])
(%i16) subst(d = zzz+ c.a^^-1 .b,%);
(%o16) matrix([1,-a^^(-1) . b . zzz^^(-1) . (zzz+c . a^^(-1) . b)+a^^(-1) . b . zzz^^(-1) . c . a^^(-1) . b+a^^(-1) . b],[0,zzz^^(-1) . (zzz+c . a^^(-1) . b)-zzz^^(-1) . c . a^^(-1) . b])
(%i17) expand(%);
(%o17) matrix([1,0],[0,1])
(%i18) invert_by_lu(A,'noncommutingring);
(%o18) matrix([a^^(-1) . (b . (d-c . a^^(-1) . b)^^(-1) . c . a^^(-1)+1),-a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1)],[-(d-c . a^^(-1) . b)^^(-1) . c . a^^(-1),(d-c . a^^(-1) . b)^^(-1)])
(%i19) ratsubst(zzz,(d-c . a^^(-1) . b),%);
(%o19) matrix([a^^(-1) . (b . zzz^^(-1) . c . a^^(-1)+1),-a^^(-1) . b . zzz^^(-1)],[-zzz^^(-1) . c . a^^(-1),zzz^^(-1)])
(%i20) expand(A.%);
(%o20) matrix([1,0],[-d . zzz^^(-1) . c . a^^(-1)+c . a^^(-1) . b . zzz^^(-1) . c . a^^(-1)+c . a^^(-1),d . zzz^^(-1)-c . a^^(-1) . b . zzz^^(-1)])
(%i21) subst(d = zzz+ c.a^^-1 .b,%);
(%o21) matrix([1,0],[-(zzz+c . a^^(-1) . b) . zzz^^(-1) . c . a^^(-1)+c . a^^(-1) . b . zzz^^(-1) . c . a^^(-1)+c . a^^(-1),(zzz+c . a^^(-1) . b) . zzz^^(-1)-c . a^^(-1) . b . zzz^^(-1)])
(%i22) expand(%);
(%o22) matrix([1,0],[0,1])