Limits and While Loops

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite













Question: Consider the following program. Does $f(1)=0$?



beginalign*
f(i):=&|textwhile frac1i>0\
&||ileftarrow i+1\
&|i
endalign*




I would say that $f(1)=0$ is a true statement. The program does not terminate, but one could consider the sequence of points $x_i_iin mathbbN$ given by $x_i:=frac1i$, so that $x_i_iin mathbbN$ converges to the limit $0$ which makes $underbracefrac1i_=0>0$ false which means $f(1)=0$. However, I could be wrong.










share|cite|improve this question























  • The line $||ileftarrow i+1$ add 1 to the original variable $i$?
    – gimusi
    27 mins ago






  • 1




    Yes, that is exactly what that means. So, $frac11>0$ is true in the beginning so then we add $1$ to $i$ which looking at the precondition we know $frac12>0$ is true. This loop continues over and over until the statement is false.
    – W. G.
    24 mins ago














up vote
1
down vote

favorite













Question: Consider the following program. Does $f(1)=0$?



beginalign*
f(i):=&|textwhile frac1i>0\
&||ileftarrow i+1\
&|i
endalign*




I would say that $f(1)=0$ is a true statement. The program does not terminate, but one could consider the sequence of points $x_i_iin mathbbN$ given by $x_i:=frac1i$, so that $x_i_iin mathbbN$ converges to the limit $0$ which makes $underbracefrac1i_=0>0$ false which means $f(1)=0$. However, I could be wrong.










share|cite|improve this question























  • The line $||ileftarrow i+1$ add 1 to the original variable $i$?
    – gimusi
    27 mins ago






  • 1




    Yes, that is exactly what that means. So, $frac11>0$ is true in the beginning so then we add $1$ to $i$ which looking at the precondition we know $frac12>0$ is true. This loop continues over and over until the statement is false.
    – W. G.
    24 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite












Question: Consider the following program. Does $f(1)=0$?



beginalign*
f(i):=&|textwhile frac1i>0\
&||ileftarrow i+1\
&|i
endalign*




I would say that $f(1)=0$ is a true statement. The program does not terminate, but one could consider the sequence of points $x_i_iin mathbbN$ given by $x_i:=frac1i$, so that $x_i_iin mathbbN$ converges to the limit $0$ which makes $underbracefrac1i_=0>0$ false which means $f(1)=0$. However, I could be wrong.










share|cite|improve this question
















Question: Consider the following program. Does $f(1)=0$?



beginalign*
f(i):=&|textwhile frac1i>0\
&||ileftarrow i+1\
&|i
endalign*




I would say that $f(1)=0$ is a true statement. The program does not terminate, but one could consider the sequence of points $x_i_iin mathbbN$ given by $x_i:=frac1i$, so that $x_i_iin mathbbN$ converges to the limit $0$ which makes $underbracefrac1i_=0>0$ false which means $f(1)=0$. However, I could be wrong.







limits programming






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited 24 mins ago









lioness99a

3,6382527




3,6382527










asked 33 mins ago









W. G.

5131416




5131416











  • The line $||ileftarrow i+1$ add 1 to the original variable $i$?
    – gimusi
    27 mins ago






  • 1




    Yes, that is exactly what that means. So, $frac11>0$ is true in the beginning so then we add $1$ to $i$ which looking at the precondition we know $frac12>0$ is true. This loop continues over and over until the statement is false.
    – W. G.
    24 mins ago
















  • The line $||ileftarrow i+1$ add 1 to the original variable $i$?
    – gimusi
    27 mins ago






  • 1




    Yes, that is exactly what that means. So, $frac11>0$ is true in the beginning so then we add $1$ to $i$ which looking at the precondition we know $frac12>0$ is true. This loop continues over and over until the statement is false.
    – W. G.
    24 mins ago















The line $||ileftarrow i+1$ add 1 to the original variable $i$?
– gimusi
27 mins ago




The line $||ileftarrow i+1$ add 1 to the original variable $i$?
– gimusi
27 mins ago




1




1




Yes, that is exactly what that means. So, $frac11>0$ is true in the beginning so then we add $1$ to $i$ which looking at the precondition we know $frac12>0$ is true. This loop continues over and over until the statement is false.
– W. G.
24 mins ago




Yes, that is exactly what that means. So, $frac11>0$ is true in the beginning so then we add $1$ to $i$ which looking at the precondition we know $frac12>0$ is true. This loop continues over and over until the statement is false.
– W. G.
24 mins ago










