mystery wave: what to call it?












3












$begingroup$



I recently stumbled on a useful periodic waveform, but I don't know what to call it. It's drawn in blue in the enclosed image, with a sine wave drawn in red for reference. Do you know what to properly call this wave?




plot of mystery wave in blue, with sine wave in red for reference



The most efficient way I've found to generate the wave is by offsetting each quadrant of a sine wave, as in the following C code. The even quadrants are displaced, while the odd quadrants are inverted and displaced.



double MysteryWave(double fPhase)
{
double r = fmod(fPhase + 0.25, 1);
double s = sin(r * PI * 2);
if (r < 0.25)
return s - 1;
else if (r < 0.5)
return 1 - s;
else if (r < 0.75)
return s + 1;
else
return -1 - s;
}


A wave that is very similar but NOT identical to my mystery wave can be generated via the arcsine of the cubed sine, rescaled to $[-1..1]$ by dividing by $pi / 2$. In other words the following function is close but not quite the same:



2 * asin(pow(sin(fPhase * PI * 2), 3)) / PI









share|cite|improve this question











$endgroup$












  • $begingroup$
    So if I understand correctly, each quarter period of your waveform is an actual sine wave, displaced and possibly reflected?
    $endgroup$
    – Arthur
    Oct 17 '17 at 6:32








  • 3




    $begingroup$
    Come up with a name that you like and use it. I don't think there is one already.
    $endgroup$
    – Ivan Neretin
    Oct 17 '17 at 8:29










  • $begingroup$
    In what way is it useful?
    $endgroup$
    – md2perpe
    Oct 17 '17 at 16:13










  • $begingroup$
    What's the context where such a "useful" function appears ?
    $endgroup$
    – Yves Daoust
    Oct 17 '17 at 22:07










  • $begingroup$
    @victimofleisure just a funny curiosity: In this other question, the very last graph shows a waveform similar to yours getting smoother cycle by cycle. math.stackexchange.com/questions/1431415/…
    $endgroup$
    – iadvd
    Oct 18 '17 at 4:41


















3












$begingroup$



I recently stumbled on a useful periodic waveform, but I don't know what to call it. It's drawn in blue in the enclosed image, with a sine wave drawn in red for reference. Do you know what to properly call this wave?




plot of mystery wave in blue, with sine wave in red for reference



The most efficient way I've found to generate the wave is by offsetting each quadrant of a sine wave, as in the following C code. The even quadrants are displaced, while the odd quadrants are inverted and displaced.



double MysteryWave(double fPhase)
{
double r = fmod(fPhase + 0.25, 1);
double s = sin(r * PI * 2);
if (r < 0.25)
return s - 1;
else if (r < 0.5)
return 1 - s;
else if (r < 0.75)
return s + 1;
else
return -1 - s;
}


A wave that is very similar but NOT identical to my mystery wave can be generated via the arcsine of the cubed sine, rescaled to $[-1..1]$ by dividing by $pi / 2$. In other words the following function is close but not quite the same:



2 * asin(pow(sin(fPhase * PI * 2), 3)) / PI









share|cite|improve this question











$endgroup$












  • $begingroup$
    So if I understand correctly, each quarter period of your waveform is an actual sine wave, displaced and possibly reflected?
    $endgroup$
    – Arthur
    Oct 17 '17 at 6:32








  • 3




    $begingroup$
    Come up with a name that you like and use it. I don't think there is one already.
    $endgroup$
    – Ivan Neretin
    Oct 17 '17 at 8:29










  • $begingroup$
    In what way is it useful?
    $endgroup$
    – md2perpe
    Oct 17 '17 at 16:13










  • $begingroup$
    What's the context where such a "useful" function appears ?
    $endgroup$
    – Yves Daoust
    Oct 17 '17 at 22:07










  • $begingroup$
    @victimofleisure just a funny curiosity: In this other question, the very last graph shows a waveform similar to yours getting smoother cycle by cycle. math.stackexchange.com/questions/1431415/…
    $endgroup$
    – iadvd
    Oct 18 '17 at 4:41
















3












3








3


0



$begingroup$



I recently stumbled on a useful periodic waveform, but I don't know what to call it. It's drawn in blue in the enclosed image, with a sine wave drawn in red for reference. Do you know what to properly call this wave?




plot of mystery wave in blue, with sine wave in red for reference



