2nd vs. 3rd Order Gauss Quadrature











up vote
0
down vote

favorite












I have read that using Gauss Quadrature integration,
$$int_{-1}^{1}f(x)dx=sum_i f(x_i)w_i$$
for polynomials of degree $leq2n-1$ (and otherwise it is an approximation). Using weight functions $w_i$ from wikipedia, for 2$^{nd}$ order GQ we have
$$int_{-1}^{1}f(x)dx=fbigg(frac{1}{sqrt{3}}bigg) + fbigg(-frac{1}{sqrt{3}}bigg)$$
and for 3$^{rd}$ order,
$$int_{-1}^{1}f(x)dx=frac 59 fbigg(sqrt{frac{3}{5}}bigg)+ frac 59 fbigg(-sqrt{frac{3}{5}}bigg) $$



My problem is that I don't seem to be getting the same answer for second and third order GQ for polynomials of degree $leq 3$, for which they should both yield exact solutions.



For example, for the function $f(x)=a_1 + a_2x + a_3x^2 + a_4x^3$, from first order GQ I get:
$$int_{-1}^{1}f(x)dx=2a_1 + frac{2}{3}a_3$$
which I believe is the correct solution, but for third order GQ I get



$$int_{-1}^{1}f(x)dx=frac{10}{9}a_1 + frac 23 a_3$$



This error seems to occur for any constant term in any polynomial as a result of the fact that the sum of the weight functions aren't equal for second and third order GQ. Why is this? I can't find my mistake!



Thanks in advance for your help.










