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.
numerical-methods
add a comment |
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.
numerical-methods
add a comment |
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.
numerical-methods
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
numerical-methods
asked Nov 13 at 1:46
lamdoug
32
32
add a comment |
add a comment |
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.
Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
– lamdoug
Nov 13 at 1:52
add a comment |
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.
Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
– lamdoug
Nov 13 at 1:52
add a comment |
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.
Of course. I saw the zero and neglected it but obviously f(0) is not zero! Thanks.
– lamdoug
Nov 13 at 1:52
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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