(50g) Simpson's rule for f(x,y)
|
11-17-2018, 09:27 PM
(This post was last modified: 11-18-2018 11:14 PM by peacecalc.)
Post: #1
|
|||
|
|||
(50g) Simpson's rule for f(x,y)
Hello friends,
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 do the same thing for the HP 50G but not so elegant, it is brute force: I implementated this formular: \[ F = \int_a^b\int_c^d f(t,s)dtds \\ \sim \frac{ha}{3} \left( \frac{hi}{3}\left( f(a,c) + f(b,c) + \sum_{j=1}^{k-1}\left( 2f(t_j,c) + 4f(t_j,c)\right) + f(a,d) + f(b,d) + \sum_{j=1}^{k-1}\left( 2f(t_j,d) + 4f(t_j,d)\right) + \\ \sum_{i=1}^{m-1}\left(2\left(f(a,s_i)+f(b,s_i) + \sum_{j=1}^{k-1}\left( 2f(t_j,s_i) + 4f(t_j,s_i)\right)\right) + \\ 4\left(f(a,s_i)+f(b,s_i) + \sum_{j=1}^{k-1}\left( 2f(t_j,s_i) + 4f(t_j,s_i)\right)\right)\right)\right)\right) \] That looks horrible, but I used the stack to sum up all function values and multiplied them afterwards with 2 or 4. And the indices in formular above has to be disdinguish between even or odd numbers (only values with odd indices has to be multiplied be 4 and even with 2). I used in the FOR loops no integer values but the values for the variables (the hp 50g is very happy to use a real variable in the FOR loop. For instance I used my little program for estimate antiderivatives with harmonic sphere function multiplied with a light function to geht the coeffecients.The one angle goes from 0 to pi, the other one from 0 to 2pi. With N = 15 the hp 50g has to calculate 30*60 = 180 function values and it takes 2 minutes at average. That seems to be very long, but it is faster as you take the built-in function \[ \int \]. I have the impression that the built in function works then (when you have more variables) with recursion. Code:
|
|||
« 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)