Understanding Gauss Quadrature for Approximating Integrals

  • MHB
  • Thread starter mathmari
  • Start date
  • Tags
    Gauss
In summary, the weighting function affects the points that we use to approximate the integral. The Chebychev-polynomials, $T_n(x)=\cos \left (\arccos x\right ), \ x\in [-1,1]$, use roots of the Legendre polynomials, $w(x)=1$, while the Chebychev-polynomials, $T_{n}(x)=\cos(n\arccos x).$, use roots of the Hermite polynomials, $w(x)=\frac{1}{\sqrt{1-x^2}}$.
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! :eek:

I am looking at the Gauss Quadrature to approximate integrals. I haven;t really understood the meaning of the weighting function. Could you explain that to me?

At each case, the points that we need depend on what weighting function we have, so which polynomials we consider or not?

For example, if we have the weighting function $w(x)=1$ we use the Legendre polynomials, and so their roots are the points that we need.
If we have $w(x)=\frac{1}{\sqrt{1-x^2}}$ we use the Chebychev-Polynomials.
If we have $w(x)=e^{-x^2}$ we use the Hermite polynomials.
If we have $w(x)=e^{-x}$ we use the Laguerre polynomials.
Right? Can we have also other weighting functions? (Wondering) Suppose we have the integral $\displaystyle{\int_{-1}^1\frac{\cos (x)}{\sqrt{1-x^2}}\, dx}$ with weighting function $w(x)= \frac{1}{\sqrt{1-x^2}}$.

We approxmate the integral by the sum \begin{equation*}\sum_{i=1}^n\Phi (x_i)w_i\end{equation*}

So we use the Chebychev-polynomials, $T_n(x)=\cos \left (\arccos x\right ), \ x\in [-1,1]$. We get so the points \begin{equation*}x_k=\cos \left (\frac{2k+1}{2n}\pi \right ), \ \ k=0, \ldots n-1\end{equation*}

The constant weight are given by $w_i=\frac{\pi}{n+1}$.

Applying the Gauss quadrature with two weights and two points, so we use $w_1=w_2=\frac{\pi}{2+1}=\frac{\pi}{3}$ and $x_1=\cos \left (\frac{\pi}{4} \right )=\frac{1}{\sqrt{2}}$ and $x_2=\cos \left (\frac{3}{4}\pi \right )=-\frac{1}{\sqrt{2}}$, right? (Wondering)

Let $f(x)=\cos (x)$.

We have the following:
\begin{equation*}\int_{-1}^1f(x)\cdot w(x)\, dx\approx \sum_{i=1}^2 f (x_i)w_i=f (x_1)w_1+f (x_2)w_2=\cos \left (\frac{1}{\sqrt{2}}\right ) \cdot \frac{\pi}{3}+\cos \left (-\frac{1}{\sqrt{2}}\right )\cdot \frac{\pi}{3}\approx 1.59225\end{equation*}

Is this correct? (Wondering)
 
Last edited by a moderator:
Mathematics news on Phys.org
  • #2
Hi mathmari,

Nice job showing the work you've done so far. There are a few points to clear up and I will do my best to parse them out. Since I don't know exactly what you do and don't know, feel free to ask any follow up questions if I mention something that's unclear.

mathmari said:
I haven;t really understood the meaning of the weighting function. Could you explain that to me?

Weights are used in math to give more (or less) emphasis to certain types of data. You have most likely seen this when your instructor computes your final grade. For example, say you have a final exam grade worth 40%, 2 midterms worth 25% each, and a homework grade worth 10%. Your grade for the course would then be

(Final Exam Raw Percentage)*(.4) + (Midterm 1 + Midterm 2 Raw Percentage)*(.25) + (Homework Raw Percentage)*(.1).

In this way your instructor has mathematically placed more emphasis (i.e., weight) on, say, a 90% on the final exam than a 90% on your homework for the semester. The domain here (your scores for the course) is a discrete set, so when we calculate your weighted average, we need only use a standard summation.

It turns out that in many applications (e.g., probability theory, quantum mechanics) you need to work with continuous sets of data/outcomes. When this is the case, weight functions are used to place more (or less) emphasis on certain outcomes based (typically) on how likely you are to measure/observe a particular outcome. If you've taken a probability/stats course you have likely seen Gaussian/Normal distributions (among others). The example you gave of $w(x)=e^{-x^{2}}$ is (outside of a multiplicative factor) a Gaussian distribution/weight function with mean = 0 and variance = 1/2.

mathmari said:
At each case, the points that we need depend on what weighting function we have, so which polynomials we consider or not?

For example, if we have the weighting function $w(x)=1$ we use the Legendre polynomials, and so their roots are the points that we need.
If we have $w(x)=\frac{1}{\sqrt{1-x^2}}$ we use the Chebychev-Polynomials.
If we have $w(x)=e^{-x^2}$ we use the Hermite polynomials.
If we have $w(x)=e^{-x}$ we use the Laguerre polynomials.
Right?

This is all correct, though I will add that the interval you are working on is also important. For example, when using the Laguerre polynomials you are thinking about problems on the half-line $(0,\infty)$, not $[-1,1]$.

mathmari said:
Can we have also other weighting functions?

Yes, you can. In fact, quantum mechanics is, in a basic sense, essentially about finding different kinds of weight functions!

mathmari said:
So we use the Chebychev-polynomials, $T_n(x)=\cos \left (\arccos x\right ), \ x\in [-1,1]$.

