Constructing a 2-periodic extension of the absolute value function using floor and ceiling functions











up vote
0
down vote

favorite












I am trying to use floor and ceiling functions to construct a 2-periodic extension of the function $f(x) = |x|, -1 leq x leq 1$.



Through trial an error I have been able to show that:



$f(x) = 1 - bigg( lfloor x rfloor - 2 lfloor frac{lfloor x rfloor}{2} rfloor)(x - lfloor x rfloor) + (lfloor x-1 rfloor - 2lfloor{frac{lfloor x-1 rfloor}{2}}rfloor)(lceil x-1 rceil -(x-1)bigg)$



However, this formula does not work when $x$ is an even integer since it gives 1 instead of 0.



Is there an easier way to do this?










share|cite|improve this question


























    up vote
    0
    down vote

    favorite












    I am trying to use floor and ceiling functions to construct a 2-periodic extension of the function $f(x) = |x|, -1 leq x leq 1$.



    Through trial an error I have been able to show that:



    $f(x) = 1 - bigg( lfloor x rfloor - 2 lfloor frac{lfloor x rfloor}{2} rfloor)(x - lfloor x rfloor) + (lfloor x-1 rfloor - 2lfloor{frac{lfloor x-1 rfloor}{2}}rfloor)(lceil x-1 rceil -(x-1)bigg)$



    However, this formula does not work when $x$ is an even integer since it gives 1 instead of 0.



    Is there an easier way to do this?










    share|cite|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to use floor and ceiling functions to construct a 2-periodic extension of the function $f(x) = |x|, -1 leq x leq 1$.



      Through trial an error I have been able to show that:



      $f(x) = 1 - bigg( lfloor x rfloor - 2 lfloor frac{lfloor x rfloor}{2} rfloor)(x - lfloor x rfloor) + (lfloor x-1 rfloor - 2lfloor{frac{lfloor x-1 rfloor}{2}}rfloor)(lceil x-1 rceil -(x-1)bigg)$



      However, this formula does not work when $x$ is an even integer since it gives 1 instead of 0.



      Is there an easier way to do this?










      share|cite|improve this question













      I am trying to use floor and ceiling functions to construct a 2-periodic extension of the function $f(x) = |x|, -1 leq x leq 1$.



      Through trial an error I have been able to show that:



      $f(x) = 1 - bigg( lfloor x rfloor - 2 lfloor frac{lfloor x rfloor}{2} rfloor)(x - lfloor x rfloor) + (lfloor x-1 rfloor - 2lfloor{frac{lfloor x-1 rfloor}{2}}rfloor)(lceil x-1 rceil -(x-1)bigg)$



      However, this formula does not work when $x$ is an even integer since it gives 1 instead of 0.



      Is there an easier way to do this?







      floor-function ceiling-function






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked 16 hours ago









      1123581321

      10017




      10017






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          If you can also use trigonometric functions, then there are several ways to do it.



          If we can construct a graph like the following, which I will call $r(x)$ then $f(x)=r(x)+r(-x)$ will almost be what you want depending whether or not $f(2k)=1$ and $f(2k+1)=0$ for all integers $k$.



          r(x)



          First, let us create a periodic "cutting" function



          $$ c(x)=lfloor1+sinpi xrfloor $$



          Fig3



          Now look at the graph of



          $$ g(x)=lceil xrceil-x $$



          Fig2



          If we multiply $g(x)$ and $c(x)$ we will get a function whose graph looks like the first graph above. So we define



          begin{eqnarray}
          r(x)&=&g(x)c(x)\
          &=&(lceil xrceil-x)lfloor1+sinpi xrfloor
          end{eqnarray}



          And let



          begin{eqnarray}
          f_0(x)&=&r(x)+r(-x)\
          &=&(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor
          end{eqnarray}



          This function has the following graph



          Fig4



          This is almost what we want, but we need to correct the missing points by adding a function which equals one for all even integers and equals zero elsewhere. A function such as



          $$ c(x)=leftlfloorfrac{1+cospi x}{2}rightrfloor $$



          So we define



          $$ f(x)=(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor+leftlfloorfrac{1+cospi x}{2}rightrfloor $$






          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: 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%2f2995900%2fconstructing-a-2-periodic-extension-of-the-absolute-value-function-using-floor-a%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            If you can also use trigonometric functions, then there are several ways to do it.



            If we can construct a graph like the following, which I will call $r(x)$ then $f(x)=r(x)+r(-x)$ will almost be what you want depending whether or not $f(2k)=1$ and $f(2k+1)=0$ for all integers $k$.



            r(x)



            First, let us create a periodic "cutting" function



            $$ c(x)=lfloor1+sinpi xrfloor $$



            Fig3



            Now look at the graph of



            $$ g(x)=lceil xrceil-x $$



            Fig2



            If we multiply $g(x)$ and $c(x)$ we will get a function whose graph looks like the first graph above. So we define



            begin{eqnarray}
            r(x)&=&g(x)c(x)\
            &=&(lceil xrceil-x)lfloor1+sinpi xrfloor
            end{eqnarray}



            And let



            begin{eqnarray}
            f_0(x)&=&r(x)+r(-x)\
            &=&(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor
            end{eqnarray}



            This function has the following graph



            Fig4



            This is almost what we want, but we need to correct the missing points by adding a function which equals one for all even integers and equals zero elsewhere. A function such as



            $$ c(x)=leftlfloorfrac{1+cospi x}{2}rightrfloor $$



            So we define



            $$ f(x)=(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor+leftlfloorfrac{1+cospi x}{2}rightrfloor $$






            share|cite|improve this answer

























              up vote
              0
              down vote













              If you can also use trigonometric functions, then there are several ways to do it.



              If we can construct a graph like the following, which I will call $r(x)$ then $f(x)=r(x)+r(-x)$ will almost be what you want depending whether or not $f(2k)=1$ and $f(2k+1)=0$ for all integers $k$.



              r(x)



              First, let us create a periodic "cutting" function



              $$ c(x)=lfloor1+sinpi xrfloor $$



              Fig3



              Now look at the graph of



              $$ g(x)=lceil xrceil-x $$



              Fig2



              If we multiply $g(x)$ and $c(x)$ we will get a function whose graph looks like the first graph above. So we define



              begin{eqnarray}
              r(x)&=&g(x)c(x)\
              &=&(lceil xrceil-x)lfloor1+sinpi xrfloor
              end{eqnarray}



              And let



              begin{eqnarray}
              f_0(x)&=&r(x)+r(-x)\
              &=&(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor
              end{eqnarray}



              This function has the following graph



              Fig4



              This is almost what we want, but we need to correct the missing points by adding a function which equals one for all even integers and equals zero elsewhere. A function such as



              $$ c(x)=leftlfloorfrac{1+cospi x}{2}rightrfloor $$



              So we define



              $$ f(x)=(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor+leftlfloorfrac{1+cospi x}{2}rightrfloor $$






              share|cite|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                If you can also use trigonometric functions, then there are several ways to do it.



                If we can construct a graph like the following, which I will call $r(x)$ then $f(x)=r(x)+r(-x)$ will almost be what you want depending whether or not $f(2k)=1$ and $f(2k+1)=0$ for all integers $k$.



                r(x)



                First, let us create a periodic "cutting" function



                $$ c(x)=lfloor1+sinpi xrfloor $$



                Fig3



                Now look at the graph of



                $$ g(x)=lceil xrceil-x $$



                Fig2



                If we multiply $g(x)$ and $c(x)$ we will get a function whose graph looks like the first graph above. So we define



                begin{eqnarray}
                r(x)&=&g(x)c(x)\
                &=&(lceil xrceil-x)lfloor1+sinpi xrfloor
                end{eqnarray}



                And let



                begin{eqnarray}
                f_0(x)&=&r(x)+r(-x)\
                &=&(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor
                end{eqnarray}



                This function has the following graph



                Fig4



                This is almost what we want, but we need to correct the missing points by adding a function which equals one for all even integers and equals zero elsewhere. A function such as



                $$ c(x)=leftlfloorfrac{1+cospi x}{2}rightrfloor $$



                So we define



                $$ f(x)=(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor+leftlfloorfrac{1+cospi x}{2}rightrfloor $$






                share|cite|improve this answer












                If you can also use trigonometric functions, then there are several ways to do it.



                If we can construct a graph like the following, which I will call $r(x)$ then $f(x)=r(x)+r(-x)$ will almost be what you want depending whether or not $f(2k)=1$ and $f(2k+1)=0$ for all integers $k$.



                r(x)



                First, let us create a periodic "cutting" function



                $$ c(x)=lfloor1+sinpi xrfloor $$



                Fig3



                Now look at the graph of



                $$ g(x)=lceil xrceil-x $$



                Fig2



                If we multiply $g(x)$ and $c(x)$ we will get a function whose graph looks like the first graph above. So we define



                begin{eqnarray}
                r(x)&=&g(x)c(x)\
                &=&(lceil xrceil-x)lfloor1+sinpi xrfloor
                end{eqnarray}



                And let



                begin{eqnarray}
                f_0(x)&=&r(x)+r(-x)\
                &=&(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor
                end{eqnarray}



                This function has the following graph



                Fig4



                This is almost what we want, but we need to correct the missing points by adding a function which equals one for all even integers and equals zero elsewhere. A function such as



                $$ c(x)=leftlfloorfrac{1+cospi x}{2}rightrfloor $$



                So we define



                $$ f(x)=(lceil xrceil-x)lfloor1+sinpi xrfloor+(lceil -xrceil+x)lfloor1-sinpi xrfloor+leftlfloorfrac{1+cospi x}{2}rightrfloor $$







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered 4 hours ago









                John Wayland Bales

                13.7k21137




                13.7k21137






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2995900%2fconstructing-a-2-periodic-extension-of-the-absolute-value-function-using-floor-a%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix