(50g) Simpson's rule for f(x,y)
|
11-17-2018, 10:31 PM
Post: #2
|
|||
|
|||
RE: (50g) Simpson's rule for f(x,y)
.
Hi, peacecalc: (11-17-2018 09:27 PM)peacecalc Wrote: like Eddie Shore showed us HERE an algorithm for integration a function with two variables with the simpson rule and a matrix. He implemented this for the HP 71B. I didn't see Eddie's post at the time but he's wrong on one count, namely (my bolding): Eddie W. Shore Wrote:On the HP 71B, matrices cannot be typed directly, elements have to be stored and recalled on element at a time. The program presented does not use modules. That's not correct. HP-71B's BASIC language allows for filling in all elements of an arbitrary size matrix at once by including the values in one or more DATA statements and then reading them all into the matrix using a single READ statement, no extra ROM modules needed. Thus, this lengthy initialization part in Eddie's code: 14 DIM I(5,5) 20 I(1,1) = 1 21 I(1,2) = 4 22 I(1,3) = 2 23 I(1,4) = 4 24 I(1,5) = 1 25 I(2,1) = 4 26 I(2,2) = 16 27 I(2,3) = 8 28 I(2,4) = 16 29 I(2,5) = 4 30 I(3,1) = 2 31 I(3,2) = 8 32 I(3,3) = 4 33 I(3,4) = 8 34 I(3,5) = 2 35 I(4,1) = 4 36 I(4,2) = 16 37 I(4,3) = 8 38 I(4,4) = 16 39 I(4,5) = 4 40 I(5,1) = 1 41 I(5,2) = 4 42 I(5,3) = 2 43 I(5,4) = 4 44 I(5,5) = 1 can be replaced by this much shorter, much faster version (OPTION BASE 1 assumed): 14 DATA 1,4,2,4,1,4,16,8,16,4,2,8,4,8,2,4,16,8,16,4,1,4,2,4,1
20 DIM I(5,5) @ READ I where the READ I fills in all data into the matrix with a single statement, no individual assignments or loops needed, thus it's much faster and uses less program memory. Notice that this also works for arbitrary numerical expressions in the DATA, i.e.: the following hipothetical code would work Ok: 10 DATA 5,-3,2.28007e20,X,2*Z+SIN(Y),FNF(X+Y,X-Y),FNZ(2+FNF(C+D),3/FNF(6,8)),43
20 DIM M(2,4) @ READ M Anyway, Simpson's rule is suboptimal for integration purposes, either one-dimensional or multi-dimensional. There are much better methods providing either significantly increased accuracy for the same number of function evaluations or the same accuracy with fewer evaluations. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(50g) Simpson's rule for f(x,y) - peacecalc - 11-17-2018, 09:27 PM
RE: (50g) Simpson's rule for f(x,y) - Valentin Albillo - 11-17-2018 10:31 PM
RE: (50g) Simpson's rule for f(x,y) - peacecalc - 11-19-2018, 08:33 PM
|
User(s) browsing this thread: 1 Guest(s)