You are missing an $n$ here inside the parenthesis; i.e., $T_{n}(x)=\cos(n\arccos x).$

mathmari said:
The constant weight are given by $w_i=\frac{\pi}{n+1}$.

This should be $\pi/n.$ There are two ways for checking this is incorrect: (1) Using Wolfram to check that the error you get when using these weights is quite large for the problem you are trying to solve; (2) (MORE IMPORTANTLY!) The method you use to derive the nodes $x_{i}$ and the weights $w_{i}$ is one that requires/forces the Gaussian quadrature to give EXACT equality in the case that $f(x)$ is a polynomial of degree $2n-1$ or smaller (due to linearity of integration, it is enough to check this using the monomials $1, x,\ldots, x^{2n-1}$). In particular, for $f(x)=1$ we have
$$\pi=\int_{-1}^{1}\frac{1}{\sqrt{1-x^{2}}}\,dx\neq w_{1}+w_{2} = \frac{2\pi}{3}.$$
I would try your calculation again. The "exact" value of the integral is 2.40394 (using Mathematica) and your new answer should be much closer to this than what you previously had.
 
Last edited:
  • #3
GJA said:
Weights are used in math to give more (or less) emphasis to certain types of data. You have most likely seen this when your instructor computes your final grade. For example, say you have a final exam grade worth 40%, 2 midterms worth 25% each, and a homework grade worth 10%. Your grade for the course would then be

(Final Exam Raw Percentage)*(.4) + (Midterm 1 + Midterm 2 Raw Percentage)*(.25) + (Homework Raw Percentage)*(.1).

In this way your instructor has mathematically placed more emphasis (i.e., weight) on, say, a 90% on the final exam than a 90% on your homework for the semester. The domain here (your scores for the course) is a discrete set, so when we calculate your weighted average, we need only use a standard summation.

It turns out that in many applications (e.g., probability theory, quantum mechanics) you need to work with continuous sets of data/outcomes. When this is the case, weight functions are used to place more (or less) emphasis on certain outcomes based (typically) on how likely you are to measure/observe a particular outcome. If you've taken a probability/stats course you have likely seen Gaussian/Normal distributions (among others). The example you gave of $w(x)=e^{-x^{2}}$ is (outside of a multiplicative factor) a Gaussian distribution/weight function with mean = 0 and variance = 1/2.

Ah I see!
GJA said:
This is all correct, though I will add that the interval you are working on is also important. For example, when using the Laguerre polynomials you are thinking about problems on the half-line $(0,\infty)$, not $[-1,1]$.

Ah ok!
GJA said:
You are missing an $n$ here inside the parenthesis; i.e., $T_{n}(x)=\cos(n\arccos x).$

This should be $\pi/n.$ There are two ways for checking this is incorrect: (1) Using Wolfram to check that the error you get when using these weights is quite large for the problem you are trying to solve; (2) (MORE IMPORTANTLY!) The method you use to derive the nodes $x_{i}$ and the weights $w_{i}$ is one that requires/forces the Gaussian quadrature to give EXACT equality in the case that $f(x)$ is a polynomial of degree $2n-1$ or smaller (due to linearity of integration, it is enough to check this using the monomials $1, x,\ldots, x^{2n-1}$). In particular, for $f(x)=1$ we have
$$\pi=\int_{-1}^{1}\frac{1}{\sqrt{1-x^{2}}}\,dx\neq w_{1}+w_{2} = \frac{2\pi}{3}.$$
I would try your calculation again. The "exact" value of the integral is 2.40394 (using Mathematica) and your new answer should be much closer to this than what you previously had.

Yes, now I get an approximation that is much closer to the exact result! (Yes) Thank you so much for your help! (Smile)
 
Last edited by a moderator:

FAQ: Understanding Gauss Quadrature for Approximating Integrals

What is Gauss quadrature?

Gauss quadrature is a numerical method used for approximating integrals. It involves selecting a specific set of points, known as quadrature points, within the interval of integration and using them to calculate the integral value. This method is more accurate and efficient than other numerical integration techniques.

How does Gauss quadrature work?

Gauss quadrature works by using a weighted sum of function values at the selected quadrature points to approximate the integral. The weights and quadrature points are chosen in such a way that the approximation is as accurate as possible. The more quadrature points used, the more accurate the approximation will be.

What are the advantages of using Gauss quadrature?

One of the main advantages of Gauss quadrature is its accuracy. This method can provide accurate results for a wide range of integrands, including those with sharp peaks or discontinuities. It also requires fewer function evaluations compared to other numerical integration techniques, making it more efficient.

Are there any limitations to using Gauss quadrature?

While Gauss quadrature is a powerful method for approximating integrals, it does have some limitations. One limitation is that it can only be applied to integrals with finite limits. It also requires knowledge of the integrand, which may not always be available. Additionally, the accuracy of the approximation can be affected by the choice of quadrature points.

How is Gauss quadrature used in real-world applications?

Gauss quadrature is used in a variety of fields, including physics, engineering, and finance. It is commonly used to solve problems involving integration of functions, such as calculating the area under a curve or determining the volume of a solid. It is also used in numerical methods for solving differential equations and in numerical optimization algorithms.

Similar threads

Replies
4
Views
937
Replies
12
Views
2K
Replies
11
Views
885
Replies
1
Views
1K
Back
Top