I have tried to calculate an integral of a function numerically using NIntegrate
, but sadly it seems like I do not get the correct result from it.
The function $\phi(x,y)$ is defined using a function $A(c)$ which is given by an parametric numerical integral. The definition is
A[c_] := Evaluate[2 NIntegrate[(2 ArcCos[Sqrt[1 - c]/Sqrt[(c + Cos[π x]) Sec[(πx)/2]^2]])/π,
{x, -((2 ArcCos[Sqrt[1 - c]/Sqrt[1 + c]])/π), (2 ArcCos[Sqrt[1 - c]/Sqrt[1 + c]])/π}]]
r[x_, y_] := 1/Sqrt[π] Sqrt[A[1 - 2/(Cos[π/2 x]^-2 + Cos[π/2 y]^-2)]]
a = Sqrt[π]/2;
ϕ[x_, y_] := 2 ArcSin[1/Sqrt[2] a r[x/a, y/a]];
The function $\phi(x,y)$ defined in the triangle with corner points of $(0,0), (a,a), (a,-a)$ for $a=\frac{\pi}{2}$. By ploting the function $\phi(x,y)$ we can see it is pretty simillar to the function $\frac{\pi}{2a}x$:
Plot3D[{ϕ[x, y], π/(2 a) x}, {x, 0, a}, {y, -x, x}]
Therefore I expect the integral $$\intop_{0}^{a}\intop_{-x}^{x}\left(\frac{\partial\phi}{\partial x}\right)^{2}dydx$$ to be close to $a^2\cdot(\frac{\pi}{2a})^2=\frac{\pi^2}{4}\approx2.467$. But when I'm integrating numerically over $\left(\partial_{x}\phi\right)^{2}$ I get something very different:
In[69]:= NIntegrate[(\!\(\*SubscriptBox[\(∂\), \(x\)]\(ϕ[x, y]\)\))^2, {x, 0, a}, {y, -x, x}]
During evaluation of In[69]:= NIntegrate::nlim: x = Indeterminate is not a valid limit of integration.
During evaluation of In[69]:= General::ivar: Sqrt[π]/2 is not a valid variable.
During evaluation of In[69]:= NIntegrate::nlim: x = Indeterminate is not a valid limit of integration.
During evaluation of In[69]:= General::ivar: Sqrt[π]/2 is not a valid variable.
During evaluation of In[69]:= NIntegrate::nlim: x = Indeterminate is not a valid limit of integration.
During evaluation of In[69]:= General::stop: Further output of NIntegrate::nlim will be suppressed during this calculation.
During evaluation of In[69]:= General::ivar: Sqrt[π]/2 is not a valid variable.
During evaluation of In[69]:= General::stop: Further output of General::ivar will be suppressed during this calculation.
During evaluation of In[69]:= NIntegrate::write: Tag Times in (Sqrt[π] x)/2 is Protected.
During evaluation of In[69]:= NIntegrate::write: Tag Times in (Sqrt[π] x)/2 is Protected.
During evaluation of In[69]:= NIntegrate::write: Tag Times in (Sqrt[π] x)/2 is Protected.
During evaluation of In[69]:= General::stop: Further output of NIntegrate::write will be suppressed during this calculation.
During evaluation of In[69]:= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.
During evaluation of In[69]:= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 18 recursive bisections in x near {x,y} = {0.93974199467253037576508489792104228399693965911865234375000000000,0.713879}. NIntegrate obtained 0.605531 +0.0100204 I and 0.00006594026997516764` for the integral and error estimates.
Out[69]= 0.605531 + 0.0100204 I
I get many warnings which are probably due to the definition of $A(x,y)$, but in other cases I did this I got the correct results despite these warnings. In this case I get that the integral fail to converge, and indeed the result I get here is $0.605531$ (plus an imagenary contribution) is probablt too far from the approximately expected $2.467$.
I tried many integration methods using the Methods
option, but non of them helped. Monte-Carlo methods also gave results of about $0.605$.
In addition I tried to calculate the integral by definin $A(c)$ using A[c_?Qnumeric]
. In this case the integral did not give results at all.
Does anyone know what the problem is? Am I wrong and the integral is so different from the one over $\frac{\pi}{2a}$ despite the similar apperence of the functions?
Thank you!