Home > K25104 > Integration > composite_rule_script.m

composite_rule_script

PURPOSE ^

Usage example for composite_rule

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Usage example for composite_rule

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Usage example for composite_rule
0002 
0003 a = -1;
0004 b= 1;
0005 n = 10;
0006 m = 5;
0007 rule = 'gauss_legendre';
0008 for k = 0:5
0009     f = @(x) x^k;
0010     [ Q ] = composite_rule( f,a,b,n,m,rule );
0011     disp(['Gauss-Legendre composite',' rule for x^', num2str(k), ' on [-1,1] is ', num2str(Q)]);
0012 end
0013 f = @sin;
0014 [ Q ] = composite_rule( f,a,b,n,m,rule );
0015 disp(['Gauss-Legendre composite',' rule for ', func2str(f), ' on [-1,1] is ', num2str(Q)]);
0016 f = @cos;
0017 [ Q ] = composite_rule( f,a,b,n,m,rule );
0018 disp(['Gauss-Legendre composite',' rule for ', func2str(f), ' on [-1,1] is ', num2str(Q)]);
0019 f = @exp;
0020 [ Q ] = composite_rule( f,a,b,n,m,rule );
0021 disp(['Gauss-Legendre composite',' rule for ', func2str(f), ' on [-1,1] is ', num2str(Q)]);
0022 f = @(x) 1/x;
0023 [ Q ] = composite_rule( f,a,b,n,m,rule );
0024 disp(['Gauss-Legendre composite',' rule for ', func2str(f), ' on [-1,1] is ', num2str(Q)]);
0025 f = @(x) 1/(1+x);
0026 [ Q ] = composite_rule( f,a,b,n,m,rule );
0027 disp(['Gauss-Legendre composite',' rule for ', func2str(f), ' on [-1,1] is ', num2str(Q)]);

Generated on Mon 18-Jan-2016 10:25:49 by m2html © 2005