Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have been having a few issues using the quadrature function in python 2.7 (part of the scipy.integrate module). The equation I am trying to integrate is simply:

$$ \frac{x}{d^2-x^2}$$

The integration is between limits a and b. However, I need to do the integration at 40 different values of d and am not sure how to pass in the second argument so as to loop the integration over the values of d. Any help would be much appreciated and is quadrature the best way to evaluate this problem.


share|improve this question
Re the question title: As far as I know, quadrature is (a somewhat oldfashioned term for) integration. –  Harald Hanche-Olsen Feb 22 '12 at 15:44
Nowadays, I know that in numerical analysis the term 'quadrature' is used to refer to integration rules based on interpolating polynomials. I this case, you may as well use the elementary anti-derivative. en.wikipedia.org/wiki/… –  dls Feb 22 '12 at 16:30

1 Answer 1

up vote 4 down vote accepted


$$ \int_a^{b} \frac{x}{d^2} - x^{2} $$

$$ = \left( \frac{x^2}{2d^2} - \frac{x^3}{3} \right) $$

$$ = x^2 \left( \frac{1}{2d^{2}} - \frac{x}{3} \right) $$

$$ = \frac{x^2}{6d^2} (3-2d^{2}x) $$

Now apply the limits from a to b

$$ = \frac{1}{2d^2}(b^2-a^2) - \frac{1}{3}(b^3-a^3) $$

To simplify further

$$ = (b-a) \left( \frac{(a+b)}{2d^2} - \frac{(b^2+ab-a^2)}{3} \right)$$

If you are writing a program then

$$ = \frac{(b^2-a^2)}{2d^2} - (b-a)\frac{b^2+ab-a^2}{3} $$ would be better because the second expression (with a 3 in the bottom) is only evaluated once

share|improve this answer
It may (or may not) be worth pointing out that the expression x/(d^2)-(x^2) in Python is equivalent to the function $(x/d^2) - x^2$, rather than $x/(d^2-x^2)$. –  Chris Taylor Feb 22 '12 at 13:33
@Chris I edited your question. Next time, try to clearly write the equation in $\LaTeX$ –  Pedro Tamaroff Feb 22 '12 at 14:26
@Peter (i) I don't think you meant to address that to me, and (ii) you don't know whether the OP means $x/d^2-x^2$ or $x/(d^2-x^2)$, so your edit may have changed the meaning of the question. –  Chris Taylor Feb 22 '12 at 14:36
Peter, thanks for putting it into latex but the questions was for x/(d^2−x^2). cheers –  Karim Sutton Feb 22 '12 at 14:46
@ChrisTaylor I was suspecting that. But I don't know why I thought you were the OP! Sorry! –  Pedro Tamaroff Feb 22 '12 at 14:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.