6

Is there a way to make Orthogonalize do the normal Gram-Schmidt procedure without normalizing the result? As far as I've understood this was possible with Mathematica 5.2.

One way would be to just multiply with the norms but being complicated expressions the whole thing would be easier without normalizing in the first place.

jorgen
  • 539
  • 2
  • 11

1 Answers1

12

How about writing the Gram-Schmit down by yourself?

GramSchmidt[w_?MatrixQ] := Module[{v = ConstantArray[0, Length[w]]},
  Table[
    v[[n]] = w[[n]] - 
      Sum[(v[[i]].w[[n]]/v[[i]].v[[i]])*v[[i]], {i, 1, n - 1}], 
    {n, 1, Length[w]}];
  v
]

Then you have the unscaled orthogonal basis

GramSchmidt[{{1, 1, 1}, {1, 1/2, 1/3}, {1, 2, 3}}]
Graphics3D[Arrow[{{0, 0, 0}, #}] & /@ %]

Mathematica graphics

halirutan
  • 112,764
  • 7
  • 263
  • 474
  • Thanks! That's great. I actually need it for a nonstandard inner product but probably that can be easily incorporated into your function. – jorgen Nov 19 '13 at 17:56
  • @halirutan, you could generalize this to linearly dependent set of vectors by adding a condition. Right now, it returns Indeterminate on for example, w = {{4, 2}, {2, 1}, {3, 3}}; – cleanplay Apr 28 '18 at 12:50
  • @cleanplay The question is, what result do you expect? The original Orthogonalize gives you a null-vector if it is dependent on some former vector. In numerical applications, one maybe likes a different approach. You could for instance make a small random perturbation and get a normal basis even with dependent vectors. – halirutan Apr 29 '18 at 11:54
  • 1
    @halirutan I have copied your code, it is showing SyntaxError: Incomplete Expression; More input needed when I am using it with some code you can see here. Can we use capital letter for functions not defined in Mathematica? Please help.. – tarit goswami Feb 16 '19 at 08:45
  • @taritgoswami post a question and also with copyable code, pictures are useless for us to help :) – CA Trevillian Apr 22 '19 at 13:31