[SciPy-User] numerical integration with square root like singularity

153 views
Skip to first unread message

Daniel Platz

unread,
Nov 24, 2011, 9:16:22 AM11/24/11
to scipy-user
Hi,

I am stuck with a problem in scipy. I want to numerically integrate a
function with a square root like singularity at one end of the
integration interval. The integral has the form

\int_{0}^{1} f(x) * x / sqrt(1-x**2) dx

or alternatively

\int_{0}^{A} f(x) / sqrt(A-x) dx.

Can the quad function in scipy deal with this kind of singularity. I
tried to use the points argument of the quad function but I still get
warning messages and do not know how much I can trust the results.

Alternatively, I was wondering if I can implement a Chebyshev–Gauss
quadrature myself to lift the singularity? Or is there a way to do
this elegantly using scipy?

I would be very glad about a short answer.

Best regards,

Daniel Platz
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Pauli Virtanen

unread,
Nov 24, 2011, 9:25:27 AM11/24/11
to scipy...@scipy.org
24.11.2011 15:16, Daniel Platz kirjoitti:
[clip]

> \int_{0}^{A} f(x) / sqrt(A-x) dx.
>
> Can the quad function in scipy deal with this kind of singularity. I
> tried to use the points argument of the quad function but I still get
> warning messages and do not know how much I can trust the results.
[clip]

Yes, `quad` supports weight functions of this form (see its `weight` and
`wvar` arguments). Run

scipy.integrate.quad_explain()

to find what to specify as these arguments

--
Pauli Virtanen

Charles R Harris

unread,
Nov 24, 2011, 9:48:58 AM11/24/11
to SciPy Users List
On Thu, Nov 24, 2011 at 7:16 AM, Daniel Platz <mail.to.da...@googlemail.com> wrote:
Hi,

I am stuck with a problem in scipy. I want to numerically integrate a
function with a square root like singularity at one end of the
integration interval. The integral has the form

\int_{0}^{1} f(x) * x / sqrt(1-x**2) dx

or alternatively

\int_{0}^{A} f(x) / sqrt(A-x) dx.

Can the quad function in scipy deal with this kind of singularity. I
tried to use the points argument of the quad function but I still get
warning messages and do not know how much I can trust the results.

Alternatively, I was wondering if I can implement a Chebyshev–Gauss
quadrature myself to lift the singularity? Or is there a way to do
this elegantly using scipy?

I would be very glad about a short answer.


The substitution y^2 = A - x in the second form will eliminate the singularity.

Chuck

Reply all
Reply to author
Forward
0 new messages