Giter VIP home page Giter VIP logo

Comments (2)

stevengj avatar stevengj commented on July 25, 2024

What is your interval (a,b)?

  • If the interval includes x=±1, where your w(x) blows up, then your integral does not converge (unless f vanishes at these points), because this is not an integrable singularity. For the same reason, QuadGK.gauss will not work for this weight function.
  • Or maybe you want to compute a Cauchy Principal value? In that case, you can use a simple transformation to remove the singularity: #44 (comment)
  • If your interval does not include the singularity, why do you need to precompute the effect of the weight function at all? Why not just pass the whole integrand F(x)=w(x)f(x) to quadgk or some other quadrature method? But yes, you could use QuadGK.gauss to obtain a custom weighted quadrature scheme in this case.

from quadgk.jl.

nhavt avatar nhavt commented on July 25, 2024

Hi @stevengj,

Thank you very much for your help. So, my interval can arbitrarily be chosen (a, b>=0).

If the interval includes x=±1, where your w(x) blows up, then your integral does not converge (unless f vanishes at these points), because this is not an integrable singularity. For the same reason, QuadGK.gauss will not work for this weight function.

Do you mean that at these values my w(x) will equal to 0? But I think w(x)=1/(1+x^2) = 1 when x=+-1.

Or maybe you want to compute a Cauchy Principal value? In that case, you can use a simple transformation to remove the singularity: #44 (comment)

Yes, indeed. That is what I want. Here my weight function could be (1)w(x) = e^{-x^2} (normal distribution) or (2) w(x) = 1/(1+x^2) (Half-Cauchy distribution, https://distribution-explorer.github.io/continuous/halfcauchy.html). In case (1), we can use Gauss–Laguerre quadrature (https://en.wikipedia.org/wiki/Gauss–Laguerre_quadrature). But in case (2), I could not find a proper a quadrature rule (see https://en.wikipedia.org/wiki/Gaussian_quadrature in Section "Other Forms"). Perhaps, I would need to do a transformation as you suggested to remove the singularity. Or another transformation is x = tan(u). So my integral will be I = \int_{a}^{b} w(x)f(x)dx = \int_{arctan(a)}^{arctan(b)} f(tan(u))du. Then, I can use your function QuadGK.gauss to get notes and weights. I am sorry that I do not know how to display LaTeX formulaes in GitHub.

If your interval does not include the singularity, why do you need to precompute the effect of the weight function at all? Why not just pass the whole integrand F(x)=w(x)f(x) to quadgk or some other quadrature method? But yes, you could use QuadGK.gauss to obtain a custom weighted quadrature scheme in this case.

Yes, indeed. I also thought that. But I thought that using QuadGK.gauss on F(x) might not give a good approximation compared to a special technique using different polynomials on w(x). So, I will try with your suggestions. Also, do you have any suggestions for other quadrature methods that I could look at?

Thank you very much for your help!

from quadgk.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.