A function f has the values shown Use Simpsons rule and the

A function f has the values shown. Use Simpson\'s rule and the function values at x = 1,1.5 and 2 to approximate integral f(x) dx. Repeat the preceding part, using x = 1,1.25, 1.5,1.75 and 2. Use the results from parts a and b along with the error terms to establish an improved approximation. Repeat the previous parts using the trapezoid rule. Compare these results to that from Simpson\'s rule.

Solution

Use this matlab code for Trepizoidal ruel:

clc
clear
x = [1,1.25,1.5,1.75,2];
y = [10,8,7,6,5];
trapz(x,y)

You will get the output as

ans =

7.1250

Use the following code for sympson rule

clc;
clear all;
close all;

f=@(x)1/(1); %Change here for different function
a=0;b=4; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;
x=[1,1.25,1.5,1.75,2]
y=[10,8,7,6,5]


l=length(x);
x
y
answer=(h/3)*((y(1)+y(l))+2*(y(3)+y(5))+4*(y(2)+y(4)))

you will get the answer as


x =

Columns 1 through 3

1.0000 1.2500 1.5000

Columns 4 through 5

1.7500 2.0000


y =

10 8 7 6 5


x =

Columns 1 through 3

1.0000 1.2500 1.5000

Columns 4 through 5

1.7500 2.0000


y =

10 8 7 6 5

Use the above code to find the required answers for all the bits.


answer =

31.6667

>>

 A function f has the values shown. Use Simpson\'s rule and the function values at x = 1,1.5 and 2 to approximate integral f(x) dx. Repeat the preceding part, u
 A function f has the values shown. Use Simpson\'s rule and the function values at x = 1,1.5 and 2 to approximate integral f(x) dx. Repeat the preceding part, u

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site