Register to reply 
Matlab  multiple integral Riemann sums 
Share this thread: 
#1
Apr3012, 01:28 AM

P: 15

1. The problem statement, all variables and given/known data
Write an m.file that will integrate a function [itex]f(x, y)[/itex] on any given rectangle [itex] (a,b)\times(c,d)[/itex] and returns the value of the integral from [itex]a [/itex] to [itex] b [/itex] and [itex]c [/itex] to [itex]d [/itex] of the function [itex]f(x,y) [/itex]. Include errorcatching code in the case that the integral diverges. The program should use the notion of a limit of sums, so that you increase the number of Riemann cubes until the approximate value of the integral shows a relative error [itex]\displaystyle \frac{S_{new}  S_{old}}{S_{new}}[/itex] of less than 0.001. 2. Relevant equations 3. The attempt at a solution Ok so here is what I have right now
This is what it returns (without the table)
Any kind of help would be awesome! 


#2
Apr3012, 06:41 PM

P: 280



#3
May312, 10:16 PM

P: 317

You have three possible exit conditions for your loop. One is a divergence catch, which isn't an issue here. The second is achieved convergence, and the third is if the number of iterations exceeds the number "itmax." You have set this maximum at 100, and clearly it's taking 100 iterations, which means it hasn't converged because it's reached that limit and not gotten within the desired error yet. I am guessing the reason you don't reach convergence within 100 steps is that you are only increasing [itex]n[/itex] by one each time. Probably a better strategy is to double it with each iteration.



Register to reply 
Related Discussions  
Theory behind Integral Test with Riemann Sums  Calculus & Beyond Homework  3  
Definite Integral of the Natural Log of a Quadratic using Riemann Sums  Calculus & Beyond Homework  16  
Definite integral using Riemann sums?  Calculus & Beyond Homework  1  
Approximating integral using riemann sums  Calculus & Beyond Homework  3  
Integral Question (Riemann Sums)  Calculus & Beyond Homework  3 