Normalize a vector: error [duplicate]

I have this simple example in which I am trying to write a column vector (ket vector) and then I want to normalize it. It seems that ther is something wrong, leading to an error message

"The first argument is not a number or a vector,... "

 myVec = {{1}, {2}};
Normalize[myVec]


How can one fix this. What is the best way of writing a ket vector and bra vector in Mathematica?

Edit: Related to some comments below, I want to added the following:

 mat1 = {{1}, {2}};
Dimensions[mat1](*(2,1)*)

mat2 = {{1, 2}};
Dimensions[mat2](*(1,2)*)

mat3 = {1, 2};
Dimensions[mat3](*(2)*)

• myVec = {1, 2} Feb 27, 2019 at 8:23
• Would this be a row or a column vector? Feb 27, 2019 at 8:29
• No. Normalize accepts a vector, in Wolfram language, which means a List with an ArrayDepth 1; a row/column vector is represented by a matrix (a List of Lists) with an ArrayDepth 2, unacceptable. Feb 27, 2019 at 8:32
• Tobias, there’s no practical distinction between row and column vectors in Mathematica. They are expressed the same way. You keep track of their “meaning” as you see fit. Feb 27, 2019 at 13:13

Mathematica's vectors are always simple lists (tutorial). In this sense there is no distinction between row vectors and column vectors, unlike Matlab etc.

A propos ket vs bra: if you define a state ket

p = {1, 2};


then the corresponding bra is simply

ps = Conjugate[p];


and is also a vector. The scalar product would be

ps.p
(* 5 *)


You could even define a scalar-product function

scp[a_?VectorQ, b_?VectorQ] /; Length[a] == Length[b] := Conjugate[a].b


and then calculate

scp[p,p]
(* 5 *)


If you want to make vectors a special case of matrices (this can be useful for some applications), you can normalize this way:

myVec/Norm[myVec]
(* {{1/Sqrt[5]}, {2/Sqrt[5]}} *)

• It's a bit odd that Mathematica can handle Norm[v] when v is a "column vector", i.e., a list of 1-element lists, yet Normalize cannot. Is there some good reason that Normalize should not equally generalize like that? Feb 28, 2019 at 21:05
• I can only guess that whoever made this design decision judged that extending Normalize to matrices would cause more confusion than enlightenment. Feb 28, 2019 at 21:19