Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB code for Simpson's Rule. Please help fix my code. I am trying to use the example to verify my code, but my code is

MATLAB code for Simpson's Rule.

Please help fix my code. I am trying to use the example to verify my code, but my code is wrong.

clc

clear all

close all

%Equation = input('Enter Function: ');

a = input('Enter lower limit: ');

b = input('Enter upper limit: ');

n = input('Enter number of sub-intervals: ');

f = @(x) 1/(x+1);

T = a:n:b;

w = (b-a);

j = f(a);

k = f(b);

area1 = 1;

c = a + w;

while (c

area1 = area1 + 4 * f(c);

c = c + w + w;

end

area2 = 0;

e = a + w + w;

while (e

area2 = area2 + 2 * f(e);

e = e + w + w;

end

g = (j + area1 + area2 + k);

fprintf('Area using Simpsons Rule = %f ', g);

image text in transcribed

Example. Use Simpson's rule with n 6 to estimate 1 +x3 dx. Solution. For n = 6, we have ?x = 461 = 0.5. We compute the values of yo, y?, ??, . . . , 16. 11.5 2 2.5 3.5 24.375 3 16.62528 43.875 65 Therefore, ???? dz 0.5(V2 + 4v 4.375+2(3) + 4v 16.625 + 2v 28 +A/43 875 + 35 12.871

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

LO4 List options for development needs analyses.

Answered: 1 week ago