Calculate Gaussian Quadrature: x1, x2 & w1, w2

In summary: What do you think the result would be?According to the table, the weight function for $n=2$ is $w_2=\frac{3}{(1-x_1^2)P_2(x_1)}=\frac{3}{6}$.
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! 😊

If we want to calculate the nodes $x_1, x_2$ and the weight functions $w_1, w_2$ for the Gaussian quadrature of the integral $$\int_{-1}^1f(x)\, dx\approx \sum_{j=1}^2w_jf(x_j)$$ is there a criteria that we have to consider at chosing the weight functions? I mean if we use e.g. Gauss-Legendre or Tschebyscheff-Jacobi? :unsure:
 
Mathematics news on Phys.org
  • #2
Hi mathmari!

We can choose the weights in multiple ways. It depends on the function $f$ what the best one is.
Gauss-Legendre is for an $f$ that is "well approximated by polynomials on [-1,1]", which will not always be the case.
I cannot find Tschebyscheff-Jacobi, but Chebyshev–Gauss is for a specific form of $f$. 🤔
 
  • #3
Klaas van Aarsen said:
We can choose the weights in multiple ways. It depends on the function $f$ what the best one is.
Gauss-Legendre is for an $f$ that is "well approximated by polynomials on [-1,1]", which will not always be the case.
I cannot find Tschebyscheff-Jacobi, but Chebyshev–Gauss is for a specific form of $f$. 🤔

In this exercise we have the function $e^{-\frac{1}{x^2}-x^2}$.

Which method is the best here? :unsure:
 
  • #4
mathmari said:
In this exercise we have the function $e^{-\frac{1}{x^2}-x^2}$.

Which method is the best here?

I don't know which Gaussian Quadrature would be best for that.
If it were me, I'd use Simpson's rule instead, which is simpler and which will work. 🤔
 
  • #5
Klaas van Aarsen said:
I don't know which Gaussian Quadrature would be best for that.
If it were me, I'd use Simpson's rule instead, which is simpler and which will work. 🤔

So in general can we use one of the Gaussian Quadrature methods? Or is there a specific criteria? :unsure:
 
  • #6
According to the exercise statement we have to calculate the nodes and the weight functions. So do we have to calculate them by ourselves instead of taking the already known functions Gauss-Legendre, Chebyshev, etc? :unsure:
 
  • #7
Since the function does not match any of the special functions in the wiki article, I think we should use the generic Gauss–Legendre version.
Then we can still calculate the weights based on the number of points that we choose. 🤔
 
  • #8
Klaas van Aarsen said:
Since the function does not match any of the special functions in the wiki article, I think we should use the generic Gauss–Legendre version.
Then we can still calculate the weights based on the number of points that we choose. 🤔

I found now the below table:

1606141277275.png


Does this mean that since we have an integral of the formm $\int_{-1}^1f(x)\, dx$, i.e. $w\equiv 1$ we use the Gauss-Legendre?
If we would have an integral of the form $\int_{-1}^1f(x)\cdot \frac{1}{\sqrt{1-x^2}}\, dx$ we would use Gauss-Tschebyscheff, etc? Or since we have the function $f(x)=e^{-\frac{1}{x^2}-x^2}$ we write it in the form $e^{-\frac{1}{x^2}}e^{-x^2}$ and we use Gauss-Laguerre for example consider the function $e^{-\frac{1}{x^2}}$ ?



:unsure:
 
  • #9
mathmari said:
Does this mean that since we have an integral of the formm $\int_{-1}^1f(x)\, dx$, i.e. $w\equiv 1$ we use the Gauss-Legendre?
If we would have an integral of the form $\int_{-1}^1f(x)\cdot \frac{1}{\sqrt{1-x^2}}\, dx$ we would use Gauss-Tschebyscheff, etc?

It depends on what $f(x)$ is. If it is a function that behaves like a polynomial, you are right.
If $f(x)$ is a polynomial divided by $\sqrt{1-x^2}$, we should use Gauss-Tschebyscheff. (Wondering)

