# Orthogonalize with a custom inner product

Bug introduced in 9.0 or earlier and fixed in 10.0

I was trying to define a custom inner product function for Orthogonalize, and have been getting some odd behaviour. Here's a MWE: I try to compute the inner product using the last 2 elements of a vector. For an exact matrix, it works as expected.

Orthogonalize[{{1, 0, 1}, {-1, 2, 1}}, #1[[-2 ;; -1]].#2[[-2 ;; -1]] &] // MatrixForm


$$\left( \begin{array}{ccc} 1 & 0 & 1 \\ -1 & 1 & 0 \\ \end{array} \right)$$ The point being that if you ignore the first column, the two vectors are orthogonal (and normalised).

Meanwhile, if the vectors are numerical

Orthogonalize[N[{{1, 0, 1}, {-1, 2, 1}}], #1[[-2 ;; -1]].#2[[-2 ;; -1]] &] // MatrixForm


I get the answer $$\left( \begin{array}{ccc} 0.707107 & 0. & 0.707107 \\ -0.588348 & 0.784465 & 0.196116 \\ \end{array} \right)$$ The rows have been normalised across the whole row (not the last two elements) and the two rows are not orthogonal according to either measure.

I'm sure I could write a custom function to do all this, but when it's all supposed to be built-in, the built-in solution will presumably be better/faster than anything I could write myself. So, what have I missed? In case it makes a difference, I'm running Mathematica v.9 at the moment.

• Looks like a bug fixed in M10+. – Carl Woll Sep 14 '17 at 15:55
• @CarlWoll. Verified in V10.0.01 on Mac OSX that it works correctly. – march Sep 14 '17 at 15:57
• v10.4 on Win10 works fine, too. – aardvark2012 Sep 14 '17 at 23:42
• This bug is present in version 8.0.4 as well. – innaiz Sep 15 '17 at 15:23