Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Double integral using Simpsons rule!

Subject: Double integral using Simpsons rule!

From: Saud Alkhaldi

Date: 26 May, 2012 22:32:24

Message: 1 of 2

Hi Everyone,

This is my final project for my numerical methods class and I'm having some trouble with it. It would be great if you can help me :)
I'm trying to use Simpsons 1/3 rule to find the 2d integral of (x^2)+(y^2)dydx with the limits of x from -0,824 to 0.824 and the y limits are g(x)=x^2 to p(x)=cos(x) with 20 intervals in each direction!
This is what I got so far: ( I wasn't too sure if I should start integrating the inner integral (dy) first or the outer (dx))


hx = (0.824+0.824)/20; % steps in x direction
I=G(-0.824)+G(0.824);
for i = a+h:2*h:b
    I = I + 4*G(i);
end
for j = (a+2*h):2*h:(b-2*h)
    I = I + 2*G(j);
end
I = h*I/3;
for i=a+h:2*h:b
hy=(p(x(i))-g(x(i)))/4;
for j=
II=Fund(x(i),y(j))+Fund(x(i),y(j)) % problem
end
end
for j=g(x(i))+h:2*h:p(x(i))
II=II + 4*Fund((xi),y(j))
end
for
    II=I+2*Fund(x(i),y(j)
end

Thanks much in advance!

Subject: Double integral using Simpsons rule!

From: Roger Stafford

Date: 27 May, 2012 00:03:33

Message: 2 of 2

"Saud Alkhaldi" wrote in message <jprllo$l6b$1@newscl01ah.mathworks.com>...
> I'm trying to use Simpsons 1/3 rule to find the 2d integral of (x^2)+(y^2)dydx with the limits of x from -0,824 to 0.824 and the y limits are g(x)=x^2 to p(x)=cos(x) with 20 intervals in each direction!
- - - - - - - - -
  In case it is of interest to you, your double integral can be solved using the methods of elementary calculus (or with the symbolic toolbox.) You don't have to resort to numerical methods.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us