Smooth transition between functions












1












$begingroup$


Therefor that I don't really have a mathematical background, it is kind of difficult to me, to describe what I'm looking for (but I'll give it a try):



I'm looking for a way to parameterize a function to fulfill the following constraints:




  • function is a typical $y=f(x)$

  • lets call the parameter $p$

  • the following three coordinates shall be fixed: $f(0)=0$; $f(-100)=-100$; $f(100)=100$


  • $p$ shall have 100 valid values $([0-99];[1-100])$


now it comes to the tricky part:




  • when 'p' has its minimum value; I want $f(x)$ to be $x^2$

  • now with p increasing, I need f(x) become more and more bulgy like a $x^3$


I tried to separate the range from 1-3 in 100steps for $p$, and tried to use $y=x^p$, but that misses a lot of the above constraints (p.e. I never want the function to be $x^2$)



Maybe it becomes a little clearer, if you know what I need this for:
I want to program an configurable exponential transmission for a computergame. If you set the parameter to the minimum, the transmission is 1:1 (a movement of a joystick by one, results in a in_game_change of the value by one. If you want maximum exponential control, you need to move the joystick a lot more, before you reach a change of the in_game_value (reduced sensitivity). But in every case, 100% joystick_movement shall result in a 100% ingame_change (thats why I need the three coordinates to be fixed).



I hope I could make clear what I'm looking for, and will be very glad if someone could point me to the right idea.
Thanks in advance :)










share|cite|improve this question











$endgroup$












  • $begingroup$
    Welcome to MSE. You should choose your tags carefully. What has this to do with exponential-function?
    $endgroup$
    – José Carlos Santos
    Jan 23 at 9:37










  • $begingroup$
    isn't it? I'm sorry, but I haven't had anything to do with math for years. Please feel free to edit/correct my question to make it more clear
    $endgroup$
    – Tom Mekken
    Jan 23 at 9:41
















1












$begingroup$


Therefor that I don't really have a mathematical background, it is kind of difficult to me, to describe what I'm looking for (but I'll give it a try):



I'm looking for a way to parameterize a function to fulfill the following constraints:




  • function is a typical $y=f(x)$

  • lets call the parameter $p$

  • the following three coordinates shall be fixed: $f(0)=0$; $f(-100)=-100$; $f(100)=100$


  • $p$ shall have 100 valid values $([0-99];[1-100])$


now it comes to the tricky part:




  • when 'p' has its minimum value; I want $f(x)$ to be $x^2$

  • now with p increasing, I need f(x) become more and more bulgy like a $x^3$


I tried to separate the range from 1-3 in 100steps for $p$, and tried to use $y=x^p$, but that misses a lot of the above constraints (p.e. I never want the function to be $x^2$)



Maybe it becomes a little clearer, if you know what I need this for:
I want to program an configurable exponential transmission for a computergame. If you set the parameter to the minimum, the transmission is 1:1 (a movement of a joystick by one, results in a in_game_change of the value by one. If you want maximum exponential control, you need to move the joystick a lot more, before you reach a change of the in_game_value (reduced sensitivity). But in every case, 100% joystick_movement shall result in a 100% ingame_change (thats why I need the three coordinates to be fixed).



I hope I could make clear what I'm looking for, and will be very glad if someone could point me to the right idea.
Thanks in advance :)










share|cite|improve this question











$endgroup$












  • $begingroup$
    Welcome to MSE. You should choose your tags carefully. What has this to do with exponential-function?
    $endgroup$
    – José Carlos Santos
    Jan 23 at 9:37










  • $begingroup$
    isn't it? I'm sorry, but I haven't had anything to do with math for years. Please feel free to edit/correct my question to make it more clear
    $endgroup$
    – Tom Mekken
    Jan 23 at 9:41














1












1








1


0



$begingroup$


Therefor that I don't really have a mathematical background, it is kind of difficult to me, to describe what I'm looking for (but I'll give it a try):



I'm looking for a way to parameterize a function to fulfill the following constraints:




  • function is a typical $y=f(x)$

  • lets call the parameter $p$

  • the following three coordinates shall be fixed: $f(0)=0$; $f(-100)=-100$; $f(100)=100$


  • $p$ shall have 100 valid values $([0-99];[1-100])$


now it comes to the tricky part:




  • when 'p' has its minimum value; I want $f(x)$ to be $x^2$

  • now with p increasing, I need f(x) become more and more bulgy like a $x^3$


I tried to separate the range from 1-3 in 100steps for $p$, and tried to use $y=x^p$, but that misses a lot of the above constraints (p.e. I never want the function to be $x^2$)



Maybe it becomes a little clearer, if you know what I need this for:
I want to program an configurable exponential transmission for a computergame. If you set the parameter to the minimum, the transmission is 1:1 (a movement of a joystick by one, results in a in_game_change of the value by one. If you want maximum exponential control, you need to move the joystick a lot more, before you reach a change of the in_game_value (reduced sensitivity). But in every case, 100% joystick_movement shall result in a 100% ingame_change (thats why I need the three coordinates to be fixed).



I hope I could make clear what I'm looking for, and will be very glad if someone could point me to the right idea.
Thanks in advance :)










share|cite|improve this question











$endgroup$




Therefor that I don't really have a mathematical background, it is kind of difficult to me, to describe what I'm looking for (but I'll give it a try):



I'm looking for a way to parameterize a function to fulfill the following constraints:




  • function is a typical $y=f(x)$

  • lets call the parameter $p$

  • the following three coordinates shall be fixed: $f(0)=0$; $f(-100)=-100$; $f(100)=100$


  • $p$ shall have 100 valid values $([0-99];[1-100])$


now it comes to the tricky part:




  • when 'p' has its minimum value; I want $f(x)$ to be $x^2$

  • now with p increasing, I need f(x) become more and more bulgy like a $x^3$


I tried to separate the range from 1-3 in 100steps for $p$, and tried to use $y=x^p$, but that misses a lot of the above constraints (p.e. I never want the function to be $x^2$)



Maybe it becomes a little clearer, if you know what I need this for:
I want to program an configurable exponential transmission for a computergame. If you set the parameter to the minimum, the transmission is 1:1 (a movement of a joystick by one, results in a in_game_change of the value by one. If you want maximum exponential control, you need to move the joystick a lot more, before you reach a change of the in_game_value (reduced sensitivity). But in every case, 100% joystick_movement shall result in a 100% ingame_change (thats why I need the three coordinates to be fixed).



I hope I could make clear what I'm looking for, and will be very glad if someone could point me to the right idea.
Thanks in advance :)







exponentiation






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 23 at 18:31









caverac

14.8k31130




14.8k31130










asked Jan 23 at 9:34









Tom MekkenTom Mekken

1083




1083












  • $begingroup$
    Welcome to MSE. You should choose your tags carefully. What has this to do with exponential-function?
    $endgroup$
    – José Carlos Santos
    Jan 23 at 9:37










  • $begingroup$
    isn't it? I'm sorry, but I haven't had anything to do with math for years. Please feel free to edit/correct my question to make it more clear
    $endgroup$
    – Tom Mekken
    Jan 23 at 9:41


















  • $begingroup$
    Welcome to MSE. You should choose your tags carefully. What has this to do with exponential-function?
    $endgroup$
    – José Carlos Santos
    Jan 23 at 9:37










  • $begingroup$
    isn't it? I'm sorry, but I haven't had anything to do with math for years. Please feel free to edit/correct my question to make it more clear
    $endgroup$
    – Tom Mekken
    Jan 23 at 9:41
















$begingroup$
Welcome to MSE. You should choose your tags carefully. What has this to do with exponential-function?
$endgroup$
– José Carlos Santos
Jan 23 at 9:37




$begingroup$
Welcome to MSE. You should choose your tags carefully. What has this to do with exponential-function?
$endgroup$
– José Carlos Santos
Jan 23 at 9:37












$begingroup$
isn't it? I'm sorry, but I haven't had anything to do with math for years. Please feel free to edit/correct my question to make it more clear
$endgroup$
– Tom Mekken
Jan 23 at 9:41




$begingroup$
isn't it? I'm sorry, but I haven't had anything to do with math for years. Please feel free to edit/correct my question to make it more clear
$endgroup$
– Tom Mekken
Jan 23 at 9:41










2 Answers
2






active

oldest

votes


















1












$begingroup$

Define the functions



begin{align}
g_1(x) &= x \
g_2(x) &= 100 (x/100)^3
end{align}



Now define



$$
sigma(p) = frac{2}{1 + e^{-p/30}}-1
$$



The number 30 is kind of arbitrary, it just tells you how fast you want the transition between $g_1$ and $g_2$ to occur. Small means fast. One option is



$$
f_p(x) = g_1(x) + [g_2(x) - g_1(x)]sigma(p)
$$



Here is the result



enter image description here






share|cite|improve this answer









$endgroup$













  • $begingroup$
    this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
    $endgroup$
    – Tom Mekken
    Jan 23 at 11:32










  • $begingroup$
    @TomMekken I used LaTeX for this, but it can be done in a few lines with python
    $endgroup$
    – caverac
    Jan 23 at 12:55



















0












$begingroup$

You could set $f_p(x)=mathrm{sgn}(x)|x|^p$ for $1leq pleq 3$, where $mathrm{sgn}(x)$ is the sign of $x$ and $|x|$ is the absolute value of $x$. This reduces to the desired $x^p$ when $xgeq0$, with the added benefit of being an odd function, so for example $f(-1)=-1$.



Or, you can try linear interpolation between two functions, as in $f_p(x)=(1-p)x+px^3$ for $0leq pleq 1$. This may look more elegant on paper, but it might not feel as nice in practice, since it doesn't place a dead zone around $x=0$ unless $p$ is very close to $1$.



I assume you want a dead zone to compensate for the discontinuous jump in force that is required for the player's hand to move the joystick away from neutral. In other words, we want the derivative $f'_p(0)=0$ for all $p$ greater than the minimum setting. That's what you'll get with $mathrm{sgn}(x)|x|^p$.






share|cite|improve this answer









$endgroup$













    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%2f3084266%2fsmooth-transition-between-functions%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









    1












    $begingroup$

    Define the functions



    begin{align}
    g_1(x) &= x \
    g_2(x) &= 100 (x/100)^3
    end{align}



    Now define



    $$
    sigma(p) = frac{2}{1 + e^{-p/30}}-1
    $$



    The number 30 is kind of arbitrary, it just tells you how fast you want the transition between $g_1$ and $g_2$ to occur. Small means fast. One option is



    $$
    f_p(x) = g_1(x) + [g_2(x) - g_1(x)]sigma(p)
    $$



    Here is the result



    enter image description here






    share|cite|improve this answer









    $endgroup$













    • $begingroup$
      this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
      $endgroup$
      – Tom Mekken
      Jan 23 at 11:32










    • $begingroup$
      @TomMekken I used LaTeX for this, but it can be done in a few lines with python
      $endgroup$
      – caverac
      Jan 23 at 12:55
















    1












    $begingroup$

    Define the functions



    begin{align}
    g_1(x) &= x \
    g_2(x) &= 100 (x/100)^3
    end{align}



    Now define



    $$
    sigma(p) = frac{2}{1 + e^{-p/30}}-1
    $$



    The number 30 is kind of arbitrary, it just tells you how fast you want the transition between $g_1$ and $g_2$ to occur. Small means fast. One option is



    $$
    f_p(x) = g_1(x) + [g_2(x) - g_1(x)]sigma(p)
    $$



    Here is the result



    enter image description here






    share|cite|improve this answer









    $endgroup$













    • $begingroup$
      this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
      $endgroup$
      – Tom Mekken
      Jan 23 at 11:32










    • $begingroup$
      @TomMekken I used LaTeX for this, but it can be done in a few lines with python
      $endgroup$
      – caverac
      Jan 23 at 12:55














    1












    1








    1





    $begingroup$

    Define the functions



    begin{align}
    g_1(x) &= x \
    g_2(x) &= 100 (x/100)^3
    end{align}



    Now define



    $$
    sigma(p) = frac{2}{1 + e^{-p/30}}-1
    $$



    The number 30 is kind of arbitrary, it just tells you how fast you want the transition between $g_1$ and $g_2$ to occur. Small means fast. One option is



    $$
    f_p(x) = g_1(x) + [g_2(x) - g_1(x)]sigma(p)
    $$



    Here is the result



    enter image description here






    share|cite|improve this answer









    $endgroup$



    Define the functions



    begin{align}
    g_1(x) &= x \
    g_2(x) &= 100 (x/100)^3
    end{align}



    Now define



    $$
    sigma(p) = frac{2}{1 + e^{-p/30}}-1
    $$



    The number 30 is kind of arbitrary, it just tells you how fast you want the transition between $g_1$ and $g_2$ to occur. Small means fast. One option is



    $$
    f_p(x) = g_1(x) + [g_2(x) - g_1(x)]sigma(p)
    $$



    Here is the result



    enter image description here







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Jan 23 at 10:14









    caveraccaverac

    14.8k31130




    14.8k31130












    • $begingroup$
      this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
      $endgroup$
      – Tom Mekken
      Jan 23 at 11:32










    • $begingroup$
      @TomMekken I used LaTeX for this, but it can be done in a few lines with python
      $endgroup$
      – caverac
      Jan 23 at 12:55


















    • $begingroup$
      this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
      $endgroup$
      – Tom Mekken
      Jan 23 at 11:32










    • $begingroup$
      @TomMekken I used LaTeX for this, but it can be done in a few lines with python
      $endgroup$
      – caverac
      Jan 23 at 12:55
















    $begingroup$
    this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
    $endgroup$
    – Tom Mekken
    Jan 23 at 11:32




    $begingroup$
    this is just perfect and exactly what I needed. Thank you :). What kind of program did you use to plot this function dynamically?
    $endgroup$
    – Tom Mekken
    Jan 23 at 11:32












    $begingroup$
    @TomMekken I used LaTeX for this, but it can be done in a few lines with python
    $endgroup$
    – caverac
    Jan 23 at 12:55




    $begingroup$
    @TomMekken I used LaTeX for this, but it can be done in a few lines with python
    $endgroup$
    – caverac
    Jan 23 at 12:55











    0












    $begingroup$

    You could set $f_p(x)=mathrm{sgn}(x)|x|^p$ for $1leq pleq 3$, where $mathrm{sgn}(x)$ is the sign of $x$ and $|x|$ is the absolute value of $x$. This reduces to the desired $x^p$ when $xgeq0$, with the added benefit of being an odd function, so for example $f(-1)=-1$.



    Or, you can try linear interpolation between two functions, as in $f_p(x)=(1-p)x+px^3$ for $0leq pleq 1$. This may look more elegant on paper, but it might not feel as nice in practice, since it doesn't place a dead zone around $x=0$ unless $p$ is very close to $1$.



    I assume you want a dead zone to compensate for the discontinuous jump in force that is required for the player's hand to move the joystick away from neutral. In other words, we want the derivative $f'_p(0)=0$ for all $p$ greater than the minimum setting. That's what you'll get with $mathrm{sgn}(x)|x|^p$.






    share|cite|improve this answer









    $endgroup$


















      0












      $begingroup$

      You could set $f_p(x)=mathrm{sgn}(x)|x|^p$ for $1leq pleq 3$, where $mathrm{sgn}(x)$ is the sign of $x$ and $|x|$ is the absolute value of $x$. This reduces to the desired $x^p$ when $xgeq0$, with the added benefit of being an odd function, so for example $f(-1)=-1$.



      Or, you can try linear interpolation between two functions, as in $f_p(x)=(1-p)x+px^3$ for $0leq pleq 1$. This may look more elegant on paper, but it might not feel as nice in practice, since it doesn't place a dead zone around $x=0$ unless $p$ is very close to $1$.



      I assume you want a dead zone to compensate for the discontinuous jump in force that is required for the player's hand to move the joystick away from neutral. In other words, we want the derivative $f'_p(0)=0$ for all $p$ greater than the minimum setting. That's what you'll get with $mathrm{sgn}(x)|x|^p$.






      share|cite|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$

        You could set $f_p(x)=mathrm{sgn}(x)|x|^p$ for $1leq pleq 3$, where $mathrm{sgn}(x)$ is the sign of $x$ and $|x|$ is the absolute value of $x$. This reduces to the desired $x^p$ when $xgeq0$, with the added benefit of being an odd function, so for example $f(-1)=-1$.



        Or, you can try linear interpolation between two functions, as in $f_p(x)=(1-p)x+px^3$ for $0leq pleq 1$. This may look more elegant on paper, but it might not feel as nice in practice, since it doesn't place a dead zone around $x=0$ unless $p$ is very close to $1$.



        I assume you want a dead zone to compensate for the discontinuous jump in force that is required for the player's hand to move the joystick away from neutral. In other words, we want the derivative $f'_p(0)=0$ for all $p$ greater than the minimum setting. That's what you'll get with $mathrm{sgn}(x)|x|^p$.






        share|cite|improve this answer









        $endgroup$



        You could set $f_p(x)=mathrm{sgn}(x)|x|^p$ for $1leq pleq 3$, where $mathrm{sgn}(x)$ is the sign of $x$ and $|x|$ is the absolute value of $x$. This reduces to the desired $x^p$ when $xgeq0$, with the added benefit of being an odd function, so for example $f(-1)=-1$.



        Or, you can try linear interpolation between two functions, as in $f_p(x)=(1-p)x+px^3$ for $0leq pleq 1$. This may look more elegant on paper, but it might not feel as nice in practice, since it doesn't place a dead zone around $x=0$ unless $p$ is very close to $1$.



        I assume you want a dead zone to compensate for the discontinuous jump in force that is required for the player's hand to move the joystick away from neutral. In other words, we want the derivative $f'_p(0)=0$ for all $p$ greater than the minimum setting. That's what you'll get with $mathrm{sgn}(x)|x|^p$.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Jan 23 at 10:21









        Chris CulterChris Culter

        21.4k43888




        21.4k43888






























            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%2f3084266%2fsmooth-transition-between-functions%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

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith