non continuous double integration

1 次查看(过去 30 天)
I am looking to integrate the following function 5sin(x) dx dy, however I am only aware of performing integrals for specific upper bounds using integral2.
Does anyone know if it is possible/how to perform this double integration given x and y are non continuous set of numbers. x and y, x=[20 33 47 85] and y=[10 22 43 98].
*Sorry if the title isn't clear
  2 个评论
John D'Errico
John D'Errico 2021-6-6
编辑:John D'Errico 2021-6-6
Sure. The integral is zero. The integral of ANY finite function over a set of discrete points is zero. Wow! That was an easy one to solve! Sorry, but this is the answer to your question, AS ASKED.
Would you like to clarify your question? That is, if my answer is not what you were asking about? For example, perhaps you want to solve a problem where something like trapezoidal rule might be employed, evaliuating the function only at that set of points to compute the integral over a finite (but non-zero measure interval). But that is a VERY different question than what you asked.
Ahmed Abdulla
Ahmed Abdulla 2021-6-6
Thank you for your time, sorry I am not very sure how to word it.
To apply the trapezoidal rule, should i evaluate the integrated function at each set of points then sum up the findings?

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2021-6-6
Ok, now that we understand the question, it is easy. Just use trapz, TWICE.
To apply the trapezoidal rule, you will create a matrix of 4x4 elements. Then call trapz twice, once on each dimension of the array. I won't do your problem here, since this seems too much likely to be homework.
But for example, suppose I wanted to integrate the function
z = x.^3 + x.*y^2
over the domain (x,y) = [20,85] X [10,98], where we will sample the function at that set of nodes? This is VERY different from what you wanted to call a discontinuous point set of some sort.
Zfun = @(X,Y) X.^3 + X.*Y.^2;
Xnodes = [20 33 47 85];
Ynodes = [10 22 43 98];
[x,y] = meshgrid(Xnodes,Ynodes)
x = 4×4
20 33 47 85 20 33 47 85 20 33 47 85 20 33 47 85
y = 4×4
10 10 10 10 22 22 22 22 43 43 43 43 98 98 98 98
z = Zfun(x,y)
z = 4×4
10000 39237 108523 622625 17680 51909 126571 655265 44980 96954 190726 771290 200080 352869 555211 1430465
intest = trapz(Xnodes,trapz(Ynodes,z,1),2)
intest = 2.4820e+09
How accurate is that estimate? Remember, this is just trapezoidal integration, over a VERY coarse set of nodes.
syms X Y
int(int(X.^3 + X.*Y.^2,X,20,85),Y,10,98)
ans = 
2214362150
So the trapezoidal estimate was within 10% of the exact value. Probably as good as we could do on that set of nodes.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by