non continuous double integration
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ahmed Abdulla
le 6 Juin 2021
Réponse apportée : John D'Errico
le 6 Juin 2021
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 commentaires
John D'Errico
le 6 Juin 2021
Modifié(e) : John D'Errico
le 6 Juin 2021
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.
Réponse acceptée
John D'Errico
le 6 Juin 2021
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)
z = Zfun(x,y)
intest = trapz(Xnodes,trapz(Ynodes,z,1),2)
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)
So the trapezoidal estimate was within 10% of the exact value. Probably as good as we could do on that set of nodes.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!