The most efficient way I've found to generate the wave is by offsetting each quadrant of a sine wave, as in the following C code. The even quadrants are displaced, while the odd quadrants are inverted and displaced.



double MysteryWave(double fPhase)
{
double r = fmod(fPhase + 0.25, 1);
double s = sin(r * PI * 2);
if (r < 0.25)
return s - 1;
else if (r < 0.5)
return 1 - s;
else if (r < 0.75)
return s + 1;
else
return -1 - s;
}


A wave that is very similar but NOT identical to my mystery wave can be generated via the arcsine of the cubed sine, rescaled to $[-1..1]$ by dividing by $pi / 2$. In other words the following function is close but not quite the same:



2 * asin(pow(sin(fPhase * PI * 2), 3)) / PI









share|cite|improve this question











$endgroup$





I recently stumbled on a useful periodic waveform, but I don't know what to call it. It's drawn in blue in the enclosed image, with a sine wave drawn in red for reference. Do you know what to properly call this wave?




plot of mystery wave in blue, with sine wave in red for reference



The most efficient way I've found to generate the wave is by offsetting each quadrant of a sine wave, as in the following C code. The even quadrants are displaced, while the odd quadrants are inverted and displaced.



double MysteryWave(double fPhase)
{
double r = fmod(fPhase + 0.25, 1);
double s = sin(r * PI * 2);
if (r < 0.25)
return s - 1;
else if (r < 0.5)
return 1 - s;
else if (r < 0.75)
return s + 1;
else
return -1 - s;
}


A wave that is very similar but NOT identical to my mystery wave can be generated via the arcsine of the cubed sine, rescaled to $[-1..1]$ by dividing by $pi / 2$. In other words the following function is close but not quite the same:



2 * asin(pow(sin(fPhase * PI * 2), 3)) / PI






trigonometry periodic-functions






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Oct 17 '17 at 14:35









iadvd

5,357102656




5,357102656










asked Oct 17 '17 at 5:59









victimofleisurevictimofleisure

162




162












  • $begingroup$
    So if I understand correctly, each quarter period of your waveform is an actual sine wave, displaced and possibly reflected?
    $endgroup$
    – Arthur
    Oct 17 '17 at 6:32








  • 3




    $begingroup$
    Come up with a name that you like and use it. I don't think there is one already.
    $endgroup$
    – Ivan Neretin
    Oct 17 '17 at 8:29










  • $begingroup$
    In what way is it useful?
    $endgroup$
    – md2perpe
    Oct 17 '17 at 16:13










  • $begingroup$
    What's the context where such a "useful" function appears ?
    $endgroup$
    – Yves Daoust
    Oct 17 '17 at 22:07










  • $begingroup$
    @victimofleisure just a funny curiosity: In this other question, the very last graph shows a waveform similar to yours getting smoother cycle by cycle. math.stackexchange.com/questions/1431415/…
    $endgroup$
    – iadvd
    Oct 18 '17 at 4:41




















  • $begingroup$
    So if I understand correctly, each quarter period of your waveform is an actual sine wave, displaced and possibly reflected?
    $endgroup$
    – Arthur
    Oct 17 '17 at 6:32








  • 3




    $begingroup$
    Come up with a name that you like and use it. I don't think there is one already.
    $endgroup$
    – Ivan Neretin
    Oct 17 '17 at 8:29










  • $begingroup$
    In what way is it useful?
    $endgroup$
    – md2perpe
    Oct 17 '17 at 16:13










  • $begingroup$
    What's the context where such a "useful" function appears ?
    $endgroup$
    – Yves Daoust
    Oct 17 '17 at 22:07










  • $begingroup$
    @victimofleisure just a funny curiosity: In this other question, the very last graph shows a waveform similar to yours getting smoother cycle by cycle. math.stackexchange.com/questions/1431415/…
    $endgroup$
    – iadvd
    Oct 18 '17 at 4:41


















$begingroup$
So if I understand correctly, each quarter period of your waveform is an actual sine wave, displaced and possibly reflected?
$endgroup$
– Arthur
Oct 17 '17 at 6:32






$begingroup$
So if I understand correctly, each quarter period of your waveform is an actual sine wave, displaced and possibly reflected?
$endgroup$
– Arthur
Oct 17 '17 at 6:32






3




3




$begingroup$
Come up with a name that you like and use it. I don't think there is one already.
$endgroup$
– Ivan Neretin
Oct 17 '17 at 8:29




