I have tried to calculate an interal of a function numericaly  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(x,y)$ which is given by an parametric numerical integral. The definition is
```
A[c_?NumericQ] := Evaluate[2 NIntegrate[(2 ArcCos[Sqrt[1 - c]/Sqrt[(c + Cos[\[Pi] x]) Sec[(\[Pi]x)/2]^2]])/\[Pi],
{x, -((2 ArcCos[Sqrt[1 - c]/Sqrt[1 + c]])/\[Pi]), (2 ArcCos[Sqrt[1 - c]/Sqrt[1 + c]])/\[Pi]}]]

r[x_, y_] := 1/Sqrt[\[Pi]] Sqrt[A[1 - 2/(Cos[\[Pi]/2 x]^-2 + Cos[\[Pi]/2 y]^-2)]]

a = Sqrt[\[Pi]]/2;
\[Phi][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[{\[Phi][x, y], \[Pi]/(2 a) x}, {x, 0, a}, {y, -x, x}]
```
[![][1]][1]

  [1]: https://i.sstatic.net/u6RnU.png

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[\(\[PartialD]\), \(x\)]\(\[Phi][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[\[Pi]]/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[\[Pi]]/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[\[Pi]]/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[\[Pi]] x)/2 is Protected.

During evaluation of In[69]:= NIntegrate::write: Tag Times in (Sqrt[\[Pi]] x)/2 is Protected.

During evaluation of In[69]:= NIntegrate::write: Tag Times in (Sqrt[\[Pi]] 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$.

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!