1
$\begingroup$

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.

Thanks

  • 0
    Re the question title: As far as I know, quadrature _is_ (a somewhat oldfashioned term for) integration.2012-02-22
  • 0
    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. http://en.wikipedia.org/wiki/Numerical_integration#Quadrature_rules_based_on_interpolating_functions2012-02-22

1 Answers 1

4

THE CORRECT ANSWER FOR CORRECT QUESTION IS

$$ \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

  • 1
    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)$.2012-02-22
  • 0
    @Chris I edited your question. Next time, try to clearly write the equation in $\LaTeX$2012-02-22
  • 0
    @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.2012-02-22
  • 0
    Peter, thanks for putting it into latex but the questions was for x/(d^2−x^2). cheers2012-02-22
  • 0
    @ChrisTaylor I was suspecting that. But I don't know why I thought you were the OP! Sorry!2012-02-22