$begingroup$
Come up with a name that you like and use it. I don't think there is one already.
$endgroup$
– Ivan Neretin
Oct 17 '17 at 8:29












$begingroup$
In what way is it useful?
$endgroup$
– md2perpe
Oct 17 '17 at 16:13




$begingroup$
In what way is it useful?
$endgroup$
– md2perpe
Oct 17 '17 at 16:13












$begingroup$
What's the context where such a "useful" function appears ?
$endgroup$
– Yves Daoust
Oct 17 '17 at 22:07




$begingroup$
What's the context where such a "useful" function appears ?
$endgroup$
– Yves Daoust
Oct 17 '17 at 22:07












$begingroup$
@victimofleisure just a funny curiosity: In this other question, the very last graph shows a waveform similar to yours getting smoother cycle by cycle. math.stackexchange.com/questions/1431415/…
$endgroup$
– iadvd
Oct 18 '17 at 4:41






$begingroup$
@victimofleisure just a funny curiosity: In this other question, the very last graph shows a waveform similar to yours getting smoother cycle by cycle. math.stackexchange.com/questions/1431415/…
$endgroup$
– iadvd
Oct 18 '17 at 4:41












1 Answer
1






active

oldest

votes


















2












$begingroup$

This is a more direct formula: there are two symmetries happening there, so you need to play with the values assigned to each $frac{pi}{2}$ interval in order to retrieve the correct "mapping" (probably it can be simplified more):




$$sin{[x+pi+[frac{pi}{2}cdot(-1)^{lfloorfrac{x}{pi/2}rfloor}]]}+(-1)^{lfloor{x/pi}rfloor}$$




According to Wolfram Alpha if my calculations are correct it matches your waveform:



enter image description here






share|cite|improve this answer











$endgroup$














    Your Answer








    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%2f2476351%2fmystery-wave-what-to-call-it%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2












    $begingroup$

    This is a more direct formula: there are two symmetries happening there, so you need to play with the values assigned to each $frac{pi}{2}$ interval in order to retrieve the correct "mapping" (probably it can be simplified more):




    $$sin{[x+pi+[frac{pi}{2}cdot(-1)^{lfloorfrac{x}{pi/2}rfloor}]]}+(-1)^{lfloor{x/pi}rfloor}$$




    According to Wolfram Alpha if my calculations are correct it matches your waveform:



    enter image description here






    share|cite|improve this answer











    $endgroup$


















      2












      $begingroup$

      This is a more direct formula: there are two symmetries happening there, so you need to play with the values assigned to each $frac{pi}{2}$ interval in order to retrieve the correct "mapping" (probably it can be simplified more):




      $$sin{[x+pi+[frac{pi}{2}cdot(-1)^{lfloorfrac{x}{pi/2}rfloor}]]}+(-1)^{lfloor{x/pi}rfloor}$$




      According to Wolfram Alpha if my calculations are correct it matches your waveform:



      enter image description here






      share|cite|improve this answer











      $endgroup$
















        2












        2








        2





        $begingroup$

        This is a more direct formula: there are two symmetries happening there, so you need to play with the values assigned to each $frac{pi}{2}$ interval in order to retrieve the correct "mapping" (probably it can be simplified more):




        $$sin{[x+pi+[frac{pi}{2}cdot(-1)^{lfloorfrac{x}{pi/2}rfloor}]]}+(-1)^{lfloor{x/pi}rfloor}$$




        According to Wolfram Alpha if my calculations are correct it matches your waveform:



        enter image description here






        share|cite|improve this answer











        $endgroup$



        This is a more direct formula: there are two symmetries happening there, so you need to play with the values assigned to each $frac{pi}{2}$ interval in order to retrieve the correct "mapping" (probably it can be simplified more):




        $$sin{[x+pi+[frac{pi}{2}cdot(-1)^{lfloorfrac{x}{pi/2}rfloor}]]}+(-1)^{lfloor{x/pi}rfloor}$$




        According to Wolfram Alpha if my calculations are correct it matches your waveform:



        enter image description here







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Oct 17 '17 at 21:49

























        answered Oct 17 '17 at 8:36









        iadvdiadvd

        5,357102656




        5,357102656






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2476351%2fmystery-wave-what-to-call-it%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

            Bressuire

            Cabo Verde

            Gyllenstierna