2
$\begingroup$

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.

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

As conveyed in the comments, the problem seems to have been with version 9 of Mathematica. I upgraded to 10.4.1 this morning, and it is working as expected.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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