simpr1 - x=a h*2*k s2=s2 feval(f,x end s=h(4*s1 2*s2...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function s=simpr1(f,a,b,M) h=(b-a)/(2*M); s1=0; s2=0; for k=1:M x=a+h*(2*k-1); s1=s1+feval(f,x); end for k=1:(M-1)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x=a+h*2*k; s2=s2+feval(f,x); end s=h*(4*s1+2*s2+feval(f,a)+feval(f,b))/3; s...
View Full Document

This note was uploaded on 09/11/2011 for the course MECH 231 taught by Professor Den during the Spring '11 term at Rutgers.

Ask a homework question - tutors are online