can you solve this problem in matlab the result from trapezo
can you solve this problem in matlab, the result from trapezoidal must be 0.4876022, from Simpson\'s must be 0.52928738
use the attached algorithm to solve it by matlab
22.10 Develop a user-friendly computer program for the multiple- segment (a) trapezoidal and (b) Simpson\'s 1/3 rule based on Fig. 22.1. Test it by integrating 20(x-1) Use the true value of 0.602298 to compute e, for n = 4. Solution
Trapezoidal rule
f=@((x^(0.1) *(1.2-x) *(1-e^(20(x-1)); %Change here for different function
a=0;b=1; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end
l=length(x);
x
y
answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))
Simpson\'s 1.3 rule
f=@((x^(0.1) *(1.2-x) *(1-e^(20(x-1)); %Change here for different function
a=0;b=1; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end
