Special Gram schmidt process

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 :

x={{0,1,2},{-1,-2,-3},{-1,0,2}}//MatrixForm
or
y={{0,2,2},{-1,-2,-3},{-1,0,2}}//MatrixForm

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

state1=ax+by
state2=a'x+b'y.

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.

• So far this question is meaningless. You need to define $\langle x_i| x_j\rangle$. Oct 6 '20 at 14:16
• 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.
– yfs
Oct 6 '20 at 15:33
• 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. Oct 6 '20 at 15:36

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

Assuming[Element[a|b|A|B,Reals],Orthogonalize[{{a,b},{A,B}}]//FullSimplify]

$$\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}.

• Ok, my question was not clear. I have 20000 basis states, not just x and y !
– yfs
Oct 6 '20 at 11:29
• @yfs You have to define $\langle x_i| x_j \rangle$. Oct 6 '20 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

ClearAll[myInnerProd]
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.

• 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...
– yfs
Oct 6 '20 at 10:14
• @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. Oct 6 '20 at 11:03
• 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. Oct 6 '20 at 13:58
• 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
– yfs
Oct 6 '20 at 15:32