M:matrix([2,x,1],[4,2,1],[3,1,-1]);

m:matrix([1,2],[x,1]);

determinant(M)=determinant(m);

solve(%,x);