0

Is there a way where Mathematica gives a step-by-step process for orthonormalization of vectors? I have the final result, but I would like to see the process of GramSchmidt to obtain the normalized basis.

  • 4
    There are many code posted here. Adding a Print statement could show the result of each step. (You don't mention it, but I assume you know of the built-in function Orthogonalize[].) – Michael E2 Mar 13 '21 at 15:13
  • @MichaelE2 Thank you. But please can you help me by where to write the "Print"? I tried to use some of the code, and it went well by I want to print all the steps, so how could I do that? – Mubarak Alsaeedi Mar 13 '21 at 15:25
  • 1
    Here you find an step by step intro to Gram Schmidt: https://mathworld.wolfram.com/Gram-SchmidtOrthonormalization.html – Daniel Huber Mar 13 '21 at 20:39
  • I cannot tell from your description exactly what you want printed out. And if you can't figure where to put Print to print what you want to see, it makes me wonder, what do you want printed? I don't think I can figure that out either. – Michael E2 Mar 14 '21 at 05:28
  • @MichaelE2 I want to print every step of the GS process, not just the final answer. – Mubarak Alsaeedi Mar 14 '21 at 05:40
  • 1
    So every time two numbers are added, the addends and the sum should be printed? The same for multiplications and divisions? I doubt it. I imagine you put in Print where I would, and printed out a row after it was changed. When I’m confused, I do something on the level of someone who is confused: I print Print[1 -> x] where x is the data calculated by the first step of the code; then Print[2 -> y] at the second step of the code, and so on. In this way, when I see what I really wanted to print, I know which Print statement gave me the desired output. – Michael E2 Mar 14 '21 at 05:56

1 Answers1

1

You can refer to the method in this post.

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]
tmat = {{1, 0, 1}, {2, 6, 3}, {1, 1, 1}, {2, 3, 5}};
GramSchmidt[tmat]

Appendix:

enter image description here