Question
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
function Solution()clear all
clc
close all
disp('----------Question 3-------------')
%syms x
%Iexact=double(int(exp(x^2),x,0,1));
n=[2 4 6 10];
f=@(t)exp(t.^2);
for i=1:3
ErrorSimpson(i)=Simpson(f,0,1,n(i+1))-Simpson(f,0,1,n(i));
ErrorTrapezoid(i)=Trapezoid(f,0,1,n(i+1))-Trapezoid(f,0,1,n(i));
end
ErrorSimpson=ErrorSimpson
ErrorTrapezoid=ErrorTrapezoid
%determine the smallest i such that abs(ErrorTrapezoid(i))>10^(-2)
it=3; err=1;%initialize
while abs(err)>10^(-2)
err=Trapezoid(f,0,1,it)-Trapezoid(f,0,1,it-1);
it=it+1;
end...