Why is the error of $O(h^2)$ when using Taylor expansion and centered approximation for the first derivative












0












$begingroup$


We know that the approximation of the first derivative by centered approximation is given by
$$ f'(x) =
frac{f(t+h) - f(x-h)}{2h} + O(h^2)$$

The quality of the above approximation is determined by the error. For smaller values of $h>0$ the error should be as small as possible. To determine this error we use the Taylor expansion



begin{align*}
y(t+h) &= y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t-h) &= y(t) - y'(t)h + frac{y''(t)}{2}h^2-frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t+h) - y(t-h) &= 2y'(t)h + 2frac{y'''(t)}{3!}h^3 + O(h^4)\
frac{y(t+h)-y(t-h)}{2h}-y'(t) &= frac{y'''(t)}{3!}h^2 + O(h^3) = O(h^2)
end{align*}



an thus we conclude
$$
y'(t) = frac{y(t+h)-y(t-h)}{2h}+O(h^2)
$$



Here is my question



We could have arbitrarily decided to take the Taylor expansion with the polynomial of fourth and fifth order namely writing the first line as follows:
$$
y(t+h) = y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+frac{y''''(t)}{4!}h^4+frac{y'''''(t)}{5!}h^5+ O(h^6)
$$

Thus the last line would have been:
$$
frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + O(h^5) = O(h^4)
$$

and conclude that the error is of order $= O(h^4)$



Why is this not true?










share|cite|improve this question











$endgroup$












  • $begingroup$
    You are dropping several $h^n$ factors. This explains your mistake. And the developments involves $o$, not $O$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 13:34


















0












$begingroup$


We know that the approximation of the first derivative by centered approximation is given by
$$ f'(x) =
frac{f(t+h) - f(x-h)}{2h} + O(h^2)$$

The quality of the above approximation is determined by the error. For smaller values of $h>0$ the error should be as small as possible. To determine this error we use the Taylor expansion



begin{align*}
y(t+h) &= y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t-h) &= y(t) - y'(t)h + frac{y''(t)}{2}h^2-frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t+h) - y(t-h) &= 2y'(t)h + 2frac{y'''(t)}{3!}h^3 + O(h^4)\
frac{y(t+h)-y(t-h)}{2h}-y'(t) &= frac{y'''(t)}{3!}h^2 + O(h^3) = O(h^2)
end{align*}



an thus we conclude
$$
y'(t) = frac{y(t+h)-y(t-h)}{2h}+O(h^2)
$$



Here is my question



We could have arbitrarily decided to take the Taylor expansion with the polynomial of fourth and fifth order namely writing the first line as follows:
$$
y(t+h) = y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+frac{y''''(t)}{4!}h^4+frac{y'''''(t)}{5!}h^5+ O(h^6)
$$

Thus the last line would have been:
$$
frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + O(h^5) = O(h^4)
$$

and conclude that the error is of order $= O(h^4)$



Why is this not true?










share|cite|improve this question











$endgroup$












  • $begingroup$
    You are dropping several $h^n$ factors. This explains your mistake. And the developments involves $o$, not $O$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 13:34
















0












0








0





$begingroup$


We know that the approximation of the first derivative by centered approximation is given by
$$ f'(x) =
frac{f(t+h) - f(x-h)}{2h} + O(h^2)$$

The quality of the above approximation is determined by the error. For smaller values of $h>0$ the error should be as small as possible. To determine this error we use the Taylor expansion



begin{align*}
y(t+h) &= y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t-h) &= y(t) - y'(t)h + frac{y''(t)}{2}h^2-frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t+h) - y(t-h) &= 2y'(t)h + 2frac{y'''(t)}{3!}h^3 + O(h^4)\
frac{y(t+h)-y(t-h)}{2h}-y'(t) &= frac{y'''(t)}{3!}h^2 + O(h^3) = O(h^2)
end{align*}



