(* MATRICI *)

(* SOLUZIONE SIMULTANEA DI n SISTEMI *)

Clear[x1,x2,x3];
aa={{2,-1,3},{-2,3,-1},{3,-2,2}};
b1={1,-2,-1};
b2={2,0,-1};
b3={-1,2,2};
bb={b1,b2,b3};
b=Transpose[bb];
ab1={Join[aa[[1]],{b1[[1]]}],Join[aa[[2]],{b1[[2]]}],Join[aa[[3]],{b1[[3]]}]};
ab2={Join[aa[[1]],{b2[[1]]}],Join[aa[[2]],{b2[[2]]}],Join[aa[[3]],{b2[[3]]}]};
ab3={Join[aa[[1]],{b3[[1]]}],Join[aa[[2]],{b3[[2]]}],Join[aa[[3]],{b3[[3]]}]};
MatrixForm[ab1]
MatrixForm[ab2]
MatrixForm[ab3]
MatrixForm[b]

ab={Join[aa[[1]],b[[1]]],Join[aa[[2]],b[[2]]],Join[aa[[3]],b[[3]]]};
MatrixForm[ab]

(* INVERSA DI UNA MATRICE *)

Clear[ab,b]
b={{1,0,0},{0,1,0},{0,0,1}};
MatrixForm[b];
ab={Join[aa[[1]],b[[1]]],Join[aa[[2]],b[[2]]],Join[aa[[3]],b[[3]]]};
MatrixForm[ab]

ab1={ab[[1]],ab[[1]]+ab[[2]],3*ab[[1]]-2*ab[[3]]};
MatrixForm[ab1]

ab2={ab1[[1]],ab1[[2]],2*ab1[[3]]-ab1[[2]]}; (* Eliminaz. Gaussiana *)
MatrixForm[ab2]

x31=5/8;
x21=(1-2*x31)/2;
x11=(1-3*x31+x21)/2;

x32=-1/8;
x22=(1-2*x32)/2;
x12=(0-3*x32+x22)/2;

x33=-1/2;
x23=(0-2*x33)/2;
x13=(0-3*x33+x23)/2;

ainv={{x11,x12,x13},{x21,x22,x23},{x31,x32,x33}};
MatrixForm[ainv]
MatrixForm[Inverse[aa]]
MatrixForm[Dot[aa,ainv]]