0
|
1 function [bp,wf]=ncrule(m) |
|
2 %usage: [bp,wf]=ncrule(m); |
|
3 % This function returns the Newton-Coates base points and weight factors |
|
4 % up to an 8 point Newton-Coates formula. |
|
5 % |
|
6 % m -- number of Newton-Coates points (integrates an mth order |
|
7 % polynomial exactly (or an (m+1)th order for even m)) |
|
8 |
|
9 % By Bryce Gardner, Purdue University, Spring 1993. |
|
10 |
|
11 if ( m == 1 ) |
|
12 bp=[-1;1]; |
|
13 wf=[1;1]; |
|
14 elseif ( m == 2 ) |
|
15 bp=[-1;0;1]; |
|
16 wf=[1;4;1]/3; |
|
17 elseif ( m == 3 ) |
|
18 bp=[-1;-1/3;1/3;1]; |
|
19 wf=[1;3;3;1]/4; |
|
20 elseif ( m == 4 ) |
|
21 bp=[-1;-1/2;0;1/2;1]; |
|
22 wf=[7;32;12;32;7]/45; |
|
23 elseif ( m == 5 ) |
|
24 bp=[-1;-3/5;-1/5;1/5;3/5;1]; |
|
25 wf=[19;75;50;50;75;19]/144; |
|
26 elseif ( m == 6 ) |
|
27 bp=[-1;-2/3;-1/3;0;1/3;2/3;1]; |
|
28 wf=[41;216;27;272;27;216;41]/420; |
|
29 elseif ( m == 7 ) |
|
30 bp=[-1;-5/7;-3/7;-1/7;1/7;3/7;5/7;1]; |
|
31 wf=[751;3577;1323;2989;2989;1323;3577;751]/8640; |
|
32 else |
|
33 if ( m != 8 ) |
|
34 disp('Dont know formula higher than n=8. Returning as if n=8.'); |
|
35 endif |
|
36 bp=[-1;-3/4;-1/2;-1/4;0;1/4;1/2;3/4;1]; |
|
37 wf=[989;5888;-928;10496;-4540;10496;-928;5888;989]/14175; |
|
38 endif |
|
39 |
|
40 endfunction |