Distance of a vector from a subspace - Linear Algebra












2














I want to calculate the distance of the vector $x=(1,1,1,1)$ to the subspace ${(1,0,2,0) , (0,1,0,2)}$



I have solved this in 2 ways that I know of but the thing is, the results are different.



For instance when I use $||x-Pr(x)||$ I get $sqrt{2}$, but when I calculate it using the gram determinant (more info here: Distance between a point and a m-dimensional space in n-dimensional space ($m<n$) ) I get $sqrt{frac{10}{25}}$ which is weird because both ways should be equivalent.



So my question is, what am I missing here? Which one of these result was the correct one?



Thank you.



Edit: Solution using $||x-Pr(x)||$ :



Let $v_1$ be $(1,0,2,0)$ and $v_2$ be $(0,1,0,2)$



Both vectors $v_1$ and $v_2$ are orthogonal meaning the inner product of them is $0$. Now we need to make them orthonormal. After doing so we get $e_1=v_1/sqrt{3}$ and $e_2=v_2/sqrt{3}$



Now we calculate $Pr(x)$.



$$Pr(x)= (x,e_1)e_1+(x,e_2)e_2 =ldots= (1,1,2,2)$$



Therefore the distance is $d(x,U)= ||x-Pr(x)||=||(1,1,1,1)-(1,1,2,2)||= ||(0,0,-1,-1)||= sqrt{2}$










share|cite|improve this question
























  • @M.Vinay yes that is indeed what I meant.
    – Kyle
    Jun 28 '14 at 14:48










  • $sqrt{3}$ is not the modulus of those vectors
    – enzotib
    Jun 28 '14 at 15:49










  • Note that $|v_k| = sqrt{5}$.
    – copper.hat
    Jun 28 '14 at 15:53












  • I can't believe I made that mistake lol, well it's all clear now, thanks a lot guys.
    – Kyle
    Jun 28 '14 at 15:57
















2














I want to calculate the distance of the vector $x=(1,1,1,1)$ to the subspace ${(1,0,2,0) , (0,1,0,2)}$



I have solved this in 2 ways that I know of but the thing is, the results are different.



For instance when I use $||x-Pr(x)||$ I get $sqrt{2}$, but when I calculate it using the gram determinant (more info here: Distance between a point and a m-dimensional space in n-dimensional space ($m<n$) ) I get $sqrt{frac{10}{25}}$ which is weird because both ways should be equivalent.



So my question is, what am I missing here? Which one of these result was the correct one?



Thank you.



Edit: Solution using $||x-Pr(x)||$ :



Let $v_1$ be $(1,0,2,0)$ and $v_2$ be $(0,1,0,2)$



Both vectors $v_1$ and $v_2$ are orthogonal meaning the inner product of them is $0$. Now we need to make them orthonormal. After doing so we get $e_1=v_1/sqrt{3}$ and $e_2=v_2/sqrt{3}$



Now we calculate $Pr(x)$.



$$Pr(x)= (x,e_1)e_1+(x,e_2)e_2 =ldots= (1,1,2,2)$$



Therefore the distance is $d(x,U)= ||x-Pr(x)||=||(1,1,1,1)-(1,1,2,2)||= ||(0,0,-1,-1)||= sqrt{2}$










share|cite|improve this question
























  • @M.Vinay yes that is indeed what I meant.
    – Kyle
    Jun 28 '14 at 14:48










  • $sqrt{3}$ is not the modulus of those vectors
    – enzotib
    Jun 28 '14 at 15:49










  • Note that $|v_k| = sqrt{5}$.
    – copper.hat
    Jun 28 '14 at 15:53












  • I can't believe I made that mistake lol, well it's all clear now, thanks a lot guys.
    – Kyle
    Jun 28 '14 at 15:57














2












2








2







I want to calculate the distance of the vector $x=(1,1,1,1)$ to the subspace ${(1,0,2,0) , (0,1,0,2)}$



I have solved this in 2 ways that I know of but the thing is, the results are different.



For instance when I use $||x-Pr(x)||$ I get $sqrt{2}$, but when I calculate it using the gram determinant (more info here: Distance between a point and a m-dimensional space in n-dimensional space ($m<n$) ) I get $sqrt{frac{10}{25}}$ which is weird because both ways should be equivalent.



So my question is, what am I missing here? Which one of these result was the correct one?



Thank you.



Edit: Solution using $||x-Pr(x)||$ :



Let $v_1$ be $(1,0,2,0)$ and $v_2$ be $(0,1,0,2)$



