This method only works for square matrices :( For square matrices,
you can try linsolve_by_lu. Example:
(%i1) linsolve_by_lu(matrix([1,2],[3,4]), matrix([1],[2]));
(%o1) [matrix([0],[1/2]),false]
For rational numbers, the second argument is false; for floats the
second argument is an estimate of the condition number. Multiple
right-hand-sides are OK
(%i2) linsolve_by_lu(matrix([1,2],[3,4]), matrix([1,0],[0,1]));
(%o2) [matrix([-2,1],[3/2,-1/2]),false]
And a double-float example
(%i3) linsolve_by_lu(matrix([1,2],[3,4]),
matrix([1,0],[0,1]),'floatfield);
(%o3) [matrix([-2.0,1.0],[1.5,-0.5]),21.77777777777778]
And, for fun:
(%i1) f : lambda([i,j], random(10))$
(%i2) m2(m,n) := genmatrix(f,m,n)$
(%i3) m1 : matrix([m2(2,2),m2(2,2)],[m2(2,2), m2(2,2)]);
(%o3)
matrix([matrix([2,9],[8,0]),matrix([4,5],[7,3])],[matrix([3,9],[5,5]),matrix([2,5],[1,0])])
(%i4) b : identfor(m1);
(%o4)
matrix([matrix([1,0],[0,1]),matrix([0,0],[0,0])],[matrix([0,0],[0,0]),matrix([1,0],[0,1])])
(%i5) matrix_element_mult : "."$
(%i6) m1_inv : first(linsolve_by_lu(m1,b, 'noncommutingring));
(%o6) matrix([matrix([-43/188,25/376],[57/376,-55
/752]),matrix([71/376,27/376],[-81/752,91/752])],
[matrix([145/376,25/752],[-109
/376,59/752]),matrix([-305/752,27/752],[333/752,-207/752])])
(%i7) m1.m1_inv;
(%o7)
matrix([matrix([1,0],[0,1]),matrix([0,0],[0,0])],[matrix([0,0],[0,0]),matrix([1,0],[0,1])])
BW
-----maxima-bounces at math.utexas.edu wrote: -----
>To: maxima at math.utexas.edu
>From: Peter Danenberg <pcd at wikitex.org>
>Sent by: maxima-bounces at math.utexas.edu
>Date: 11/21/2007 05:25PM
>Subject: Re: [Maxima] Matrix: finding x in A.x=b
>
>> Is there any way to find vector x in A.x=b simply?
>
>What about something like this:
>
> (%i10) load(linearalgebra)$
> (%i11) A:matrix([1,2],[3,4])$
> (%i12) b:matrix([1],[2])$
> (%i13) lu_backsub(lu_factor(A, floatfield), b);
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima