Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Section 1 consists of basic concepts, and can be done either with a numerical co

ID: 2087565 • Letter: S

Question

Section 1 consists of basic concepts, and can be done either with a numerical code or by hand (where "by hand" means with a normal calculator). For sections 2-4, the goal is to solve the following problems using the numerical schemes outlined during class. For each problem, you should submit the code from your program as well as the output. Note that you are not allowed to use any built-in Matlab programs (i.e. ODE45) for this project (unless you want to use them to check your own code). Also I don't expect to see the same code from two different people! Section 3: Integration x2 from x = 0 to x = 1 using the rectangular or trapezoidal rule. Integrate the function f(x) Do this first with ?x = 1, then 0.5, 0.25, and finally 0.1. 7)

Explanation / Answer

Using trapazoidal rule:- matlab code

%for step =1 means no. of intervals 1

clc;
clear all;
close all;

f=@(x)x^2; %Change here for different function
a=0;b=1; %Given limits
n=1; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^2; %Change here for different function
end

l=length(x);

answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))

% for step equal to 0.5 means no. of intervals 2

clc;
clear all;
close all;

f=@(x)x^2; %Change here for different function
a=0;b=1; %Given limits
n=2; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^2; %Change here for different function
end

l=length(x);
answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))

%for step = 0.25 means no. of intervals 4

clc;
clear all;
close all;

f=@(x)x^2; %Change here for different function
a=0;b=1; %Given limits
n=4; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^2; %Change here for different function
end

l=length(x);
answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))

%for step=0.1 means no. of intervals 10

clc;
clear all;
close all;

f=@(x)x^2; %Change here for different function
a=0;b=1; %Given limits
n=10; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^2; %Change here for different function
end

l=length(x);
answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote