# Thread: Software to calculate integrals numerically

1. ## Software to calculate integrals numerically

I need to confirm my own numerical calculation of the following integral with another package - possibly one that calculates to more decimal places. If someone can point me to such software or confirm the result I'd be grateful.

$4\;\int\limits_{ - r}^{ + r} {\left( {R + x} \right)} \sqrt {r^2 - x^2 } \cos ^{ - 1} \left( {\frac{{R - r}}
{{R + x}}} \right)\;dx$

Integral=2553.871 when r=5 & R=27 (angles in radians)

I've derived some possible equations for the integral but they are all giving results that are less than 1% from the numerical results, so I can't tell if the equations are wrong or the numerical answers are wrong.

For example, one equation generates an answer of 2551.2952, another 2553.5994.

If someone could plug in other values of r & R and supply the results, that would also be great.

2. I used my computer program to get $3131.5686$.

EDIT: I programmed the wrong function, the poster had the correct answer.

3. That seems a little bit out. I forgot to mention that angles are in radians (in case you used degrees). Can you double check please. I'm quite sure the result is around 2550 (just by measuring the volume the integral generates). Please don't forget that the trig function is ARCCOS.

Your result seems multiplied by 1-r/R or possibly ARCCOS((R-r)/(R+r)).

4. According to MathCad the value is 2553.873.

5. That's great Plato! Could you please plug in the following values...

r=15 R=81
r=1 R=1.1
r=5 R=10
r=5 R=1,000
r=5 R=1,000,000

This will help me confirm the full range.

6. $\begin{array}{rclcr}
r &\vline & R &\vline & { {\int {} }} \\\hline
{15} &\vline & {81} &\vline & {68954.576} \\
1 &\vline & {1.1} &\vline & {10.225} \\
5 &\vline & {10} &\vline & {1629.010} \\
5 &\vline & {10^3 } &\vline & {15097.521} \\
5 &\vline & {10^6 } &\vline & {477028.661} \\ \end{array}$

7. Thanks very much Plato. These tie up nicely with the results from my own program.

68954.5169
10.224921
1629.00924
15097.509
477028.233

8. Originally Posted by Monkfish
I need to confirm my own numerical calculation of the following integral with another package - possibly one that calculates to more decimal places. If someone can point me to such software or confirm the result I'd be grateful.

$4\;\int\limits_{ - r}^{ + r} {\left( {R + x} \right)} \sqrt {r^2 - x^2 } \cos ^{ - 1} \left( {\frac{{R - r}}
{{R + x}}} \right)\;dx$

Integral=2553.871 when r=5 & R=27 (angles in radians)

I've derived some possible equations for the integral but they are all giving results that are less than 1% from the numerical results, so I can't tell if the equations are wrong or the numerical answers are wrong.

For example, one equation generates an answer of 2551.2952, another 2553.5994.

If someone could plug in other values of r & R and supply the results, that would also be great.
Midpoint rule with h=0.0001 gives integral ~= 2553.8710

.

9. Originally Posted by Plato
$\begin{array}{rclcr}
r &\vline & R &\vline & { {\int {} }} \\\hline
{15} &\vline & {81} &\vline & {68954.576} \\
1 &\vline & {1.1} &\vline & {10.225} \\
5 &\vline & {10} &\vline & {1629.010} \\
5 &\vline & {10^3 } &\vline & {15097.521} \\
5 &\vline & {10^6 } &\vline & {477028.661} \\ \end{array}$
What are the settings used for the numerical integrator? Do we know what error limit the integrator is using? It looks like these values are good for six significant digits.
.

10. What are the settings used for the numerical integrator? Do we know what error limit the integrator is using? It looks like these values are good for six significant digits.
The program I wrote divided the interval into 10,000,000 slices, but 1,000,000 gave the same result to 7 significant figures. I don't know how many significant figures the programming language I used works with, but it might be 20. I just read the manual and it states double-precision floating point accuracy.