# Multivariate integration of a compicated expression

I have an expression in multiple variables that is something like

4.85746*10^-7 Cos[ϕ] (1 +
1/2 (Abs[(-1.5782 Sqrt[1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])/(1.5782 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2 +
Abs[(1.329 Sqrt[1 - z^2 Sin[ϕ]^2] -
1.5782 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])/(1.329 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.5782 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2) Cos[
2 ArcSin[
z Sin[ϕ]]] - ((1 +
1/2 (-Abs[(-1.5782 Sqrt[1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[
1 - 0.70913 z^2 Sin[ϕ]^2])/(1.5782 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2 -
Abs[(1.329 Sqrt[1 - z^2 Sin[ϕ]^2] -
1.5782 Sqrt[
1 - 0.70913 z^2 Sin[ϕ]^2])/(1.329 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.5782 Sqrt[
1 - 0.70913 z^2 Sin[ϕ]^2])]^2))^2 (Cos[
2 ArcSin[0.842099 z Sin[ϕ]] -
2 ArcSin[z Sin[ϕ]]] +
1/2 (Abs[(-1.5782 Sqrt[1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[
1 - 0.70913 z^2 Sin[ϕ]^2])/(1.5782 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2 +
Abs[(1.329 Sqrt[1 - z^2 Sin[ϕ]^2] -
1.5782 Sqrt[
1 - 0.70913 z^2 Sin[ϕ]^2])/(1.329 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.5782 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2) Cos[
2 ArcSin[z Sin[ϕ]]]))/(1 +
1/4 (Abs[(-1.5782 Sqrt[1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])/(1.5782 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2 +
Abs[(1.329 Sqrt[1 - z^2 Sin[ϕ]^2] -
1.5782 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])/(1.329 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.5782 Sqrt[
1 - 0.70913 z^2 Sin[ϕ]^2])]^2)^2 + (Abs[(-1.5782 \
Sqrt[1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])/(1.5782 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.329 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2 +
Abs[(1.329 Sqrt[1 - z^2 Sin[ϕ]^2] -
1.5782 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])/(1.329 Sqrt[
1 - z^2 Sin[ϕ]^2] +
1.5782 Sqrt[1 - 0.70913 z^2 Sin[ϕ]^2])]^2) Cos[
2 ArcSin[0.842099 z Sin[ϕ]]]))


I want to integrate this expression first w.r.t. ϕ with limits 0 to 7 π/18 and then indefinite integral Integrate[F, z] w.r.t z. I tried it in many ways, but it is very difficult for me to solve this integral. Can anyone help to find out the solution of this integral. I would be highly obliged.

• I highly doubt you can find an indefinite integral here. Such complicated functions are usually best solved numerically. Commented Jul 1, 2016 at 11:08
• Are you certain that you need a symbolic result? What do you want to use it for? Commented Jul 1, 2016 at 11:31
• after this integral i want to plot graph between thisfunction and z. Commented Jul 2, 2016 at 13:55

The integrand cannot be solved when $|z|\rightarrow1$ Therefore, let's integrate the function on a possible domain, numerically.

zdat=Table[NIntegrate[f, {Phi, 0, 7 Pi/18}, {z, 0, i}], {i, -0.95, 0.95, 0.1}];


This gives us a list of values, from which we can approximate a function for this part of the domain for z. Plotting this list gives us:

lp = ListPlot[data = Transpose[{Table[i, {i, -0.95, 0.95, 0.1}], zdat}]]


We can use this to formulate an approximate function for z. The function appears to be odd, and includes the point {0,0}, and we can try an odd polynomial.

nlm = NonlinearModelFit[data, a z + b z^3, {a, b}, z]//Normal


1.2737*10^-8 z + 8.36705*10^-9 z^3

Show[Plot[nlm, {z, -0.95, 0.95}, PlotStyle -> Red], lp]


Adding a fifth order term barely changes the plot.

nlm2 = NonlinearModelFit[data, a z + b z^3 + c z^5, {a, b, c}, z] //
Normal

Plot[{nlm, nlm2}, {z, -0.95, 0.95}, PlotStyle -> {Red, {Dashed, Black}}]


Therefore the third order polynomial appears to approximate the function you seek quite well.

$$1.2737\times 10^{-8} z + 8.36705\times 10^{-9} z^3$$

When we extend the domain, the integrand becomes highly oscillatory, the errors in the numerical integration become quite large.

At this point, the function becomes rather more complicated, the function is then better approximated with an interpolating function:

zdat = Table[NIntegrate[f, {\[Phi], 0, 7 Pi/18}, {z, 0, i},
Method -> {"GlobalAdaptive",MaxErrorIncreases -> 10000}], {i, -2.01, 2.01, 0.1}];

data = Re[zdat];
data = Transpose[{Table[i, {i, -2.01, 2.01, 0.1}], data}];
ip = Interpolation[data];
Show[Plot[ip[z], {z, -2.01, 1.9900000000000002}, PlotStyle -> Red],ListPlot[data]]


• but i want to plot in -2 to 2 range.Is their any possible solution for that . Commented Jul 3, 2016 at 10:27
• @AnitaMaheshwari I've extended my answer. Commented Jul 3, 2016 at 12:28
• I am running these command again and again but it is showing me some error like its not a valid command for z and so, Commented Jul 4, 2016 at 4:15
• I have one more question this is the plot only for phi integral.their is any possiblity to integrate this function w.r.t z?? Commented Jul 4, 2016 at 4:16
• whatever you did may be its correct but the nature of the curve is not correct because the way you did in this is you are integrating w.r.t particular value every time that's why it will give you the nature of curve same as after integrating phi if you plot after phi integration is same as this curve.That's why i want separate indefinite integral of z. Commented Jul 4, 2016 at 9:48

One can use NDSolve to construct a particular "indefinite" integral, e.g., $$f(z) = \int_0^z f'(ζ) \; dζ$$

First define integrand to be the OP's expression. The the following computes its integral.

Clear[df];
df[z0_?NumericQ] :=
df[z0] = NIntegrate[integrand /. z -> z0, {ϕ, 0, 7 Pi/18},
Method -> {"GaussKronrodRule", "Points" -> 11},
MaxRecursion -> 20];
{fsol} = NDSolve[{f'[z] == df[z], f[0] == 0},
f, {z, -2., 2.}]; // AbsoluteTiming
(*  {1.89007, Null}  *)


The function is an InterpolatingFunction that can be obtained with f /. fsol or plotted with f[z] /. fsol. See the documentation for NDSolve for more examples.

Plot[f[z] /. fsol, {z, -2., 2.}]


• when I run this integral in my mathematica 10.0 it showed me many error .Can you please tell me what should i do to remove all these error? Commented Jul 4, 2016 at 4:27
• @AnitaMaheshwari Did you define integrand to be your integrand? Commented Jul 4, 2016 at 5:08
• whatever you did may be its correct but the nature of the curve is not correct because the way you did in this is you are integrating w.r.t particular value every time that's why it will give you the nature of curve same as after integrating phi if you plot after phi integration is same as this curve.That's why i want separate indefinite integral of z. Commented Jul 4, 2016 at 9:47
• @AnitaMaheshwari Like I said from the get-go, integrating this function symbolically is impossible. An interpolating function, is as good as it gets. Commented Jul 4, 2016 at 11:02
• can you please explain your code briefly because i tried that thing in mathematica 10 and i found nothing.Its a humble request if you can do this??taking main function to f. Commented Jul 6, 2016 at 4:18