3 Answers
3






active

oldest

votes

















up vote
2
down vote













The only thing we can say here is that $f(1)$ is not defined, or that the program does not terminate for the input $1$.



We cannot say that $f(1)=0$.






share|cite|improve this answer




















  • If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
    – W. G.
    16 mins ago







  • 1




    @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
    – 5xum
    11 mins ago











  • I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
    – W. G.
    40 secs ago


















up vote
1
down vote













It's a bit of a funny question. Looks like the best answer is "no." The number $1$ is not in the domain of $f$, because the program doesn't terminate.



It's true that as a human we can see that the in-memory value of $1/i$ is headed toward $0$, but $f$ was never going to return $1/i$, it was going to return $i$, which is headed off to $infty$. Even if it were going to return $1/i$, the answer still shouldn't be $0$, because the program doesn't terminate and there's no notion of a limiting operation made explicit here.






share|cite|improve this answer



























    up vote
    0
    down vote













    The function is undefined at $i=1$ since $not exists b$ such that $b=f(1)$.



    For a fromal proof, indicating with $i_k$ the value assumed by $i$ at the $k^th$ loop, we can show by induction that $forall k$



    • $i_kge 1 implies frac 1i_k>0$

    therefore the loop will never end.



    More in general $f(i)$ is undefined for any $i>0$ and $f(i)=i$ for any $i< 0$.



    For $i=0$ it depends on how the "while" command returns to the operation $1/0$.






    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',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      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%2f2928866%2flimits-and-while-loops%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      The only thing we can say here is that $f(1)$ is not defined, or that the program does not terminate for the input $1$.



      We cannot say that $f(1)=0$.






      share|cite|improve this answer




















      • If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
        – W. G.
        16 mins ago







      • 1




        @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
        – 5xum
        11 mins ago











      • I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
        – W. G.
        40 secs ago















      up vote
      2
      down vote













      The only thing we can say here is that $f(1)$ is not defined, or that the program does not terminate for the input $1$.



      We cannot say that $f(1)=0$.






      share|cite|improve this answer




















      • If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
        – W. G.
        16 mins ago







      • 1




        @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
        – 5xum
        11 mins ago











      • I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
        – W. G.
        40 secs ago













      up vote
      2
      down vote










      up vote
      2
      down vote









      The only thing we can say here is that $f(1)$ is not defined, or that the program does not terminate for the input $1$.



      We cannot say that $f(1)=0$.






      share|cite|improve this answer












      The only thing we can say here is that $f(1)$ is not defined, or that the program does not terminate for the input $1$.



      We cannot say that $f(1)=0$.







      share|cite|improve this answer












      share|cite|improve this answer



      share|cite|improve this answer










      answered 27 mins ago









      5xum

      83.4k384148




      83.4k384148











      • If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
        – W. G.
        16 mins ago







      • 1




        @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
        – 5xum
        11 mins ago











      • I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
        – W. G.
        40 secs ago

















      • If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
        – W. G.
        16 mins ago







      • 1




        @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
        – 5xum
        11 mins ago











      • I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
        – W. G.
        40 secs ago
















      If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
      – W. G.
      16 mins ago





      If I understand this correctly, the term "total correctness" of the program requires the program to terminate which is often considered in proofs. However, why is that $f(1)$ is not defined in the mathematical sense? Is it required to finite?
      – W. G.
      16 mins ago





      1




      1




      @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
      – 5xum
      11 mins ago





      @W.G. $f(1)$ is not defined because $f$ does not terminate for the input $1$. It's as simple as that.
      – 5xum
      11 mins ago













      I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
      – W. G.
      40 secs ago





      I am not trying to rock the boat here or anything, but I agree that the program does not terminate. Any computer would say that $f(1)$ makes no sense . However, we know that the loop continues on forever. Every iteration, can be proved inductively to show that $frac1i$ is false. Thus, the loop must go on forever. If the loop was finite, the program clearly would not exist as $frac1i>0$ would be false. As the loop goes on to infinity, why can't we assume $i$ goes to infinity?
      – W. G.
      40 secs ago











      up vote
      1
      down vote













      It's a bit of a funny question. Looks like the best answer is "no." The number $1$ is not in the domain of $f$, because the program doesn't terminate.



      It's true that as a human we can see that the in-memory value of $1/i$ is headed toward $0$, but $f$ was never going to return $1/i$, it was going to return $i$, which is headed off to $infty$. Even if it were going to return $1/i$, the answer still shouldn't be $0$, because the program doesn't terminate and there's no notion of a limiting operation made explicit here.






      share|cite|improve this answer
























        up vote
        1
        down vote













        It's a bit of a funny question. Looks like the best answer is "no." The number $1$ is not in the domain of $f$, because the program doesn't terminate.



        It's true that as a human we can see that the in-memory value of $1/i$ is headed toward $0$, but $f$ was never going to return $1/i$, it was going to return $i$, which is headed off to $infty$. Even if it were going to return $1/i$, the answer still shouldn't be $0$, because the program doesn't terminate and there's no notion of a limiting operation made explicit here.






        share|cite|improve this answer






















          up vote
          1
          down vote










          up vote
          1
          down vote









          It's a bit of a funny question. Looks like the best answer is "no." The number $1$ is not in the domain of $f$, because the program doesn't terminate.



          It's true that as a human we can see that the in-memory value of $1/i$ is headed toward $0$, but $f$ was never going to return $1/i$, it was going to return $i$, which is headed off to $infty$. Even if it were going to return $1/i$, the answer still shouldn't be $0$, because the program doesn't terminate and there's no notion of a limiting operation made explicit here.






          share|cite|improve this answer












          It's a bit of a funny question. Looks like the best answer is "no." The number $1$ is not in the domain of $f$, because the program doesn't terminate.



          It's true that as a human we can see that the in-memory value of $1/i$ is headed toward $0$, but $f$ was never going to return $1/i$, it was going to return $i$, which is headed off to $infty$. Even if it were going to return $1/i$, the answer still shouldn't be $0$, because the program doesn't terminate and there's no notion of a limiting operation made explicit here.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered 27 mins ago









          hunter

          13.3k22337




          13.3k22337




















              up vote
              0
              down vote













              The function is undefined at $i=1$ since $not exists b$ such that $b=f(1)$.



              For a fromal proof, indicating with $i_k$ the value assumed by $i$ at the $k^th$ loop, we can show by induction that $forall k$



              • $i_kge 1 implies frac 1i_k>0$

              therefore the loop will never end.



              More in general $f(i)$ is undefined for any $i>0$ and $f(i)=i$ for any $i< 0$.



              For $i=0$ it depends on how the "while" command returns to the operation $1/0$.






              share|cite|improve this answer


























                up vote
                0
                down vote













                The function is undefined at $i=1$ since $not exists b$ such that $b=f(1)$.



                For a fromal proof, indicating with $i_k$ the value assumed by $i$ at the $k^th$ loop, we can show by induction that $forall k$



                • $i_kge 1 implies frac 1i_k>0$

                therefore the loop will never end.



                More in general $f(i)$ is undefined for any $i>0$ and $f(i)=i$ for any $i< 0$.



                For $i=0$ it depends on how the "while" command returns to the operation $1/0$.






                share|cite|improve this answer
























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  The function is undefined at $i=1$ since $not exists b$ such that $b=f(1)$.



                  For a fromal proof, indicating with $i_k$ the value assumed by $i$ at the $k^th$ loop, we can show by induction that $forall k$



                  • $i_kge 1 implies frac 1i_k>0$

                  therefore the loop will never end.



                  More in general $f(i)$ is undefined for any $i>0$ and $f(i)=i$ for any $i< 0$.



                  For $i=0$ it depends on how the "while" command returns to the operation $1/0$.






                  share|cite|improve this answer














                  The function is undefined at $i=1$ since $not exists b$ such that $b=f(1)$.



                  For a fromal proof, indicating with $i_k$ the value assumed by $i$ at the $k^th$ loop, we can show by induction that $forall k$



                  • $i_kge 1 implies frac 1i_k>0$

                  therefore the loop will never end.



                  More in general $f(i)$ is undefined for any $i>0$ and $f(i)=i$ for any $i< 0$.



                  For $i=0$ it depends on how the "while" command returns to the operation $1/0$.







                  share|cite|improve this answer














                  share|cite|improve this answer



                  share|cite|improve this answer








                  edited 10 mins ago

























                  answered 22 mins ago









                  gimusi

                  74.7k73889




                  74.7k73889



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2928866%2flimits-and-while-loops%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery