Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make the QuadN function suitable for up to n = 8 Gauss quadrature rule ( that is , it can change from n = 1

Make the QuadN function suitable for up to n=8 Gauss quadrature rule (that is, it can change from n=1 to 8 and find the relevant coefficient and certain xi values) by revising our trapezoidal, rectangular, integral functions according to Simphson rules to a state that stops when a certain absolute relative error value is reached. test via a function function [I] = GausQuadn(f,a,b,n)

% xi wi 's are the points and weights for calculation

%  improper integrals with special points

f=inline (f)

n

I=0;

if n==2

disp(' I was here')

w(1)=1;x(1)=0.5773502691896257 

w(2)=1;x(2)=-0.5773502691896257

for i=1:n

I=I+(b-a)*0.5*w(i)*f((b-a)*0.5*x(i)+(b+a)*0.5);

end

elseif n==3

w(1)=0.5555555555555556;x(1)=0.77459666924148347 ;

w(2)=0.8888888888888888;x(2)=0

w(3)=0.5555555555555556;x(3)=-0.7745966692414834

for i=1:n

I=I+(b-a)*0.5*w(i)*f((b-a)*0.5*x(i)+(b+a)*0.5);

end

elseif n==4

w(1)=0.3478548451374544;x(1)=0.8611363115940525  ;

w(2)=0.6521451548625460;x(2)=0.3399810435848563 ;

w(3)=0.6521451548625460;x(3)=-0.3399810435848563;

w(4)=0.3478548451374544;x(4)=-0.8611363115940525  ;

for i=1:n

I=I+(b-a)*0.5*w(i)*f((b-a)*0.5*x(i)+(b+a)*0.5);

end

else

disp('This version work only up to 4 points Gaussian quadrature')

end

I

end


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

Business Communication Essentials a skill based approach

Authors: Courtland L. Bovee, John V. Thill

6th edition

978-0132971324

More Books

Students also viewed these Databases questions

Question

Solve each equation. V4x + 13 = 2x - 1

Answered: 1 week ago