Both vectors $v_1$ and $v_2$ are orthogonal meaning the inner product of them is $0$. Now we need to make them orthonormal. After doing so we get $e_1=v_1/sqrt{3}$ and $e_2=v_2/sqrt{3}$



Now we calculate $Pr(x)$.



$$Pr(x)= (x,e_1)e_1+(x,e_2)e_2 =ldots= (1,1,2,2)$$



Therefore the distance is $d(x,U)= ||x-Pr(x)||=||(1,1,1,1)-(1,1,2,2)||= ||(0,0,-1,-1)||= sqrt{2}$










share|cite|improve this question















I want to calculate the distance of the vector $x=(1,1,1,1)$ to the subspace ${(1,0,2,0) , (0,1,0,2)}$



I have solved this in 2 ways that I know of but the thing is, the results are different.



For instance when I use $||x-Pr(x)||$ I get $sqrt{2}$, but when I calculate it using the gram determinant (more info here: Distance between a point and a m-dimensional space in n-dimensional space ($m<n$) ) I get $sqrt{frac{10}{25}}$ which is weird because both ways should be equivalent.



So my question is, what am I missing here? Which one of these result was the correct one?



Thank you.



Edit: Solution using $||x-Pr(x)||$ :



Let $v_1$ be $(1,0,2,0)$ and $v_2$ be $(0,1,0,2)$



Both vectors $v_1$ and $v_2$ are orthogonal meaning the inner product of them is $0$. Now we need to make them orthonormal. After doing so we get $e_1=v_1/sqrt{3}$ and $e_2=v_2/sqrt{3}$



Now we calculate $Pr(x)$.



$$Pr(x)= (x,e_1)e_1+(x,e_2)e_2 =ldots= (1,1,2,2)$$



Therefore the distance is $d(x,U)= ||x-Pr(x)||=||(1,1,1,1)-(1,1,2,2)||= ||(0,0,-1,-1)||= sqrt{2}$







linear-algebra






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Apr 13 '17 at 12:21









Community

1




1










asked Jun 28 '14 at 14:44









Kyle

1314




1314












  • @M.Vinay yes that is indeed what I meant.
    – Kyle
    Jun 28 '14 at 14:48










  • $sqrt{3}$ is not the modulus of those vectors
    – enzotib
    Jun 28 '14 at 15:49










  • Note that $|v_k| = sqrt{5}$.
    – copper.hat
    Jun 28 '14 at 15:53












  • I can't believe I made that mistake lol, well it's all clear now, thanks a lot guys.
    – Kyle
    Jun 28 '14 at 15:57


















  • @M.Vinay yes that is indeed what I meant.
    – Kyle
    Jun 28 '14 at 14:48










  • $sqrt{3}$ is not the modulus of those vectors
    – enzotib
    Jun 28 '14 at 15:49










  • Note that $|v_k| = sqrt{5}$.
    – copper.hat
    Jun 28 '14 at 15:53












  • I can't believe I made that mistake lol, well it's all clear now, thanks a lot guys.
    – Kyle
    Jun 28 '14 at 15:57
















@M.Vinay yes that is indeed what I meant.
– Kyle
Jun 28 '14 at 14:48




@M.Vinay yes that is indeed what I meant.
– Kyle
Jun 28 '14 at 14:48












$sqrt{3}$ is not the modulus of those vectors
– enzotib
Jun 28 '14 at 15:49




$sqrt{3}$ is not the modulus of those vectors
– enzotib
Jun 28 '14 at 15:49












Note that $|v_k| = sqrt{5}$.
– copper.hat
Jun 28 '14 at 15:53






Note that $|v_k| = sqrt{5}$.
– copper.hat
Jun 28 '14 at 15:53














I can't believe I made that mistake lol, well it's all clear now, thanks a lot guys.
– Kyle
Jun 28 '14 at 15:57




I can't believe I made that mistake lol, well it's all clear now, thanks a lot guys.
– Kyle
Jun 28 '14 at 15:57










2 Answers
2






active

oldest

votes


















2














I'll offer the third method:



Let the point in that subspace be given by $x (0,1,0,2)+y(1,0,2,0)$. Then the square of the distance to the point $(1, 1, 1, 1)$ can be written as,



$$(1-y)^2+(1-x)^2+(1-2y)^2+(1-2x)^2$$
We need to minimize the above expression with respect to $x$ and $y$. Due to symetry, it's sufficient to consider only the minimization
$$min_x ( (1-x)^2 +(1-2x)^2) =min_x( 5x^2-6x+2).$$
The minimum is attained at $x=frac 35$ and the minimal value is $frac 15$. Therefore, the square of the minimum distance is $frac 25$ (i.e. the same as you obtained via Gram's determinant).



It seems that you made some mistakes while calculating $|x-mathrm{Pr}, x|$.






share|cite|improve this answer























  • Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
    – Kyle
    Jun 28 '14 at 15:22










  • @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
    – TZakrevskiy
    Jun 28 '14 at 15:28










  • I've edited the OP with the solution using ||x-Pr(x)||
    – Kyle
    Jun 28 '14 at 15:39





















2














This is a geometric view of TZakrevskiy's answer.



Let $V=operatorname{sp} {v_1,v_2}$. Note that $v_1 bot v_2$ in this problem.



If $p in V$ minimizes the distance between $x$ and $V$, we have
$(x-p) bot v_k $ for $k=1,2$.



Writing $p=sum_k alpha_k v_k$ and using orthogonality, we obtain
$alpha_k = { langle x , v_k rangle over |v_k|^2} = { 3 over 5}$.



Substituting gives $|x-p| = sqrt{2 over 5}$






share|cite|improve this answer























    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f850439%2fdistance-of-a-vector-from-a-subspace-linear-algebra%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I'll offer the third method:



    Let the point in that subspace be given by $x (0,1,0,2)+y(1,0,2,0)$. Then the square of the distance to the point $(1, 1, 1, 1)$ can be written as,



    $$(1-y)^2+(1-x)^2+(1-2y)^2+(1-2x)^2$$
    We need to minimize the above expression with respect to $x$ and $y$. Due to symetry, it's sufficient to consider only the minimization
    $$min_x ( (1-x)^2 +(1-2x)^2) =min_x( 5x^2-6x+2).$$
    The minimum is attained at $x=frac 35$ and the minimal value is $frac 15$. Therefore, the square of the minimum distance is $frac 25$ (i.e. the same as you obtained via Gram's determinant).



    It seems that you made some mistakes while calculating $|x-mathrm{Pr}, x|$.






    share|cite|improve this answer























    • Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
      – Kyle
      Jun 28 '14 at 15:22










    • @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
      – TZakrevskiy
      Jun 28 '14 at 15:28










    • I've edited the OP with the solution using ||x-Pr(x)||
      – Kyle
      Jun 28 '14 at 15:39


















    2














    I'll offer the third method:



    Let the point in that subspace be given by $x (0,1,0,2)+y(1,0,2,0)$. Then the square of the distance to the point $(1, 1, 1, 1)$ can be written as,



    $$(1-y)^2+(1-x)^2+(1-2y)^2+(1-2x)^2$$
    We need to minimize the above expression with respect to $x$ and $y$. Due to symetry, it's sufficient to consider only the minimization
    $$min_x ( (1-x)^2 +(1-2x)^2) =min_x( 5x^2-6x+2).$$
    The minimum is attained at $x=frac 35$ and the minimal value is $frac 15$. Therefore, the square of the minimum distance is $frac 25$ (i.e. the same as you obtained via Gram's determinant).



    It seems that you made some mistakes while calculating $|x-mathrm{Pr}, x|$.






    share|cite|improve this answer























    • Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
      – Kyle
      Jun 28 '14 at 15:22










    • @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
      – TZakrevskiy
      Jun 28 '14 at 15:28










    • I've edited the OP with the solution using ||x-Pr(x)||
      – Kyle
      Jun 28 '14 at 15:39
















    2












    2








    2






    I'll offer the third method:



    Let the point in that subspace be given by $x (0,1,0,2)+y(1,0,2,0)$. Then the square of the distance to the point $(1, 1, 1, 1)$ can be written as,



    $$(1-y)^2+(1-x)^2+(1-2y)^2+(1-2x)^2$$
    We need to minimize the above expression with respect to $x$ and $y$. Due to symetry, it's sufficient to consider only the minimization
    $$min_x ( (1-x)^2 +(1-2x)^2) =min_x( 5x^2-6x+2).$$
    The minimum is attained at $x=frac 35$ and the minimal value is $frac 15$. Therefore, the square of the minimum distance is $frac 25$ (i.e. the same as you obtained via Gram's determinant).



    It seems that you made some mistakes while calculating $|x-mathrm{Pr}, x|$.






    share|cite|improve this answer














    I'll offer the third method:



    Let the point in that subspace be given by $x (0,1,0,2)+y(1,0,2,0)$. Then the square of the distance to the point $(1, 1, 1, 1)$ can be written as,



    $$(1-y)^2+(1-x)^2+(1-2y)^2+(1-2x)^2$$
    We need to minimize the above expression with respect to $x$ and $y$. Due to symetry, it's sufficient to consider only the minimization
    $$min_x ( (1-x)^2 +(1-2x)^2) =min_x( 5x^2-6x+2).$$
    The minimum is attained at $x=frac 35$ and the minimal value is $frac 15$. Therefore, the square of the minimum distance is $frac 25$ (i.e. the same as you obtained via Gram's determinant).



    It seems that you made some mistakes while calculating $|x-mathrm{Pr}, x|$.







    share|cite|improve this answer














    share|cite|improve this answer



    share|cite|improve this answer








    edited Nov 20 '18 at 11:35









    ijuneja

    1498




    1498










    answered Jun 28 '14 at 15:00









    TZakrevskiy

    20.1k12354




    20.1k12354












    • Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
      – Kyle
      Jun 28 '14 at 15:22










    • @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
      – TZakrevskiy
      Jun 28 '14 at 15:28










    • I've edited the OP with the solution using ||x-Pr(x)||
      – Kyle
      Jun 28 '14 at 15:39




















    • Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
      – Kyle
      Jun 28 '14 at 15:22










    • @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
      – TZakrevskiy
      Jun 28 '14 at 15:28










    • I've edited the OP with the solution using ||x-Pr(x)||
      – Kyle
      Jun 28 '14 at 15:39


















    Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
    – Kyle
    Jun 28 '14 at 15:22




    Interesting, although I asked a few of my friends who solved this question and they all told me the answer was sqrt(2) and they used ||x-Pr(x)|| to calculate it, I can't find a mistake I made in my solution using ||x-Pr(x)||, really weird..
    – Kyle
    Jun 28 '14 at 15:22












    @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
    – TZakrevskiy
    Jun 28 '14 at 15:28




    @Kyle If you write the details on how you calculate the projector, we can look into details and find where the error comes from.
    – TZakrevskiy
    Jun 28 '14 at 15:28












    I've edited the OP with the solution using ||x-Pr(x)||
    – Kyle
    Jun 28 '14 at 15:39






    I've edited the OP with the solution using ||x-Pr(x)||
    – Kyle
    Jun 28 '14 at 15:39













    2














    This is a geometric view of TZakrevskiy's answer.



    Let $V=operatorname{sp} {v_1,v_2}$. Note that $v_1 bot v_2$ in this problem.



    If $p in V$ minimizes the distance between $x$ and $V$, we have
    $(x-p) bot v_k $ for $k=1,2$.



    Writing $p=sum_k alpha_k v_k$ and using orthogonality, we obtain
    $alpha_k = { langle x , v_k rangle over |v_k|^2} = { 3 over 5}$.



    Substituting gives $|x-p| = sqrt{2 over 5}$






    share|cite|improve this answer




























      2














      This is a geometric view of TZakrevskiy's answer.



      Let $V=operatorname{sp} {v_1,v_2}$. Note that $v_1 bot v_2$ in this problem.



      If $p in V$ minimizes the distance between $x$ and $V$, we have
      $(x-p) bot v_k $ for $k=1,2$.



      Writing $p=sum_k alpha_k v_k$ and using orthogonality, we obtain
      $alpha_k = { langle x , v_k rangle over |v_k|^2} = { 3 over 5}$.



      Substituting gives $|x-p| = sqrt{2 over 5}$






      share|cite|improve this answer


























        2












        2








        2






        This is a geometric view of TZakrevskiy's answer.



        Let $V=operatorname{sp} {v_1,v_2}$. Note that $v_1 bot v_2$ in this problem.



        If $p in V$ minimizes the distance between $x$ and $V$, we have
        $(x-p) bot v_k $ for $k=1,2$.



        Writing $p=sum_k alpha_k v_k$ and using orthogonality, we obtain
        $alpha_k = { langle x , v_k rangle over |v_k|^2} = { 3 over 5}$.



        Substituting gives $|x-p| = sqrt{2 over 5}$






        share|cite|improve this answer














        This is a geometric view of TZakrevskiy's answer.



        Let $V=operatorname{sp} {v_1,v_2}$. Note that $v_1 bot v_2$ in this problem.



        If $p in V$ minimizes the distance between $x$ and $V$, we have
        $(x-p) bot v_k $ for $k=1,2$.



        Writing $p=sum_k alpha_k v_k$ and using orthogonality, we obtain
        $alpha_k = { langle x , v_k rangle over |v_k|^2} = { 3 over 5}$.



        Substituting gives $|x-p| = sqrt{2 over 5}$







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Jun 28 '14 at 15:49

























        answered Jun 28 '14 at 15:01









        copper.hat

        126k559159




        126k559159






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f850439%2fdistance-of-a-vector-from-a-subspace-linear-algebra%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$