Composite Simpsons Rule-Numerical Analysis-MATLAB Code, Exercises of Mathematical Methods for Numerical Analysis and Optimization

This is solution to one of problems in Numerical Analysis. This is matlab code. Its helpful to students of Computer Science, Electrical and Mechanical Engineering. This code also help to understand algorithm and logic behind the problem. This code includes: Composite, Simpsons, Rule, Function, Method, Algorithm, Piecewise, Rayleigh, Ritz, Inline, Result

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

saripella
saripella 🇮🇳

4.4

(132)

169 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
function [res] = SIMPSON(FN,A,B,sqq,sf,sp)
% This function is used by the Piecewise Linear Rayleigh Ritz
% Method (Algorithm 11.5) to perform Composite Simpson's Rule
syms('H','I','Y','Z','x');
QQ = inline(sqq,'x');
P = inline(sp,'x');
F = inline(sf,'x');
H = (B-A)/4;
Z = zeros(1,5);
for I = 0 : 4
Y = A+I*H;
if FN == 1
Z(I+1) = (4-I)*I*H*H*QQ(Y);
end;
if FN == 2
Z(I+1) = (I*H)*(I*H)*QQ(Y);
end;
if FN == 3
Z(I+1) = (H*(4-I))*(H*(4-I))*QQ(Y);
end;
if FN == 4
Z(I+1) = P(Y);
end;
if FN == 5
Z(I+1) = I*H*F(Y);
end;
if FN == 6
Z(I+1) = (4-I)*H*F(Y);
end;
end;
res = (Z(1)+Z(5)+2*Z(3)+4*(Z(2)+Z(4)))*H/3;
docsity.com

Partial preview of the text

Download Composite Simpsons Rule-Numerical Analysis-MATLAB Code and more Exercises Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

function [res] = SIMPSON(FN,A,B,sqq,sf,sp) % This function is used by the Piecewise Linear Rayleigh Ritz % Method (Algorithm 11.5) to perform Composite Simpson's Rule syms('H','I','Y','Z','x'); QQ = inline(sqq,'x'); P = inline(sp,'x'); F = inline(sf,'x'); H = (B-A)/4; Z = zeros(1,5); for I = 0 : 4 Y = A+IH; if FN == 1 Z(I+1) = (4-I)IHHQQ(Y); end; if FN == 2 Z(I+1) = (IH)(IH)QQ(Y); end; if FN == 3 Z(I+1) = (H(4-I))(H(4-I))QQ(Y); end; if FN == 4 Z(I+1) = P(Y); end; if FN == 5 Z(I+1) = IHF(Y); end; if FN == 6 Z(I+1) = (4-I)HF(Y); end; end; res = (Z(1)+Z(5)+2Z(3)+4(Z(2)+Z(4)))H/3;

docsity.com