MATLAB: If first and last rows of an orthogonal matrix is known, is it possible to determine remaining orthogonal rows

gram-schmidt orthogonalizationorthogonalization

I need to derive a 7*7orthogonal matrix. I have first and last rows of the required matrix. Here is my first and last row:
[-0.0897 0.6659 -0.7531 0.7545 -0.7141 0.3670 0.0336]
[0.5784 0.2538 0.2871 0.2870 0.2723 0.1565 0.5822]
I tried to derive rest of the rows by converting these rows into reduced echolon form as follows:
[1 0 0.9372 0 0.8888 0.0271 0.9294]
[0 1 -1 1.133 -0.9527 0.5548 0.1756]
I end up in following rows
t2 = [-0.9372 1 1 0 0 0 0];
t3 = [0 -1.133 0 1 0 0 0];
t4 = [-0.8888 0.9527 0 0 1 0 0];
t5 = [-0.0271 -0.5548 0 0 0 1 0];
t6 = [-0.9294 -0.1756 0 0 0 0 1];
I suspect, my answer is not correct. In the book, it's written that it can be done by Gram-Schmidt orthogonalization (GSO) process though I couldn't find how to do that. Any hint in order to solve this problem will be appreciated.

Best Answer

If this is homework, and you need to do this using tools other than null, sorry, you are out of luck. I won't do your homework.
Given only TWO rows of a 7x7 orthogonal matrix, the other 5 rows cannot be computed unambiguously. It is trivial to compute 5 rows that are orthogonal to those two. But the solution is not unique.
A12 = [1 0 0.9372 0 0.8888 0.0271 0.9294;0 1 -1 1.133 -0.9527 0.5548 0.1756];
First, these rows are NOT rows of an orthogonal matrix. Not even close. If they were rows of an orthognal matrix, then they would form a 2x2 identity matrix when I did this. (At least the matrix would be diagonal.)
A12*A12'
ans =
3.5328 -1.6057
-1.6057 4.53
As you see, not close. We can find a pair of vectors that span the subspace spanned by the rows of A12.
A12span = orth(A12.').'
A12span =
0.24813 -0.33686 0.56941 -0.38167 0.54147 -0.18017 0.17146
0.52522 0.38687 0.10536 0.43833 0.098237 0.22887 0.55607
A12span*A12span'
ans =
1 6.1442e-17
6.1442e-17 1
They form a basi for the given subspace. And as I showed, they are now clearly orthogonal to each other. But, how can you produce 5 rows that are orthogonal to them? That part is trivial, if you understand these tools and linear algebra.
Aetc = null(A12)';
Aetc contains 5 rows that are orthogonal to the first two. It is NOT unique. But Aetc does contain a set of 5 orthogonal vectors, that form the nulllspace of A12.
A12*Aetc'
ans =
-5.6499e-17 -5.0291e-18 8.9914e-17 -8.8734e-18 1.0304e-16
-3.4911e-17 1.4416e-16 -4.3053e-17 -3.6445e-17 3.9777e-17
As you can see, these new rows are orthogonal to those we started with (to within floating point trash.) However, as I have said, they are not unique. Here is the set I found from null.
Aetc
Aetc =
-0.44155 0.37035 0.76564 0.14227 -0.22281 0.066519 -0.08584
-0.089566 -0.58121 0.11312 0.77673 0.10813 -0.11176 -0.11785
-0.4184 0.35345 -0.22269 0.13578 0.78829 0.063512 -0.080955
-0.058912 -0.28873 0.051501 -0.11091 0.049266 0.94435 -0.063196
-0.53015 -0.23152 -0.11587 -0.088939 -0.10955 -0.049171 0.79346
But I can randomly rotate them. As you can see, they are different. But they still form an orthogonal basis for the nullspace.
Aetc2 = orth(rand(5))*Aetc
Aetc2 =
0.59296 -0.41116 -0.027373 0.20009 -0.064484 0.34931 -0.55892
0.25207 -0.19553 -0.49276 -0.61913 -0.19405 0.2677 0.40345
-0.31595 -0.18661 -0.40325 0.22085 0.71615 0.37217 0.050869
0.37243 0.44545 -0.42055 -0.177 0.36582 -0.4723 -0.31272
0.094385 -0.54435 -0.28572 0.39843 -0.093004 -0.59992 0.29299
>> Aetc2*Aetc2'
ans =
1 1.8385e-16 -2.4559e-16 6.162e-17 -1.085e-16
1.8385e-16 1 1.9243e-16 -1.2065e-16 2.4558e-16
-2.4559e-16 1.9243e-16 1 7.8167e-18 -2.8819e-16
6.162e-17 -1.2065e-16 7.8167e-18 1 1.6765e-16
-1.085e-16 2.4558e-16 -2.8819e-16 1.6765e-16 1
>> A12*Aetc2'
ans =
1.6735e-16 1.0458e-17 2.3824e-17 2.5912e-17 3.4096e-17
3.8011e-17 -6.4272e-18 -3.6084e-17 -9.3707e-17 8.6515e-17
And as shown, they are still orthogonal to the original set in A12.
Finally, IF the goal is to produce an orthogonal 7x7 matrix, this would do so:
A = [orth(A12')';Aetc];
A is an orthogonal matrix, based on the original rows. As a test of that claim...
A*A'
ans =
1 7.532e-17 -5.9336e-19 -6.0682e-17 4.1989e-17 1.6129e-17 4.086e-17
7.532e-17 1 -8.3428e-17 5.4361e-17 -2.9411e-17 -2.2233e-17 4.4083e-17
-5.9336e-19 -8.3428e-17 1 4.1705e-17 4.5634e-17 6.1926e-18 2.3981e-17
-6.0682e-17 5.4361e-17 4.1705e-17 1 4.5802e-17 -1.7362e-17 7.2233e-19
4.1989e-17 -2.9411e-17 4.5634e-17 4.5802e-17 1 1.6961e-17 -5.3706e-19
1.6129e-17 -2.2233e-17 6.1926e-18 -1.7362e-17 1.6961e-17 1 8.1267e-19
4.086e-17 4.4083e-17 2.3981e-17 7.2233e-19 -5.3706e-19 8.1267e-19 1