11
$\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$

closed as off-topic by C. E., Yves Klett, Karsten 7., Verbeia Jan 1 '15 at 23:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – C. E., Yves Klett, Karsten 7., Verbeia
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\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$ – David G. Stork Jan 1 '15 at 17:53
  • 2
    $\begingroup$ MatrixForm[u = {{1 , 1, -1, 1}}] might be what you want. $\endgroup$ – Sungmin Jan 1 '15 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 '15 at 18:32
  • 7
    $\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$ – Fred Simons Jan 1 '15 at 19:21
  • 1
    $\begingroup$ You might be interested in this answer. $\endgroup$ – Sjoerd C. de Vries Jan 1 '15 at 23:19
9
$\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.