solve for a matrix



Hello,

(%i1) A: matrix([1,-1,0,0],[0,0,1,2],[0,0,0,1])$
(%i2) x: [y1,y2,y3,y4]$
(%i3) b: [0,0,1]$
(%i4) A . x=b$

Right, solve or algsys cannot solve this. The last equation is not a system of equations. So 
we have to pull out the system of three equations:

(%i5) map(args,%)$
(%i6) map(flatten,%)$
(%i7) map("=", lhs(%), rhs(%));
(%o7)                [y1 - y2 = 0, 2 y4 + y3 = 0, y4 = 1]

Done. Now we can solve:

(%i8) solve(%,x);
(%o8)              [[y1 = %r1, y2 = %r1, y3 = - 2, y4 = 1]]

HTH

Volker van Nek

Am 25 Nov 2008 um 12:58 hat N.A.Beishuizen at ctw.utwente.nl geschrieben:

> Hello,
> 
> I want to solve a linear algebraic system like this:
> y1 - y2 = 0
> y3 + 2*y4 = 0
> y4 = 1
> 
> which has the solution y1=y2, y3=-2, y4=1 
> 
> but I have stored it in matrix form A*x=b, with the matrices (not in maxima format):
> A=(1,-1,0,0; 0,0,1,2; 0,0,0,1), x=(y2,y2,y3,y4) and b=(0,0,0,1)
> 
> Solve does not work with matrices, so is there: 
> 1. a way of converting the matrix system Ax=b into a list 
> or 
> 2. a way of getting the solution Ax=b using the matrix form?
> 
> Regards,
> Nijso
> 
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima