1
$\begingroup$

I have two subspaces $V_1$, $V_2$ of $\mathbb{R}^n$ each specified as the span of a given list L1, L2 of basis vectors, and I know a priori that $V_1\subset V_2$. What is the quickest (or shortest) expression to calculate a basis of the orthogonal complement of $V_1$ inside $V_2$?

asked Oct 27 at 18:02
$\endgroup$
1
  • 2
    $\begingroup$ Please edit the question and include some actual code example, ie. lists L1 and L2, together with the expected output. $\endgroup$ Commented Oct 27 at 20:07

2 Answers 2

4
$\begingroup$

Generally $V_{1}^{\perp} \cap V_{2} = \left( V_{1}+ V_{2}^{\perp}\right)^{\perp}$ holds, so this can be easily achieved with the following code:

NullSpace[Union[L1,NullSpace[L2]]]

Example:

n=6;
dim1=2;
dim2=5;
L2=RandomInteger[{-9,9},{dim2,n}]
(*{{-8,-8,-9,7,8,-5},
{-4,6,7,-7,3,-4},
{7,9,-2,5,7,-3},
{-8,6,-2,-1,4,4},
{-8,6,-1,-5,-7,7}}*)
L1=RandomInteger[{-3,3},{dim1,dim2}].L2
(*{{-43,-7,-11,-8,-2,3},{-45,-37,-12,-10,-23,9}}*)
basis=NullSpace[Union[L1,NullSpace[L2]]]
(*{{3423303,26965449,6851892,0,0,137110328},
{-8348533,-97751035,69911228,0,137110328,0},
{4717317,-1179017,-42619288,34277582,0,0}}*)
answered Oct 28 at 2:40
$\endgroup$
1
$\begingroup$

The function "Orthogonalize" calculates a Gram-Schmidt base of its arguments. Assume that the argument is: vs={v1,v2,..}, then "Orthogonalize" first normalizes vs[[1]]: e1. Then it calculates a unit vector e2 from e1 and vs[[2]] perpendicular to e1. Then a unit vector e3 from e1, e2 and vs[[3]] perpendicular to e1 and e2, e.t.c

Here is an example: Given a subspace V2 of dimension 4 of R^5 by:

bas2=RandomReal[{-1, 1}, {4, 5}];

Then a subbase V1 ofV2 of dimension 2 can be specified by 2 linear combinations of bas2:

bas1 = RandomReal[{-1, 1}, {2, 4}] . b2;

If we apply "Orthogonalize" to "Join ̈bas1,bas2" we get 6 vectors, where the first 2 are a orthonormal base for V1 and the 3. and 4. are an orthonormal base of the complement and the last 2 are zero because "Join ̈bas1,bas2" is linear depended.

combas = Orthogonalize[Join[b1, b2]];
ortb1= combas[[;;2]]
ortcompl= combas[[3;;4]]
answered Oct 27 at 20:43
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.