share|cite|improve this question


























    up vote
    0
    down vote

    favorite












    I have read that using Gauss Quadrature integration,
    $$int_{-1}^{1}f(x)dx=sum_i f(x_i)w_i$$
    for polynomials of degree $leq2n-1$ (and otherwise it is an approximation). Using weight functions $w_i$ from wikipedia, for 2$^{nd}$ order GQ we have
    $$int_{-1}^{1}f(x)dx=fbigg(frac{1}{sqrt{3}}bigg) + fbigg(-frac{1}{sqrt{3}}bigg)$$
    and for 3$^{rd}$ order,
    $$int_{-1}^{1}f(x)dx=frac 59 fbigg(sqrt{frac{3}{5}}bigg)+ frac 59 fbigg(-sqrt{frac{3}{5}}bigg) $$



    My problem is that I don't seem to be getting the same answer for second and third order GQ for polynomials of degree $leq 3$, for which they should both yield exact solutions.



    For example, for the function $f(x)=a_1 + a_2x + a_3x^2 + a_4x^3$, from first order GQ I get:
    $$int_{-1}^{1}f(x)dx=2a_1 + frac{2}{3}a_3$$
    which I believe is the correct solution, but for third order GQ I get



    $$int_{-1}^{1}f(x)dx=frac{10}{9}a_1 + frac 23 a_3$$



    This error seems to occur for any constant term in any polynomial as a result of the fact that the sum of the weight functions aren't equal for second and third order GQ. Why is this? I can't find my mistake!



    Thanks in advance for your help.










    share|cite|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have read that using Gauss Quadrature integration,
      $$int_{-1}^{1}f(x)dx=sum_i f(x_i)w_i$$
      for polynomials of degree $leq2n-1$ (and otherwise it is an approximation). Using weight functions $w_i$ from wikipedia, for 2$^{nd}$ order GQ we have
      $$int_{-1}^{1}f(x)dx=fbigg(frac{1}{sqrt{3}}bigg) + fbigg(-frac{1}{sqrt{3}}bigg)$$
      and for 3$^{rd}$ order,
      $$int_{-1}^{1}f(x)dx=frac 59 fbigg(sqrt{frac{3}{5}}bigg)+ frac 59 fbigg(-sqrt{frac{3}{5}}bigg) $$



      My problem is that I don't seem to be getting the same answer for second and third order GQ for polynomials of degree $leq 3$, for which they should both yield exact solutions.



      For example, for the function $f(x)=a_1 + a_2x + a_3x^2 + a_4x^3$, from first order GQ I get:
      $$int_{-1}^{1}f(x)dx=2a_1 + frac{2}{3}a_3$$
      which I believe is the correct solution, but for third order GQ I get



      $$int_{-1}^{1}f(x)dx=frac{10}{9}a_1 + frac 23 a_3$$



      This error seems to occur for any constant term in any polynomial as a result of the fact that the sum of the weight functions aren't equal for second and third order GQ. Why is this? I can't find my mistake!



      Thanks in advance for your help.










      share|cite|improve this question













      I have read that using Gauss Quadrature integration,
      $$int_{-1}^{1}f(x)dx=sum_i f(x_i)w_i$$
      for polynomials of degree $leq2n-1$ (and otherwise it is an approximation). Using weight functions $w_i$ from wikipedia, for 2$^{nd}$ order GQ we have
      $$int_{-1}^{1}f(x)dx=fbigg(frac{1}{sqrt{3}}bigg) + fbigg(-frac{1}{sqrt{3}}bigg)$$
      and for 3$^{rd}$ order,
      $$int_{-1}^{1}f(x)dx=frac 59 fbigg(sqrt{frac{3}{5}}bigg)+ frac 59 fbigg(-sqrt{frac{3}{5}}bigg) $$



      My problem is that I don't seem to be getting the same answer for second and third order GQ for polynomials of degree $leq 3$, for which they should both yield exact solutions.



      For example, for the function $f(x)=a_1 + a_2x + a_3x^2 + a_4x^3$, from first order GQ I get:
      $$int_{-1}^{1}f(x)dx=2a_1 + frac{2}{3}a_3$$
      which I believe is the correct solution, but for third order GQ I get



      $$int_{-1}^{1}f(x)dx=frac{10}{9}a_1 + frac 23 a_3$$



      This error seems to occur for any constant term in any polynomial as a result of the fact that the sum of the weight functions aren't equal for second and third order GQ. Why is this? I can't find my mistake!



      Thanks in advance for your help.







      numerical-methods






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Nov 13 at 1:46









      lamdoug

      32




      32






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          For 3 point quadrature I believe you are missing $frac{8}{9} f(0)$ in your sum.



          It would also introduce a $frac{8}{9}a_{1}$ which would correct your toy example.






          share|cite|improve this answer





















          • Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
            – lamdoug
            Nov 13 at 1:52











          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%2f2996171%2f2nd-vs-3rd-order-gauss-quadrature%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








          up vote
          0
          down vote



          accepted










          For 3 point quadrature I believe you are missing $frac{8}{9} f(0)$ in your sum.



          It would also introduce a $frac{8}{9}a_{1}$ which would correct your toy example.






          share|cite|improve this answer





















          • Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
            – lamdoug
            Nov 13 at 1:52















          up vote
          0
          down vote



          accepted










          For 3 point quadrature I believe you are missing $frac{8}{9} f(0)$ in your sum.



          It would also introduce a $frac{8}{9}a_{1}$ which would correct your toy example.






          share|cite|improve this answer





















          • Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
            – lamdoug
            Nov 13 at 1:52













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          For 3 point quadrature I believe you are missing $frac{8}{9} f(0)$ in your sum.



          It would also introduce a $frac{8}{9}a_{1}$ which would correct your toy example.






          share|cite|improve this answer












          For 3 point quadrature I believe you are missing $frac{8}{9} f(0)$ in your sum.



          It would also introduce a $frac{8}{9}a_{1}$ which would correct your toy example.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Nov 13 at 1:50









          Nebu

          585




          585












          • Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
            – lamdoug
            Nov 13 at 1:52


















          • Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
            – lamdoug
            Nov 13 at 1:52
















          Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
          – lamdoug
          Nov 13 at 1:52




          Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
          – lamdoug
          Nov 13 at 1:52


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2996171%2f2nd-vs-3rd-order-gauss-quadrature%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

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?