Post Reply 
Compact Simpson's 3/8 Rule(??)
12-13-2015, 04:39 PM (This post was last modified: 12-13-2015 07:50 PM by Dieter.)
Post: #4
RE: Compact Simpson's 3/8 Rule(??)
(12-13-2015 04:05 PM)rprosperi Wrote:  OK, I just gotta ask - why 4711 ?

That's why. ;-)
Click on "history" and the year 1794 where the origin of this number is explained.

Of course you may just as well use any other three- or four-digit integer.

While we're at it, here's a quick and dirty version for the HP41 series.
It implements yet another way of generating the 3–3–2 sequence.

Code:
01  LBL"SIMP38"
02  " A↑B=?"
03  PROMPT
04  STO 02    ' save b temporarily in R02
05  STO 03
06  X<>Y
07  STO 01    ' save a in R01
08  ST- 03    ' save b - a in R03
09  XEQ E     ' f(a)
10  STO 00
11  RCL 02
12  XEQ E     ' f(b)
13  ST+ 00    ' sum = f(a) + f(b)
14  " N=?"
15  PROMPT
16  STO 02    ' store n in R02
17  ST/ 03    ' store h = (b - a) / n  in R03
18  3
19  MOD       ' validate n
20  CHS
21  SQRT      ' generate error if n mod 3 ≠ 0
22  DSE 02    ' n = n - 1
23  LBL 01    ' start of loop
24  RCL 03
25  ST+ 01    ' x = x + h
26  RCL 01
27  XEQ E     ' f(x)
28  RCL 02
29  3
30  MOD
31  X=0?      ' if i mod 3 = 0
32  DSE L     ' set c=2, else leave it at 3
33  X<> L
34  *         ' c * f(x)
35  ST+ 00    ' add to sum
36  DSE 02
37  GTO 01    ' end of loop
38  RCL 00
39  RCL 03
40  *
41  ,375
42  *         ' result = sum * h * 3/8
43  RTN

44  LBL E     ' function f(x)
45  1/x       ' place your f(x) code here
46  RTN

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015, 02:26 PM
RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-13-2015 04:39 PM
RE: Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015, 05:05 PM



User(s) browsing this thread: 6 Guest(s)