Calculate Gaussian Quadrature: x1, x2 & w1, w2

Click For Summary
SUMMARY

This discussion centers on calculating the nodes \(x_1, x_2\) and weights \(w_1, w_2\) for Gaussian quadrature, specifically using the Gauss-Legendre method for the integral \(\int_{-1}^1 f(x) \, dx\). The function under consideration is \(f(x) = e^{-\frac{1}{x^2} - x^2}\). Participants agree that while the Gauss-Legendre method is suitable for polynomial-like functions, the choice of quadrature method depends on the characteristics of \(f\). The discussion also touches on the possibility of using Simpson's rule as a simpler alternative.

PREREQUISITES
  • Understanding of Gaussian quadrature methods, specifically Gauss-Legendre and Gauss-Chebyshev.
  • Familiarity with polynomial approximation and weight functions in numerical integration.
  • Knowledge of the properties of the function \(f(x) = e^{-\frac{1}{x^2} - x^2}\).
  • Basic calculus concepts, including integration and limits.
NEXT STEPS
  • Research the properties and applications of Gauss-Legendre quadrature.
  • Learn about the Chebyshev-Gauss quadrature method and its specific use cases.
  • Explore Simpson's rule for numerical integration and its advantages over Gaussian quadrature.
  • Investigate how to handle singularities in functions when applying numerical integration techniques.
USEFUL FOR

Mathematicians, numerical analysts, and anyone involved in computational mathematics or numerical integration techniques will benefit from this discussion.

mathmari
Gold Member
MHB
Messages
4,984
Reaction score
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:
 
Physics news on Phys.org
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$. 🤔
 
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:
 
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. 🤔
 
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:
 
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:
 
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. 🤔
 
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:
 
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. 🤔
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K