I am using the following code to compute the surface area, mean integrated curvature, and Euler characteristic of the ellipsoid parameterized by r(x,y). Here 'x' and 'y' represent the angles $\theta$ and $\phi$ in spherical coordinates. The code is
a=value1; b=value2; c=value2;
r=[a*cos(y)*sin(x), b*sin(x)*sin(y), c*cos(x)];
n=cross(r_x,r_y)/norm(cross(r_x,r_y));
K=((E*N)+(G*L)-(2*F*M))/A;
dA_=matlabFunction(dA); dC_=matlabFunction(dC); dX_=matlabFunction(dX);
S = integral2(dA_, 0, 2*pi, 0, pi);
C = (1/2)*integral2(dC_, 0, 2*pi, 0, pi);
X = (1/(2*pi))*integral2(dX_, 0, 2*pi, 0, pi);
S and X give me very well, but the problem is with C, which always gives me very small, of the order of 1e-16 to 1e-14, which is absurd since C must be of the order of 4*pi*r (for the case of a sphere a=b=c=r). Could someone tell me what is wrong?