How do I find a function to fit these criteria?

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











up vote
1
down vote

favorite












I want to find a smooth continuous function f[x] that satisfies the following for real values of x:



Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 && 
Derivative[1][f][10] == 2/5, f]


This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and Solve is not the right tool.



How do I find a continuous function of x that fits these criteria?










share|improve this question

























    up vote
    1
    down vote

    favorite












    I want to find a smooth continuous function f[x] that satisfies the following for real values of x:



    Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 && 
    Derivative[1][f][10] == 2/5, f]


    This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and Solve is not the right tool.



    How do I find a continuous function of x that fits these criteria?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I want to find a smooth continuous function f[x] that satisfies the following for real values of x:



      Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 && 
      Derivative[1][f][10] == 2/5, f]


      This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and Solve is not the right tool.



      How do I find a continuous function of x that fits these criteria?










      share|improve this question













      I want to find a smooth continuous function f[x] that satisfies the following for real values of x:



      Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 && 
      Derivative[1][f][10] == 2/5, f]


      This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and Solve is not the right tool.



      How do I find a continuous function of x that fits these criteria?







      equation-solving function-construction interpolation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 10 hours ago









      Richard Burke-Ward

      4249




      4249




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).



          f[x_] := a x^3 + b x^2 + c x + d;
          Solve[f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5, a, b, c, d]



          a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0




          Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.



          J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:



          InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]



          To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:



          f[x_] := a Sin[b x] + c Sin[x];
          NMinimize[Norm[f'[0] - 1/2, f[10] - 5, f'[10] - 2/5], a, b, c]


          NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.






          share|improve this answer


















          • 2




            You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
            – J. M. is computer-less♦
            10 hours ago










          • Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
            – Richard Burke-Ward
            8 hours ago










          • @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
            – eyorble
            8 hours ago






          • 2




            Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
            – J. M. is computer-less♦
            8 hours ago










          • Many thanks to both of you. I'll mark as answered :-)
            – Richard Burke-Ward
            8 hours ago

















          up vote
          3
          down vote













          An another alternative, giving the same result is



          DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 && 
          f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]

          (*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)





          share|improve this answer
















          • 1




            Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
            – Michael E2
            5 hours ago











          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: "387"
          ;
          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: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183838%2fhow-do-i-find-a-function-to-fit-these-criteria%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote



          accepted










          The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).



          f[x_] := a x^3 + b x^2 + c x + d;
          Solve[f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5, a, b, c, d]



          a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0




          Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.



          J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:



          InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]



          To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:



          f[x_] := a Sin[b x] + c Sin[x];
          NMinimize[Norm[f'[0] - 1/2, f[10] - 5, f'[10] - 2/5], a, b, c]


          NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.






          share|improve this answer


















          • 2




            You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
            – J. M. is computer-less♦
            10 hours ago










          • Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
            – Richard Burke-Ward
            8 hours ago










          • @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
            – eyorble
            8 hours ago






          • 2




            Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
            – J. M. is computer-less♦
            8 hours ago










          • Many thanks to both of you. I'll mark as answered :-)
            – Richard Burke-Ward
            8 hours ago














          up vote
          6
          down vote



          accepted










          The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).



          f[x_] := a x^3 + b x^2 + c x + d;
          Solve[f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5, a, b, c, d]



          a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0




          Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.



          J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:



          InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]



          To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:



          f[x_] := a Sin[b x] + c Sin[x];
          NMinimize[Norm[f'[0] - 1/2, f[10] - 5, f'[10] - 2/5], a, b, c]


          NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.






          share|improve this answer


















          • 2




            You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
            – J. M. is computer-less♦
            10 hours ago










          • Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
            – Richard Burke-Ward
            8 hours ago










          • @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
            – eyorble
            8 hours ago






          • 2




            Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
            – J. M. is computer-less♦
            8 hours ago










          • Many thanks to both of you. I'll mark as answered :-)
            – Richard Burke-Ward
            8 hours ago












          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).



          f[x_] := a x^3 + b x^2 + c x + d;
          Solve[f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5, a, b, c, d]



          a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0




          Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.



          J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:



          InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]



          To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:



          f[x_] := a Sin[b x] + c Sin[x];
          NMinimize[Norm[f'[0] - 1/2, f[10] - 5, f'[10] - 2/5], a, b, c]


          NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.






          share|improve this answer














          The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).



          f[x_] := a x^3 + b x^2 + c x + d;
          Solve[f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5, a, b, c, d]



          a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0




          Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.



          J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:



          InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]



          To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:



          f[x_] := a Sin[b x] + c Sin[x];
          NMinimize[Norm[f'[0] - 1/2, f[10] - 5, f'[10] - 2/5], a, b, c]


          NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 8 hours ago

























          answered 10 hours ago









          eyorble

          4,6301725




          4,6301725







          • 2




            You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
            – J. M. is computer-less♦
            10 hours ago










          • Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
            – Richard Burke-Ward
            8 hours ago










          • @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
            – eyorble
            8 hours ago






          • 2




            Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
            – J. M. is computer-less♦
            8 hours ago










          • Many thanks to both of you. I'll mark as answered :-)
            – Richard Burke-Ward
            8 hours ago












          • 2




            You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
            – J. M. is computer-less♦
            10 hours ago










          • Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
            – Richard Burke-Ward
            8 hours ago










          • @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
            – eyorble
            8 hours ago






          • 2




            Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
            – J. M. is computer-less♦
            8 hours ago










          • Many thanks to both of you. I'll mark as answered :-)
            – Richard Burke-Ward
            8 hours ago







          2




          2




          You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
          – J. M. is computer-less♦
          10 hours ago




          You can use InterpolatingPolynomial directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
          – J. M. is computer-less♦
          10 hours ago












          Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
          – Richard Burke-Ward
          8 hours ago




          Great. One follow-up question: is there a trigonometric equivalent to InterpolatingPolynomial?
          – Richard Burke-Ward
          8 hours ago












          @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
          – eyorble
          8 hours ago




          @RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate f is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x] as a starting point.
          – eyorble
          8 hours ago




          2




          2




          Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
          – J. M. is computer-less♦
          8 hours ago




          Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
          – J. M. is computer-less♦
          8 hours ago












          Many thanks to both of you. I'll mark as answered :-)
          – Richard Burke-Ward
          8 hours ago




          Many thanks to both of you. I'll mark as answered :-)
          – Richard Burke-Ward
          8 hours ago










          up vote
          3
          down vote













          An another alternative, giving the same result is



          DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 && 
          f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]

          (*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)





          share|improve this answer
















          • 1




            Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
            – Michael E2
            5 hours ago















          up vote
          3
          down vote













          An another alternative, giving the same result is



          DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 && 
          f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]

          (*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)





          share|improve this answer
















          • 1




            Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
            – Michael E2
            5 hours ago













          up vote
          3
          down vote










          up vote
          3
          down vote









          An another alternative, giving the same result is



          DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 && 
          f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]

          (*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)





          share|improve this answer












          An another alternative, giving the same result is



          DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 && 
          f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]

          (*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 8 hours ago









          mikado

          6,2721829




          6,2721829







          • 1




            Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
            – Michael E2
            5 hours ago













          • 1




            Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
            – Michael E2
            5 hours ago








          1




          1




          Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
          – Michael E2
          5 hours ago





          Even more generally, DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x] gives a solution valid for any sufficiently smooth function g. (+1)
          – Michael E2
          5 hours ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183838%2fhow-do-i-find-a-function-to-fit-these-criteria%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery