Numerical Integration with variable limits MATLAB

Click For Summary

Discussion Overview

The discussion revolves around the numerical integration of two functions defined as discrete vectors in MATLAB. Participants explore how to compute a double integral involving these functions, addressing issues related to the discrete nature of the data and the appropriate methods for numerical integration.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant presents a specific numerical integration problem involving functions defined as vectors and seeks guidance on how to implement this in MATLAB.
  • Another participant points out that without further definition, the discrete nature of the functions makes integration problematic.
  • A later post suggests an alternative definition for the functions to facilitate the discussion on integration.
  • Some participants emphasize the importance of understanding numerical integration and MATLAB familiarity for effectively addressing the problem.
  • One participant proposes using the MATLAB function cumsum() for integration, contingent on the x values being evenly spaced.
  • Another participant expresses uncertainty about their level of expertise in MATLAB and numerical integration, indicating a desire to learn from more advanced users.

Areas of Agreement / Disagreement

Participants generally agree that the discrete nature of the functions complicates the integration process, but there is no consensus on the best approach to resolve the issue. Multiple views on how to proceed remain present.

Contextual Notes

There are limitations regarding the assumptions about the spacing of x values and the definitions of the functions. The discussion does not resolve how to handle varying x values or the specifics of numerical integration techniques in this context.

Who May Find This Useful

This discussion may be useful for individuals interested in numerical integration techniques, MATLAB programming, and those facing similar challenges with discrete data in computational contexts.

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   Reactions: 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 8 ·
Replies
8
Views
3K
Replies
5
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
3
Views
3K
Replies
27
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 8 ·
Replies
8
Views
10K