Integrating min and max function
2 views (last 30 days)
Show older comments
I learn how to evaluate a integral using the int() function in MATLAB, but if there is an integral whose integrant involves a min or max function, like
, can we use some method to find an analytical formula?

1 Comment
Burak Kurtulan
on 23 Dec 2020
Hello, I need to learn that as well. I have a highly complicated function which cannot be seperated. How did you solve your problem? Could you share with me?
Answers (1)
Bjorn Gustavsson
on 17 Sep 2020
This might not be the most elegant solution to this, but it's a first stab. Take a quick-look at what the function looks like:
[X,Y] = meshgrid(linspace(0,1,1001));
figure
imagesc(X(1,:),Y(:,1),max(X,Y))
Then you see that it should be possible to divide the region you want to integrate over in two triangular parts, one where the function takes the value of X and one where it takes a value of Y. Those functions over those regions should be simple enough to integrate over. That aproach kind of works for simlpe cases like in your example where we get one or a couple of separate regions where the function is smooth and well-behaved. In this example direct numerical integration works both on your initial function over the 0<x<=1, 0<y<=1 region, just follow the examples in the help of integral2.
HTH
3 Comments
Bjorn Gustavsson
on 18 Sep 2020
Well, I'm not sure that the symbolic int-function handles this too well. My suggestion is that you start by having a look at the function in different slices for some values of x3, then x2 and x1 - that way you might start to figure out how to partition the region of integration, once you have some analytical expressions for the integration-limits then you have separated the integral into a sum of smaller and simpler integrals that should be easier for int to handle.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!