Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is some code used integrate an equation through the Simpsons rule in Freemat . I want to make it so I can calculate 10,000

Below is some code used integrate an equation through the Simpsons rule in Freemat. I want to make it so I can calculate 10,000 n values without having to type it 10,000 times. Right now the code works for 2 n values because of XRL and XRLL.

the Simpsons rule is as follows:

image text in transcribed

I need to change the "H" and add any code so no matter what the n value is it automatically uses the formula above to calculate with alternating 4 & 2 depending on the number of n's

Freemat Code:

format long

f = @(x) (4/(x^2 + 1))

a = 0

b = 1

n = 2

dx = (b-a);

H = 0;

for i = 1:1:n

xLL = a+(i-1)*dx;

xRL = a+4*(i+1)*dx;

xRLL = a+2*(i+1)*dx;

H = H +f(xLL)+f(xRL)+f(xRLL);

end

A = H*(dx/2)

Simpson's rule for estimating an area is

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions