Composite Trapezoid rule

34 vues (au cours des 30 derniers jours)
Jason
Jason le 9 Avr 2011
I know for a single integral you would use the cumtrapz function. I have a problem where I have to use the composite trapz rule on a double integral and I can find nothing on how to do that. The function is
(x^2 - 2y^2 +xy^3)dxdy where the outer y limits are -1:1 the inner x limits are 0:2 and n = 2
Any help would be much appreciated. The answer is supposed to be 2.
  23 commentaires
Jason
Jason le 11 Avr 2011
Jiro, I really appreciate that. I finally found somewhat similar application of the com trapz rule that I was able to use to figure it out. I was close originally and it was just missing a simple step. I have never used meshgrid, nor has it been discussed in class to this point so I would never have thought of using it nor would I know how to. Thank you for taking a moment to explain it. I already have the problem figured out but the meshgrid information will be useful in the future.
Jason
Jason le 11 Avr 2011
To clarify the missing part of what I had was to divide the entire B expression by 2n, which in this case would be 4. It's just too obvious, but looking at the basic form of the composite trapezoidal rule clearly shows it. Thanks again for the help even though it was something simple I missed.

Connectez-vous pour commenter.

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 11 Sep 2020
Here is a simple solution to this exercise:
x = -1:0.02:1;
y = -1:0.025:1;
[xx,yy] = meshgrid(x,y);
Fun = xx.^2 -2*yy.^2+xx.*yy.^2;
ALL = cumtrapz(y,cumtrapz(x,Fun,2));
mesh(xx,yy,Fun)
xlabel('x')
ylabel('y')
str = '$$ \int_{-1}^{1} \int_{-1}^{1} (x^2 -2*y^2+x*y^2 )dxdy $$';
zlabel(str,'Interpreter','latex')
hold on
surf(xx,yy,ALL,'FaceAlpha',0.5,'EdgeColor','none')
plot3(xx(end),yy(end),ALL(end),'md', 'markerfacecolor', 'c')
v = [1 1 1];
view(v);

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by