an thus we conclude
$$
y'(t) = frac{y(t+h)-y(t-h)}{2h}+O(h^2)
$$



Here is my question



We could have arbitrarily decided to take the Taylor expansion with the polynomial of fourth and fifth order namely writing the first line as follows:
$$
y(t+h) = y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+frac{y''''(t)}{4!}h^4+frac{y'''''(t)}{5!}h^5+ O(h^6)
$$

Thus the last line would have been:
$$
frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + O(h^5) = O(h^4)
$$

and conclude that the error is of order $= O(h^4)$



Why is this not true?










share|cite|improve this question











$endgroup$




We know that the approximation of the first derivative by centered approximation is given by
$$ f'(x) =
frac{f(t+h) - f(x-h)}{2h} + O(h^2)$$

The quality of the above approximation is determined by the error. For smaller values of $h>0$ the error should be as small as possible. To determine this error we use the Taylor expansion



begin{align*}
y(t+h) &= y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t-h) &= y(t) - y'(t)h + frac{y''(t)}{2}h^2-frac{y'''(t)}{3!}h^3+ O(h^4)\
y(t+h) - y(t-h) &= 2y'(t)h + 2frac{y'''(t)}{3!}h^3 + O(h^4)\
frac{y(t+h)-y(t-h)}{2h}-y'(t) &= frac{y'''(t)}{3!}h^2 + O(h^3) = O(h^2)
end{align*}



an thus we conclude
$$
y'(t) = frac{y(t+h)-y(t-h)}{2h}+O(h^2)
$$



Here is my question



We could have arbitrarily decided to take the Taylor expansion with the polynomial of fourth and fifth order namely writing the first line as follows:
$$
y(t+h) = y(t) + y'(t)h + frac{y''(t)}{2}h^2+frac{y'''(t)}{3!}h^3+frac{y''''(t)}{4!}h^4+frac{y'''''(t)}{5!}h^5+ O(h^6)
$$

Thus the last line would have been:
$$
frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + O(h^5) = O(h^4)
$$

and conclude that the error is of order $= O(h^4)$



Why is this not true?







derivatives taylor-expansion finite-differences rounding-error






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 9 at 6:25







ecjb

















asked Jan 8 at 13:29









ecjbecjb

1618




1618












  • $begingroup$
    You are dropping several $h^n$ factors. This explains your mistake. And the developments involves $o$, not $O$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 13:34




















  • $begingroup$
    You are dropping several $h^n$ factors. This explains your mistake. And the developments involves $o$, not $O$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 13:34


















$begingroup$
You are dropping several $h^n$ factors. This explains your mistake. And the developments involves $o$, not $O$.
$endgroup$
– Yves Daoust
Jan 8 at 13:34






$begingroup$
You are dropping several $h^n$ factors. This explains your mistake. And the developments involves $o$, not $O$.
$endgroup$
– Yves Daoust
Jan 8 at 13:34












2 Answers
2






active

oldest

votes


















0












$begingroup$

The correct last line is



