PROBLEM 1 PROBLEM STATEMENT A user-friendly Matlab program is to be written for
ID: 2322487 • Letter: P
Question
PROBLEM 1 PROBLEM STATEMENT A user-friendly Matlab program is to be written for a) The multiple-application trapezoidal rule (Trapm.m) based on Fig. 21.9(b). Test it by calculating the following integral with n 23, b) The multiple-application version of Simpson's 1/3 rule (Simp13m.m) based on Fig. 21.13(c). Test it by calculating the following integral with n- 20, The multiple-application Simpson's rule for both odd and even number of segments (SimInt.m) based on Fig. 21.13(d). Test it by calculating the following integral with n 10 and 15 c) 1-/resin(x)dr xhe sin o x+1 Print Layout View Sec 1Pages: 1 of 6 Words: 100%Explanation / Answer
(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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.