6
$\begingroup$

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.

$\endgroup$

1 Answer 1

12
$\begingroup$

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

$\endgroup$
5
  • $\begingroup$ Thanks! That's great. I actually need it for a nonstandard inner product but probably that can be easily incorporated into your function. $\endgroup$
    – jorgen
    Commented Nov 19, 2013 at 17:56
  • $\begingroup$ @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}}; $\endgroup$
    – cleanplay
    Commented Apr 28, 2018 at 12:50
  • $\begingroup$ @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. $\endgroup$
    – halirutan
    Commented Apr 29, 2018 at 11:54
  • 1
    $\begingroup$ @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.. $\endgroup$ Commented Feb 16, 2019 at 8:45
  • $\begingroup$ @taritgoswami post a question and also with copyable code, pictures are useless for us to help :) $\endgroup$ Commented Apr 22, 2019 at 13:31

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.