Solution:- I have given the required below:-
A) function I1 = TrapezoidalRule2D(a, b, c, d, m, n, func)
h = (b-a)/m;
k = (d-c)/n;
I11 =0;
I12 =0;
I13 =0;
I14 =0;
I15 =0;
for i = 1:m-1
xi = a + i*(h);
I11 = I11 + func(xi, c);
I22 = I22 + func(xi, d);
end
for j = 1:n-1
yj = c + j*(k);
I13 = I13 + func(a, yj);
I14 = I14 + func(b, yj);
end
for j = 1:n-1
for i = 1:m-1
xi = a + i*(h);
yj = c + j*(k);
I15 = I15 + func(xi, yj);
end
end
I1 = (h)*(k)*(0.25)*(func(a,c) + func(b,c) + func(a,d) + func(b,d)
+ 2*(I11 + I12 + I13 + I14) + 4*(I15));
end
B)
function I2 = SimpsonRule2D(a, b, c, d, m, n, func)
h = (b-a)/2*(m);
k = (d-c)/2*(n);
I21 =0;
I22 =0;
I23 =0;
I24 =0;
I25 =0;
I26 =0;
I27 =0;
I28 =0;
I29 =0;
I210 =0;
I211 =0;
I212 =0;
for j = 1:n
yj = c + (2*(j) - 1)*(k);
I21 = I21 + func(a, yj);
I23 = I23 + func(b, yj);
end
for j = 1:n-1
yj = c + 2*j*(k);
I22 = I22 + func(a, yj);
I24 = I24 + func(b, yj);
end
for i = 1:m
xi = a + (2*(i) - 1)*(h);
I25 = I25 + func(xi, c);
I26 = I26 + func(xi, d);
end
for i = 1:m-1
xi = a + 2*i*(h);
I27 = I27 + func(xi, c);
I28 = I28 + func(xi, d);
end
for j = 1:n
for i = 1:m
xi = a + (2*(i) - 1)*(h);
yj = c + (2*(j) - 1)*(k);
I29 = I29 + func(xi, yj);
end
end
for j = 1:n-1
for i = 1:m
xi = a + (2*(i) - 1)*(h);
yj = a + 2*(j)*(k);
I210 = I210 + func(xi, yj);
end
end
for j = 1:n
for i = 1:m-1
xi = a + 2*(i)*(h);
yj = c + (2*(j) - 1)*(k);
I211 = I211 + func(xi, yj);
end
end
for j = 1:n-1
for i = 1:m-1
xi = a + 2*(i)*(h);
yj = c + 2*(j)*(k);
I212 = I212 + func(xi, yj);
end
end
I2 = (1/9)*(h)*(k)*(func(a,c) + func(b,c) + func(a,d) + func(b,d) + 4*(I21 + I23 + I25 + I26 + I212) + 2*(I22 + I24 + I27 + I28) + 8*(I210 + I211) + 16*(I29));
end


I hope it solves your problem if you have any doubt please ask in the comments and if you liked the solution please upvote. Thanks.
Problem 6 (programming): Consider a two-dimensional function f(x.y) stored in the file f.mat on TritonED. Down load the...
Problem 3 (hand-calculation): Consider a two-dimensional function: f(x, y)- sin(x)cos() where x and y are in radi ans (a) Evaluate a f/oz, f / ду, and /(8z0) at x = y = 1 analytically. (b) Evaluate af/az. Э//ду, and Эг f/0гду) at x = y = 1 numerically using 2nd-order central difference formula with a grid spacing h -0.1. Take a photo of your work. Include all pages in a single photo named problem3.jpg. Set the following in your homework...
1)
a) Write MATLAB function that accepts a positive integer
parameter n and returns a vector containing the values of the
integral (A) for n= 1,2,3,..., n. The function must use the
relation (B) and the value of y(1). Your function must preallocate
the array that it returns. Use for loop when writing your code.
b) Write MATLAB script that uses your function to calculate the
values of the integral (A) using the recurrence relation (B), y(n)
for n=1,2,... 19...