$$
frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + o(h^4) = Theta(h^2)
$$
(unless $y'''(t)=0$).






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
    $endgroup$
    – ecjb
    Jan 8 at 18:32












  • $begingroup$
    @ecjb: you confuse $O$ and $o$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 21:11



















-1












$begingroup$

Because for smaller value of $h$ which is less than $1$, $h^2$ is greater than $h^5$. Hence, if the error of an algorithm is $O(h^2)$ is in $O(h^5)$ for small values of $h$ and not vice versa.






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%2f3066167%2fwhy-is-the-error-of-oh2-when-using-taylor-expansion-and-centered-approximat%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









    0












    $begingroup$

    The correct last line is



    $$
    frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + o(h^4) = Theta(h^2)
    $$
    (unless $y'''(t)=0$).






    share|cite|improve this answer









    $endgroup$













    • $begingroup$
      Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
      $endgroup$
      – ecjb
      Jan 8 at 18:32












    • $begingroup$
      @ecjb: you confuse $O$ and $o$.
      $endgroup$
      – Yves Daoust
      Jan 8 at 21:11
















    0












    $begingroup$

    The correct last line is



    $$
    frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + o(h^4) = Theta(h^2)
    $$
    (unless $y'''(t)=0$).






    share|cite|improve this answer









    $endgroup$













    • $begingroup$
      Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
      $endgroup$
      – ecjb
      Jan 8 at 18:32












    • $begingroup$
      @ecjb: you confuse $O$ and $o$.
      $endgroup$
      – Yves Daoust
      Jan 8 at 21:11














    0












    0








    0





    $begingroup$

    The correct last line is



    $$
    frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + o(h^4) = Theta(h^2)
    $$
    (unless $y'''(t)=0$).






    share|cite|improve this answer









    $endgroup$



    The correct last line is



    $$
    frac{y(t+h)-y(t-h)}{2h}-y'(t) = frac{y'''(t)}{3!}h^2 + frac{y'''''(t)}{5!}h^4 + o(h^4) = Theta(h^2)
    $$
    (unless $y'''(t)=0$).







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Jan 8 at 13:39









    Yves DaoustYves Daoust

    125k671222




    125k671222












    • $begingroup$
      Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
      $endgroup$
      – ecjb
      Jan 8 at 18:32












    • $begingroup$
      @ecjb: you confuse $O$ and $o$.
      $endgroup$
      – Yves Daoust
      Jan 8 at 21:11


















    • $begingroup$
      Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
      $endgroup$
      – ecjb
      Jan 8 at 18:32












    • $begingroup$
      @ecjb: you confuse $O$ and $o$.
      $endgroup$
      – Yves Daoust
      Jan 8 at 21:11
















    $begingroup$
    Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
    $endgroup$
    – ecjb
    Jan 8 at 18:32






    $begingroup$
    Thank you for your answer @YvesDaoust. I indeed forge some $h^n$ and added them to my question. Could you elaborate a bit: why in your answer the order of order not equal to $Oh^4$? What would happen if $y'''(t) = 0?$
    $endgroup$
    – ecjb
    Jan 8 at 18:32














    $begingroup$
    @ecjb: you confuse $O$ and $o$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 21:11




    $begingroup$
    @ecjb: you confuse $O$ and $o$.
    $endgroup$
    – Yves Daoust
    Jan 8 at 21:11











    -1












    $begingroup$

    Because for smaller value of $h$ which is less than $1$, $h^2$ is greater than $h^5$. Hence, if the error of an algorithm is $O(h^2)$ is in $O(h^5)$ for small values of $h$ and not vice versa.






    share|cite|improve this answer









    $endgroup$


















      -1












      $begingroup$

      Because for smaller value of $h$ which is less than $1$, $h^2$ is greater than $h^5$. Hence, if the error of an algorithm is $O(h^2)$ is in $O(h^5)$ for small values of $h$ and not vice versa.






      share|cite|improve this answer









      $endgroup$
















        -1












        -1








        -1





        $begingroup$

        Because for smaller value of $h$ which is less than $1$, $h^2$ is greater than $h^5$. Hence, if the error of an algorithm is $O(h^2)$ is in $O(h^5)$ for small values of $h$ and not vice versa.






        share|cite|improve this answer









        $endgroup$



        Because for smaller value of $h$ which is less than $1$, $h^2$ is greater than $h^5$. Hence, if the error of an algorithm is $O(h^2)$ is in $O(h^5)$ for small values of $h$ and not vice versa.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Jan 8 at 13:31









        OmGOmG

        2,322722




        2,322722






























            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%2f3066167%2fwhy-is-the-error-of-oh2-when-using-taylor-expansion-and-centered-approximat%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

            Mario Kart Wii

            What does “Dominus providebit” mean?

            Antonio Litta Visconti Arese