I have a matrix in which each number represents a physical property (spin) of an atom. The whole matrix represents the state of my system. for example :


represent two different (among 20 000 other states) and therefore orthogonal states.

now I have several states which are linear combinations of my basis states for example


I want to orthogonalize these state via the gram schmidt process (or something like that).

Q:Is there a way to tell mathematica that two different matrices are orthogonal in this special case (i.e. that x and y are othogonal)?

or in other words is there a way to make mathematica perform the orthogonalization process without having to rewrite the basis states into a series of 1 an 0 ?

I was thinking of using the f option in the documentation of the Orthogonalize function but I can't see how. (I am kinda new to mathematica)

Thank you very much for your help.

  • $\begingroup$ So far this question is meaningless. You need to define $\langle x_i| x_j\rangle$. $\endgroup$
    – yarchik
    Oct 6, 2020 at 14:16
  • $\begingroup$ what x_i and x_, if they are the basis states, I 've written that they were orthogonal, so it's 0, actually they're orthonormal. $\endgroup$
    – DarkBulle
    Oct 6, 2020 at 15:33
  • $\begingroup$ But you just said you have 20 000 basis states. I find it is inconvenient to number them $x$, $y$, what comes next? Therefore, I numbered them $x_i$. So, to streamline the notations $x\rightarrow x_1$, $y\rightarrow x_2$, and so on till 20 000. $\endgroup$
    – yarchik
    Oct 6, 2020 at 15:36

2 Answers 2


You can simply orthogonalize in the {x,y} basis:


$$\left\{\left\{\frac{a}{\sqrt{a^2+b^2}},\frac{b}{\sqrt{a^2+b^2}}\right\},\left\{\frac{b \text{Sign}[A b-a B]}{\sqrt{a^2+b^2}},-\frac{a \text{Sign}[A b-a B]}{\sqrt{a^2+b^2}}\right\}\right\}$$

In other words, you do not even need to do the orthogonalization. Given {a,b} is a vector of length 1 according to your metric, the other one is simply {b,-a} or {-b,a}.

  • 1
    $\begingroup$ Ok, my question was not clear. I have 20000 basis states, not just x and y ! $\endgroup$
    – DarkBulle
    Oct 6, 2020 at 11:29
  • $\begingroup$ @yfs You have to define $\langle x_i| x_j \rangle$. $\endgroup$
    – yarchik
    Oct 6, 2020 at 14:14

I am not really sure why you think that the states need to be necessarily orthogonal, but indeed one can force this kind of behavior using Orthogonalize.

One nonminimal solution is

SetAttributes[myInnerProd, Orderless]
myInnerProd[x, y] := 0
myInnerProd[x, x] := 1
myInnerProd[y, y] := 1
myInnerProd[a_ + b_, c_] := myInnerProd[a, c] + myInnerProd[b, c]
myInnerProd[c_ x, a_] /; FreeQ[c, x] := c myInnerProd[x, a]
myInnerProd[c_ y, a_] /; FreeQ[c, y] := c myInnerProd[y, a]
state1 = a x + b y;
state2 = aPrime x + bPrime y;
Orthogonalize[{state1, state2}, myInnerProd] // ExpandAll

Note that I assumed that your states are normalized.

  • $\begingroup$ Thanks, this helps me a lot.In the gram schmidt process, you need to project a state on the space generated by other, this you do through the dot product between the state and (to make it short) all the others. I need to define this dot product. One way to do it is to indicate that my basis contains only mutually orthogonal states. I think... $\endgroup$
    – DarkBulle
    Oct 6, 2020 at 10:14
  • $\begingroup$ @yfs On second thought, I think it would be best just to define some vectors in $\mathbb{R}^2$, e.g. e1 = {1, 0}; e2= {0, 1}; and then Orthogonalize the states state1 = a e1 + b e2; state2 = aPrime e1 + bPrime e2. $\endgroup$
    – Natas
    Oct 6, 2020 at 11:03
  • $\begingroup$ The fundamental step in Gram Schmidt process is: given an already normalized vector v0 and a new vector v1 we search a linear combination the is orthogonal to v0: v1= v0 + c v1 under the constrain: v0.v0 + c v0.v1 ==0 And because v0.v0==1, c= -1/v0.v1 So the only thing you need is the scalar product and if you are using an orthonormal basis, this is simply the Dot product. $\endgroup$ Oct 6, 2020 at 13:58
  • $\begingroup$ yep, I know. but in Mathematica, x.y!=0, the question if you want is how to define an inner product so that x.y=0 $\endgroup$
    – DarkBulle
    Oct 6, 2020 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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