Answers for "simpson's rule mathlab"

0

simpson's rule mathlab

function [S] = SimpI(a,b,n,f)
syms x;
h = (b-a)/n;
c= ones (1,n+1);
c(2:end-1) = 2;
c(2:2:end-1) = 4;
sum=0;
for i=1:1:n-1
    sum= sum + c(i+1)*f(a+i*h);

S =  h/3*(f(a)+f(b)+sum);
end
Posted by: Guest on March-18-2022

Browse Popular Code Answers by Language