Or since we have the function $f(x)=e^{-\frac{1}{x^2}-x^2}$ we write it in the form $e^{-\frac{1}{x^2}}e^{-x^2}$ and we use Gauss-Laguerre for example consider the function $e^{-\frac{1}{x^2}}$ ?
That's a possibility yes. 🤔
 
  • #10
What do you suggest me to do in this exercise, becaus I am confused right now? To use ready functions or to calculate by myself some weight functions? :unsure:
 
  • #11
Do we suppose that the formula has to be exact for polynomials till degree $n=3$ and so we get:
Sei $f(x)=1$ dann $$\int_{-1}^11\, dx=2\approx w_1+w_2 \\ \int_{-1}^1x\, dx=0\approx w_1x_1+w_2x_2 \\ \int_{-1}^1x^2\, dx=\frac{2}{3}\approx w_1x_1^2+w_2x_2^2$$ Or do we do something else because we have an exponential function?
 
  • #12
Suppose we use Gauss-Legendre and we calculate the nodes and weights ourselves instead of looking them up. 🤔

For $n=1$ we have the Legendre polynomial $P_1(x)=x$, which has its zero at $x_1=0$.
The corresponding weight is $w_1=\frac{2}{(1-x_1^2)P_1'(x_1)}=2$.
So we get:
$$\int_{-1}^1 f(x)\,dx \approx w_1f(x_1) = 2\cdot f(0)$$
We apply this to $f(x)=e^{-\frac 1{x^2}-x^2}$ so we have to evaluate $f(0)$, which unfortunately does not exist.
However, we can extend $f$ and define $f(0)$ to be the limit, which is $0$.
So:
$$\int_{-1}^1 f(x)\,dx \approx 2\cdot 0 = 0$$
For comparison, W|A tells us that $\int_{-1}^1 e^{-\frac 1{x^2}-x^2}\,dx\approx 0.0893$, so we are not that far off.

Suppose we repeat the calculation for $n=2$ with the Legendre polynomial $P_2(x)=\frac 12 (3x^2-1)$? 🤔
 
  • #13
mathmari said:
Do we suppose that the formula has to be exact for polynomials till degree $n=3$ and so we get:
Sei $f(x)=1$ dann $$\int_{-1}^11\, dx=2\approx w_1+w_2 \\ \int_{-1}^1x\, dx=0\approx w_1x_1+w_2x_2 \\ \int_{-1}^1x^2\, dx=\frac{2}{3}\approx w_1x_1^2+w_2x_2^2$$ Or do we do something else because we have an exponential function?
That should work as well, but aren't those formulas for $n=2$?
And the second and third formulas are not for $f(x)=1$ are they?
Either way, we now have 3 equations with 4 unknowns, so I guess we need to use symmetry to get another equation. 🤔
 

FAQ: Calculate Gaussian Quadrature: x1, x2 & w1, w2

What is Gaussian Quadrature?

Gaussian Quadrature is a numerical integration technique used to approximate the definite integral of a function. It is based on the principle of choosing specific points (x values) and weights (w values) to accurately estimate the area under the curve.

How do you calculate Gaussian Quadrature?

To calculate Gaussian Quadrature, you first need to determine the number of points and weights needed for the specific function. Then, you can use a formula or table to find the corresponding x and w values. Finally, you can plug these values into the integration formula to approximate the definite integral.

What are x1, x2, w1, and w2 in Gaussian Quadrature?

x1 and x2 are the two points (x values) chosen for the integration, while w1 and w2 are the corresponding weights. These values are determined based on the number of points needed for the specific function and are used in the integration formula to approximate the definite integral.

How accurate is Gaussian Quadrature?

The accuracy of Gaussian Quadrature depends on the number of points and weights chosen for the integration. Generally, the more points and weights used, the more accurate the approximation will be. However, it is important to note that Gaussian Quadrature is not exact and will always have some degree of error.

What are the advantages of using Gaussian Quadrature?

Gaussian Quadrature is advantageous because it can provide a more accurate approximation of the definite integral compared to other numerical integration techniques, such as the Trapezoidal Rule or Simpson's Rule. It is also more efficient for functions with a large number of points, as it requires fewer function evaluations. Additionally, it can handle a wider range of functions with varying degrees of complexity.

Similar threads

Replies
4
Views
935
Replies
1
Views
1K
Back
Top