I need to define a random set of two orthogonal unit vectors. The code below doesn't give proper unit and orthogonal vectors :
Clear["Global`*"]
n[k_] := Normalize[{RandomReal[{-1, 1}], RandomReal[{-1, 1}], RandomReal[{-1, 1}]}]
u[k_] := Normalize[{RandomReal[{-1, 1}], RandomReal[{-1, 1}], RandomReal[{-1, 1}]}]
a[k_] := Normalize[u[k] - (u[k].n[k])n[k]]
(* unitary and orthogonality test : *)
Table[n[k].n[k], {k, 1, 5}] (* this should output five 1 *)
Table[a[k].a[k], {k, 1, 5}] (* this should output five 1 *)
Table[n[k].a[k], {k, 1, 5}] (* this should output five 0 *)
Specifically, for any value of $k$ (which should be any real number) : \begin{align} \vec{\boldsymbol{n}}(k) \cdot \vec{\boldsymbol{n}}(k) &= 1, \\ \vec{\boldsymbol{a}}(k) \cdot \vec{\boldsymbol{a}}(k) &= 1. \\ \vec{\boldsymbol{n}}(k) \cdot \vec{\boldsymbol{a}}(k) &= 0. \end{align}
So what is wrong with the code above ?

n[k_]:=defines a function ofk. If you call it 3 times with the same argument, it gets evaluated 3 times and you get 3 different random vectors – Niki Estner Mar 23 '16 at 15:30