I want to find the double integral of the following function (sin(x+3*y))^2*exp(x-2*y)/(x^2+2). Limits are x and y from -1 to 1.
N = 5;x = linspace(-1, 1,N);y = linspace(-1, 1,N);dx = diff(x(1:2));dy = diff(y(1:2));[x,y] = meshgrid(x,y);mat = (sin(x+3.*y)).^2.*exp(x-2.*y)/(x.^2+2);mat(2:end-1,:) = mat(2:end-1,:)*2;mat(:,2:end-1) = mat(:,2:end-1)*2;out = sum(mat(:))*dx*dy/4
I edited this code to suit my function but it shows result as NaN with the following message:
In doubletraptest (line 7) Warning: Matrix is singular to working precision
Best Answer