Numerical Analysis/Gaussian Quadrature

From testwiki
Revision as of 11:28, 17 December 2022 by imported>MathXplore (Moving from Category:Numerical analysis to Category:Numerical integration using Cat-a-lot)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

For the first example, I just want an example to show that the solution is exact for polynomials of degree 2n1, using the nth degree Legendre polynomial. I'm going to approximate 11x3dx.

11x3dx=(13)3+(13)3141414(1)4=(133)(133)1414=0

This problem accurately illustrates the method for solving problems using the Gaussian Quadrature algorithm. Note that the zeros of the Legendre polynomials of degree n are 13 and 13.

We can see from the previous example that this method works quite well if we are integrating from 1 to 1, but in application, we rarely want to integrate over such a simple region. So in our next example, we will show that this technique is also effective if we change the limits of integration, as seen on the Wikipedia page, then we will solve the example 414x3dx

414x3dx=1442i=12f(1442xi+14+42)141441444=5((513+9)3+((513+9)3)9540=5(12533+8753+12153+72912533+875312153+729)9540=5(1908)9540=9540

We will next show how to solve a problem that isn't a simple polynomial. We will approximate 11exdx using a two point Gaussian approximation, and discuss the error analysis.

11exdxe13+e13e1ee13+1e13

We will next analyze this error, looking at the actual error followed by finding the error bound. We denote the approximation by fapprox and the exact solution by fexact.

|fexactfapprox|=|e1ee131e13|=0.00770629937787233598077

The theoretical error bound when using the Legendre polynomial method is

|fexactfapprox|(ba)2n+1(n!)4(2n+1)[(2n)!]3f(2n)(ξ),a<ξ<b25245*4!3e=295*243e=0.02013542095154848322489

In our example, the actual error was well within the error bound. We also see that with only two calculations, this is a very good algorithm for approximating integrals quickly with relatively good accuracy.

Exercises

1. Show that Gaussian Quadrature can solve exactly general cubic polynomials.

a) Set up the integral:

b) Evaluate the integral:

c) Evaluate the approximation:

d) Do parts b and c correspond?


2. Approximate 11sin2(x)cos(x)dx using Gaussian Quadrature

a) Evaluate the problem symbolically:

b) Evaluate the approximation:

c) Find the actual error

d) Find the error bound

d) Is the actual error less than the error bound?


3. If x1,x2,....,xn are the roots of the nth Legendre Polynomial Pn(x) and that for each i=1,2,....,n, the numbers ci are defined by

ci=11j=1,jinxxjxixjdx

Prove that if P(x) is any polynomial of degree less than 2n, then

11P(x)dx=i=1nciP(xi).

Gaussian Quadrature Example

I realized that there was insufficient information after the derived and solved sample on Gaussian Quadrature thus i took the pain to edit this wikiversity page by adding a solved example to the information already on there and below is what i factored in.


Find the constants C_0, C_1, and x_1 so that the quadrature formula

01f(x)dx=C0f(0)+C1f(x1).

has the highest possible degree of precision.

Solution

Since there are three unknowns, C_0, C_1 and x_1, we will expect the formula to be exact for

f(x)=1,x,and x2

Thus

f(x)=1, 01f(x)dx=1=C0+C1  Equation1,f(x)=x, 01f(x)dx=12=C1x1  Equation2.f(x)=x2, 01f(x)dx=13=C1x12.

Equation 2 and 3 will yield.

c1x1c1x12=x1=23.C1=34.C0=14.

Hence

01f(x)dx=14f(0)+34f(23)

Now,

f(x)=x3.01x3dx=14

And

14(0)3+34(23)3=29.

Thus the degree of the precision is 2

Example Quiz

<quiz display=simple> {Why do we use the zeros of the Legendre polynomials in this method? |type="()"} - By convention for consistency + Because Legendre polynomials of degree n are orthogonal to any other polynomial with degree less than n - Because they make f(x)=0 when approximating f(x) - None of these

{The integral of a 6th degree polynomial can be approximated exactly using the 3rd degree Legendre polynomial, True or False |type="()"} - True + False

{Calculate the error bound for a general 3rd degree polynomial using a 2nd order Legendre polynomial |type="()"} - 10.56 + 0 - 4.13 - 50.25

{Calculate the error bound for 48x6+5x5+27x4+108x+276dx using a 3rd degree Legendre polynomial |type="()"} + 5.85 - 0.13 - 28.83 - 12.44

{What are the failure conditions for this algorithm? |type="()"} - The nth derivative of f(x) must be nonzero + f(x) is discontinuous over the range of integration - f(x) is constant over the range - The method never fails, it just can suffer from poor accuracy </quiz>