# Thread: Integral involving logarithm and square root

1. ## Integral involving logarithm and square root

Hey I'm trying to solve the following integrals:

$

\int x^{i}\log(x+k+m\sqrt{x^2+n})dx,
$

for $i=0,1,2$ and suitalbe constants $k, m,$ and $n$.

I tried to find an anti-derivative via integration by parts - with no success.

Does anyone else have an idea?

Thanks a lot in any case,
DeeAna

2. I think your only option is approximation.

3. Thanks Anonymous1,

I thought so, too. Mathematica, however, was able to give me an antiderivative, which I don't completely trust. It is pretty long and also plugging in the integration command several times gave me different solutions. Then I started testing the Mathematica "anti-derivative" by differentiating and then trying to simplify, which didn't work. Then I just checked a couple of values, comparing the derivative of the "anti-derivative" with the integrand above. They were more or less the same. Lastly, I computed numerically a definite integral of the above and compared it to what I obtain when plugging in the boundaries in the Mathematica anti-derivative and subtracting. This, however, yields only in about 80 percent of the cases the same results, which is rather confusing...

But if Mathematica can give me a solution, then there should be a way to do this. Don't you think?

4. Originally Posted by DeeAna
Thanks Anonymous1,

I thought so, too. Mathematica, however, was able to give me an antiderivative, which I don't completely trust. It is pretty long and also plugging in the integration command several times gave me different solutions. Then I started testing the Mathematica "anti-derivative" by differentiating and then trying to simplify, which didn't work. Then I just checked a couple of values, comparing the derivative of the "anti-derivative" with the integrand above. They were more or less the same. Lastly, I computed numerically a definite integral of the above and compared it to what I obtain when plugging in the boundaries in the Mathematica anti-derivative and subtracting. This, however, yields only in about 80 percent of the cases the same results, which is rather confusing...

But if Mathematica can give me a solution, then there should be a way to do this. Don't you think?
You may be running into branch-cut problems with the log and square root functions in the antiderivative which might cause different answers depending on what the values of k, m, n, i are. Mathematica always uses the principal-value for a multi-valued function and that may not be the correct "analytically-extended" choice for the value of the antiderivative at the limit points. What values of k, m, n, i and the upper and lower limits give a value different than the numerical result?

5. Hey shawsend,

thanks for your explanation. I wasn't quite aware of what Mathematica does. For the definite integral, I obtained for the following choices of i,xmax, xmin, k,m and n different solutions when integrating numerically compared to the result obtained with the help of the Mathematica anti-derivative:

1) i=2:

xmax = - 0.5070..
xmin = 0.9071...
k = 0.3050...
m = 1.4142...
n = 0.5930...

2) i=2:

xmax = - 0.9071...
xmin = 0.5071...
k = - 0.3050
m = 1.4142...
n = 0.5930

3) i=1:

xmax = - 1.5071...
xmin = -0.0928...
k = -0.6949...
m = 1.4142...
n = 0.9829...

- whereas for example for all i

xmax = 0.0428..
xmin = 1.4571...
k = 0.6035...
m = 1.4142...
n = 0.8642...

or

xmax = - 0.9571...
xmin = 0.4571..
k = - 0.3964
m = 1.4142...
n = 0.6571...

yielded the correct result - or a result very close to the one obtained by numerical integration. I hope I didn't mix up the numbers and also I noticed that my xmax always seems to be smaller than my xmin.

Speaking of approximating the integral: What method do you think would be appropriate? I tried Gauss-Chebyshev quadrature. The convergence rate was pretty slow. In order to obtain an exactness of ~10e-6, I needed at least nine iteration steps. When calculting many integrals the speed is not even close to Matlab's quad-command. Is there an obvious explanation for that? What other method could be useful in this context?

Many thanks,
DeeAna

6. Let's just look at the first one for i=2 and arbitrary k,m, and n:

myanti = Integrate[
x^2*Log[x + k + m*Sqrt[x^2 + n]], x];

Now plot the real part of that between the limits:

Plot[Re[myanti /. {k -> 0.305,
m -> 1.4142, n -> 0.593}],
{x, -0.507, 0.9071}, PlotRange -> All]

Note in the plot below how there is a jump discontinuity in the plot. That is because Mathematica is using the principal values for any multi-valued function in the antiderivative and the limits in this particular case passes through a principal branch-cut. In order to evaluate an integral of a multi-valued function using its antiderivative, we must use it's analytic-extension. For example, if we were to analytically extend the top curve along it's underlying Riemann surface to the point x=0.9072 , then that would represent the analytic extension and we could then take the difference of it's values at the end points to compute the integral. However, that's tough to implement in the general sense without quite a bit of computational effort. This is a Mathematica limitation and the reason why some of your integrals agree and some do not is probably because in some cases, your limits do not pass through a principal branch-cut.

And in regards to your questions about numerical integration techniques, I'm not an expert in that. However, Mathematica has an extensive help section on "Advanced Integration Techniques" that would probably help you. You can get to it from the Integrate help page.

7. Thanks shawsend, you really helped me! I will need to do some background reading on "Riemann surfaces" and "analytical extension" along them - but at least I know now where the problems are;-)