# wolfram mathematica, numerical integration, precision of a function/expression

I want to obtain the best numerical approximation (up to 10 decimal place would be ok for me) to an integral:

$$\int^{\infty}_{0} f(r)r^2dr$$

I am using the function $f(r)$, which is related to the function

$$g(r)=-\frac{\sqrt[3]{3} \sqrt[3]{e^{-2 r}}}{\pi ^{2/3}}-\frac{\sqrt[3]{2 \pi }}{5 \sqrt[3]{e^{-2 r}} \left(\frac{3 \sqrt[3]{\pi } \sinh ^{-1}\left(\frac{2 \sqrt[3]{2 \pi }} {\sqrt[3]{e^{-2 r}}}\right)}{5\ 2^{2/3} \sqrt[3]{e^{-2 r}}}+1\right)}$$

as

$$f(r)=-\frac{1}{4\pi}\nabla^2_{r,\theta,\phi} g(r)$$

Obviously, explicit integration is impossible. The product $f(r)r^2$ is well-behaved and integrable for sure. The function f(r) decays faster than $\frac{1}{r^2}$.

When I try to increase WorkingPrecision, the program says the expression I am integrating itself is not specified so precisely. How can I overcome this? Any tips/ hints?

I am asking about general strategy of how to obtain the most precise value of this integral

NIntegrate[f(r)* 4* \[Pi] r^2, {r, 0, y}, WorkingPrecision -> x] , where y and x are some numbers.

P.S I've been using Mathematica for only two days.

-
What is $f(r)$? Do you even know that the integral is finite? – Christopher A. Wong Dec 18 '12 at 23:40
The integral is finite for sure. – molkee Dec 18 '12 at 23:43
I am asking about general strategy of how to obtain the most precise value of this integral in Mathematica (up to 10 decimal place would be enough for me), so I guess analytic expression for $f(r)*r^2$ is not important. What matters is that f(r) is well-behaved and integrable. – molkee Dec 18 '12 at 23:45
There is a mathematica.stackexchange.com that you could try. Also, have you tried NIntegrate for some large upper bound? You could also try ListIntegrate for specific values of the function which will be less accurate but probably faster. – Jeremy Dec 18 '12 at 23:48

## 2 Answers

Whenever you need to specify numbers in higher precision than machine precision, you can use these options:

• As suggested by @Jonathan, specify precision for number, e.g. 1.330 instead of 1.3.

• Specify exact numbers, e.g. 13/10 instead of 1.3

• Use SetPrecision for your values, e.g.

val=1.3; newval=SetPrecision[val,Infinity]

Also, note that you don't have to specify a finite value as limit of integration. NIntegrate will easily handle Infinity as one or both limits:

NIntegrate[4Pi f[r]r^2,{r,0,Infinity},WorkingPrecision->x]

And don't forget that you evaluate function using square brackets (i.e. f[r]) not parentheses as your expression.

-

You are probably specifying some parameter to your integrand with a decimal point. It would be easier to tell if you specified the command you were trying. Instead of giving something like 1.3, try 1.330 to specify precision of 30 digits. That's the backtick, conjugate to ~ on your keyboard.

-