MATLAB Numerical Integration with variable limits MATLAB

Click For Summary
To compute the double integral $$\int_0^1 f(x) \int_x^1 g(y)\, dydx$$ in MATLAB with discrete functions defined as vectors, users should consider the cumulative sum of the values of f(x) and g(y). The function cumsum() can simplify the process if the x values are evenly spaced. If the x values vary, writing a custom function may be necessary. Familiarity with numerical integration concepts and MATLAB is essential for effective implementation. The discussion emphasizes the importance of understanding the integration method and MATLAB's capabilities for handling discrete data.
member 428835
Hi PF!

Suppose I have two functions ##f(x),\,g(y)## that are numerically defined as vectors (i.e. ##g(y) = [0,1,4,9,16]:y = [0,1,2,3,4]## and say ##f(x) = [0,1,8,27,64]:x = [0,1,2,3,4]##) and am trying to compute $$\int_0^1 f(x) \int_x^1 g(y)\, dydx.$$

How would I do this in MATLAB? I could be in the wrong thread here, in which case I'm sorry!
 
Physics news on Phys.org
f and g are defined only for discrete points. Without further definition, there is nothing to integrate.
 
mathman said:
f and g are defined only for discrete points. Without further definition, there is nothing to integrate.
Let's say ##g(x) = x^3## and ##f(y) = y^2##. Now can you help?
 
Rereading my post, that came off a little rude. I'm not trying to be. Just wanting to make sure I have addressed the issue you pointed out. :)
 
It might be better to ask questions about Matlab in the computers and programming section of the forum.

Ask how ##\sum_{k=1}^5 ( \ f(k) \sum_{j=k}^5 g(j)\ )## would be done.
 
  • Like
Likes member 428835
To properly answer this question we need to know how familiar you are with numerical integration and how familiar you are with matlab.

Think about what numerical integration is... you are basically summing up the f(x) values as you sweep the x axis. If you have discrete points this becomes easy, as you are already ready. With some MATLAB knowledge this is fairly easy.
 
The function cumsum() may help you to do this, but only if the x value increases by the same amount every time
Alternatively you may need to write your own function, if you have varying x values.
 
donpacino said:
To properly answer this question we need to know how familiar you are with numerical integration and how familiar you are with matlab.
I'd say I'm pretty familiar with both, but I know some people on here are way more advanced than me, so I'm unsure. I think I'm going to write my own double sum from Stephan Tashi's post. Thanks for your input!
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
5
Views
3K
Replies
27
Views
4K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
10K