PROBLEM 1 PROBLEM STATEMENT A userfriendly Matlab program is
Solution
(a)
clc;
clear all;
close all;
f=@(x)(x+2/x)^0.5;
a=0;b=6;
n=23;
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=(i+2/i)^0.5;
end
l=length(x);
x
y
answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))
ANSWER = 5.53
(b)
clc;
clear all;
close all;
f=@(x)x^2 * exp(x);
a=0;b=3;
n=20;
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=i^2 * exp(i);
end
l=length(x);
x
y
answer=(h/3)*((y(1)+y(l))+2*(y(3)+y(5))+4*(y(2)+y(4)+y(6)))
(c)
clc;
clear all;
close all;
f=@(x)(x^(1/3) * exp(x) * sin(x))/(x+1) * exp(x);
a=0;b=3;
n=10;
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=(i^(1/3) * exp(i) * sin(i))/(i+1); %Change here for different function
end
l=length(x);
x
y
answer=(h/3)*((y(1)+y(l))+2*(y(3)+y(5))+4*(y(2)+y(4)+y(6)))
Which is same as the previous case but with different function............ANSWER

