Try something like this
(C2) m : matrix([1,2,3],[4,5,6],[7,8,9]);
(D2) MATRIX([1,2,3],[4,5,6],[7,8,9])
Replace row 2 by row 2 - 4 row 1
(C3) m[2] : part(m,2) - 4 * part(m,1);
(D3) [0,-3,-6]
Look at m
(C4) m;
(D4) MATRIX([1,2,3],[0,-3,-6],[7,8,9])
Replace row 3 by row 3 - 7 row 1
(C5) m[3] : part(m,3) - 7 * part(m,1);
(D5) [0,-6,-12]
Look at m
(C6) m;
(D6) MATRIX([1,2,3],[0,-3,-6],[0,-6,-12])
Replace row 3 by row 3 - 2 row 2
(C7) m[3] : part(m,3) - 2 * part(m,2);
(D7) [0,0,0]
Look at m
(C8) m;
(D8) MATRIX([1,2,3],[0,-3,-6],[0,0,0])
(C9)
Alternatively, use triangularize
(C9) m : matrix([1,2,3],[4,5,6],[7,8,9]);
(D9) MATRIX([1,2,3],[4,5,6],[7,8,9])
(C10) triangularize(m);
(D10) MATRIX([1,2,3],[0,-3,-6],[0,0,0])
Maybe you would like to define a function that finds the two-norm.
(C11) two_norm(e) := sqrt(e.e);
(D11) two_norm(e):=SQRT(e . e)
(C12) two_norm([1,2,3]);
(D12) SQRT(14)
(C13) two_norm([a,b,c]);
(D13) SQRT(C^2+b^2+a^2)
A more robust function might check that the input is a list and
do something else if it isn't. For example
(C15) two_norm(e) := block([ ],
if listp(e) then sqrt(e.e) else error("input to two_norm must be a
list."));
(D15) two_norm(e):=BLOCK([],
IF LISTP(e) THEN SQRT(e . e)
ELSE ERROR("input to two_norm must be a list."))
(C16) two_norm(42);
input to two_norm must be a list.
#0: two_norm(e=42)
-- an error. Quitting. To debug this try DEBUGMODE(TRUE);)
If the arguments are complex, you might also need to use conjugate.
Barton
test <fmatsu@bc.mbn.or.jp>
Sent by: maxima-admin@www.ma.utexas.edu
05/01/2003 04:55 PM
To: maxima@www.ma.utexas.edu
cc:
Subject: [Maxima] 2 basic questions about linear.
1. elementary row operation for "matrix".
I would like to perform elementary row operation for Matrix.
[ 1, 1, 2] first Row of Matrix A -> Row1
[ 2, 4, -3] 2nd Row of Matrix A -> Row2
[ 3, 6, -5] 3rd Row of Matrix A -> Row3
In this Matrix named "A", I plan to perform Row2 + (-2)*Row1.
Row(A, 2) - 2*(Row(A,1) is work well.
But I can not return the value to Row2 of Matrix A.
I know the Matrix( [ 1, 0, 1], [-2, 1,0], [0, 0, 1]).A is good
another way.
But I want know how to do.
2. About a norm of vector.
I try to find the function that return the norm of a vector.
But I don't find. So I have done like bellows.
B:[2,2]
ABS(B.B)
That's I performed. Is there any simple way to get a norm of vector
like ||B|| or Norm(B).
Thank you.
_______________________________________________
Maxima mailing list
Maxima@www.math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima