16
$\begingroup$

Why the two followings giving me same output? At least one should give me a row vector and another should give me a column vector.

MatrixForm[u = {1 , 1, -1, 1}]

MatrixForm[v = {{1}, {1}, {-1}, {1}}]

When I am trying to get transpose of u by taking Transpose[u], I am Mathematica is showing ""The first two levels of the one-dimensional list {1,1,-1,1} cannot be transposed"". So how to take transpose of a one dimensional vector?

$\endgroup$
10
  • $\begingroup$ Mathematica's internal representation of a one-dimensional vector is the same as a (one-dimensional) list, which allows Dot[a,b] to be defined generally, even for lists that are not of numbers. As such, the internal representation does not admit a Transpose of a one-dimensional list. Why do you want the transpose of a one-dimensional vector (or list)? $\endgroup$ Jan 1, 2015 at 17:53
  • 3
    $\begingroup$ MatrixForm[u = {{1 , 1, -1, 1}}] might be what you want. $\endgroup$
    – Sungmin
    Jan 1, 2015 at 18:00
  • 8
    $\begingroup$ The function Transpose permutes two (or more) distinct levels in an array/tensor. Your vector/list has only one level, so transposition is not possible. The way transposing a vector was explained to me in linear algebra was that we may consider a vector as a either a row matrix or a column matrix, which may be transposed. In Mathematica, a row matrix has the form {{1 , 1, -1, 1}}, as Sungmin points out. $\endgroup$
    – Michael E2
    Jan 1, 2015 at 18:32
  • 8
    $\begingroup$ I cannot resist the temptation to mention a point that I always strongly emphasized in my courses. A vector is just a list. What is called a row vector of a column vector are just two different (matrix) notations for the same vector. A vector cannot be transposed, but we can switch from one notation to another by transposing the matrix notation. I am happy to see that Mathematica treats vectors in the same way. $\endgroup$ Jan 1, 2015 at 19:21
  • 1
    $\begingroup$ You might be interested in this answer. $\endgroup$ Jan 1, 2015 at 23:19

1 Answer 1

14
$\begingroup$
u = {{1, 1, -1, 1}}
(* NOT u = {1 , 1, -1, 1}, which is a list, I think *)
v = {{1}, {1}, {-1}, {1}}
MatrixForm[u]
MatrixForm[v]

Also

Transpose[u]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.