T(n) S(n) 0.217206 0.214602 0.215253 0.214602 0.214765 0.214602 32 0.214643 0.21
ID: 3109969 • Letter: T
Question
T(n) S(n) 0.217206 0.214602 0.215253 0.214602 0.214765 0.214602 32 0.214643 0.214602 0.214612 0.214602 3. On the spreadsheet, we can also tabulate the absolute errors la where r is the exact value of the integral and cis the approximation. We combine these values in the above table to get T(n) Absolute Error in T(n) Absolute Error in S(n) 4 0.217206 0.214602 2.60 x 10 3.78 x 10 8 0.215253 0.214602 6.51 x 10 5.91 x 10 10 16 0.214765 0.214602 x 10 T 1.63 9.24 x 10 12 32 0.214643 0.214602 407X 10-3 1.44 x 10 m 64 0.214612 0.214602 1.02 x 10Explanation / Answer
5)
a)
for T_n factor = 2.60 * 10^(-3) / ( 6.51 * 10^(-4) ) = 3.999 = 4 (approx )
For S_n factor = 3.78 * 10^(-8) / ( 5.91 * 10^(-10 ) = 63.95 = 64 ( approx )
6)
1)
matlab code to calculate simpson and trepezoidal method is shown below
%%%% simpson %%%
clc;
clear all;
close all;
format short
a=0;
b=pi;
I_actual=pi*log(1+sqrt(3)/2);
for n=5:100;
x=a:(b-a)/n:b;
for j=1:length(x)
y(j)=log(2+cos(x(j)));
end
sum=0;
for k=1:length(x)
if (k==1||k==length(x))
sum=sum+y(k);
else if (rem(k,2)==1)
sum=sum+2*y(k);
else
sum=sum+4*y(k);
end
end
end
I=(b-a)/n*1/3*sum;
if (abs(I_actual-I)<=10^(-6))
break;
end
end
fprintf('Integration by simpsons method =%d ', I);
fprintf('Integration by Actual method =%d ', I_actual);
fprintf('N to get value within given tolerence =%i ', n);
output :
Integration by simpsons method =1.959760e+000
Integration by Actual method =1.959759e+000
N to get value within given tolerence =10
2) for b part just change the function value of a and b and atual value
%%%%
clc;
clear all;
close all;
format short
a=0;
b=2;
I_actual=log(32)-2;
for n=5:100;
x=a:(b-a)/n:b;
for j=1:length(x)
y(j)=(x(j)^2+1)/(x(j)+2);
end
sum=0;
for k=1:length(x)
if (k==1||k==length(x))
sum=sum+y(k);
else if (rem(k,2)==1)
sum=sum+2*y(k);
else
sum=sum+4*y(k);
end
end
end
I=(b-a)/n*1/3*sum;
if (abs(I_actual-I)<=10^(-6))
break;
end
end
fprintf('Integration by simpsons method =%d ', I);
fprintf('Integration by Actual method =%d ', I_actual);
fprintf('N to get value within given tolerence =%i ', n);
output :
Integration by simpsons method =1.465737e+000
Integration by Actual method =1.465736e+000
N to get value within given tolerence =20
7)
for I3
clc;
clear all;
close all;
format short
a=0;
b=pi/2;
n=10;
x=a:(b-a)/n:b;
for j=1:length(x)
y(j)=(x(j)^2+1)/(x(j)+2);
end
sum=0;
for k=1:length(x)
if (k==1||k==length(x))
sum=sum+y(k);
else if (rem(k,2)==1)
sum=sum+2*y(k);
else
sum=sum+4*y(k);
end
end
end
I=(b-a)/n*1/3*sum;
fprintf('Integration by simpsons methodusing N=10 =%d ', I);
output : =
Integration by simpsons methodusing N=10 =4.571427e-001
>>
for I4
clc;
clear all;
close all;
format short
a=0.00001;
b=1;
n=10;
x=a:(b-a)/n:b;
for j=1:length(x)
y(j)=x(j)^2*log(x(j))^3;
end
sum=0;
for k=1:length(x)
if (k==1||k==length(x))
sum=sum+y(k);
else if (rem(k,2)==1)
sum=sum+2*y(k);
else
sum=sum+4*y(k);
end
end
end
I=(b-a)/n*1/3*sum;
fprintf('Integration by simpsons methodusing N=10 =%d ', I);
output :
Integration by simpsons method using N=10 =-7.440744e-002
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.