Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN MATLAB ONLY Using these four functions, create a script to publish, writing a cell that uses N=10,20,40,80,160,320 to calculate the approximations to the integral

IN MATLAB ONLY

Using these four functions, create a script to publish, writing a cell that uses N=10,20,40,80,160,320 to calculate the approximations to the integral below using each of the three rules. The script should calculate the values as well as the absolute errors for each rule and display them in a nicely formatted table, which should include the method, N, the approximate value, and the absolute error. To format the table, use

function:

function y=func(x)

y=sqrt(4x^2);

end

The midpoint rule:

function y=Mid(a,b,N)

dx=(b-a)/N;

y=0;

for i=1:N

y=y+func(a+(i-0.5)*dx)*dx;

end

end

The trapezoidal rule:

function y=Trap(a,b,N)

dx=(b-a)/N;

y=0;

for i=1:N

y=y+0.5*(func(a+(i-1)*dx) + func(a+i*dx))*dx;

end

end

Simpsons Rule:

function y=Simp(a,b,N)

dx=(b-a)/N;

y=0;

for i=1:N

y=y+(1/6)*(func(a+(i-1)*dx) + 4*func(a+(i-0.5)*dx) + func(a+i*dx))*dx;

end

end

fprintf('\%s | \%s | \%s | \%s \ ','N','Method','Value','AbsError')

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

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions