Compact Simpson's 3/8 Rule(??)
|
12-13-2015, 03:38 PM
(This post was last modified: 12-13-2015 03:50 PM by Dieter.)
Post: #2
|
|||
|
|||
RE: Compact Simpson's 3/8 Rule(??)
(12-13-2015 02:26 PM)Namir Wrote: The variable I cycles between 1, 2, and 3. The coefficient C is calculated using a special (and simple) quadratic equation to yield 3, 3, and 2 for I=1, 2, and 3. Waaaayyyyyy too complicated. ;-) Instead of i=1, 2, 3 make it 0, 1, 2 and get c = 2 + sign(i). This doesn't even require two separate variables i and n (cf. second code sample). Code: h = (b - a) / n Or, if you do not like for-next-loops and prefer while/repeat: Code: h = (b - a) / n Those who are a bit paranoid about floating point arithmetics and exact zero results may replace the exit condition with something like Loop Until n+4711 = 4711. ;-) Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)