(50G) (49G+) Trapezoidal rule integration in RPL
11-17-2015, 11:55 AM (This post was last modified: 06-15-2017 01:57 PM by Gene.)
Post: #1
 Marcio Senior Member Posts: 438 Joined: Feb 2015
(50G) (49G+) Trapezoidal rule integration in RPL
Hello,

I have been using this code for years now and due to its simplicity, it has never failed.

<< $$\rightarrow$$ M
<< M SIZE OBJ$$\rightarrow$$ DROP DROP 'p' STO 0 'A' STO
2 p FOR i 'M(i,1)' $$\rightarrow$$NUM 'M(i-1,1)' $$\rightarrow$$NUM - 'M(i,2)' $$\rightarrow$$NUM 'M(i-1,2)' $$\rightarrow$$NUM + x 'A' $$\rightarrow$$NUM + 'A' STO NEXT
'A' $$\rightarrow$$NUM 2 / "AREA" $$\rightarrow$$TAG >>
'A' 'p' PURGE PURGE
>>

Although not optimized and is actually FORTRAN translated into RPL, this code is fast calculating the area under a curve in accordance with the trapezoidal rule:

$\int_{x_1}^{x_n} y(x) dx \approx \frac{1}{2} \sum_{k=1}^{n-1} (x_{k+1}-x_{k})(y_{k+1}+y_{k})$

Marcio
 « Next Oldest | Next Newest »

 Messages In This Thread (50G) (49G+) Trapezoidal rule integration in RPL - Marcio - 11-17-2015 11:55 AM RE: [HP-50G/49G+] Trapezoidal rule integration in RPL - Thomas Klemm - 11-17-2015, 05:56 PM RE: [HP-50G/49G+] Trapezoidal rule integration in RPL - Marcio - 11-17-2015, 06:35 PM RE: [HP-50G/49G+] Trapezoidal rule integration in RPL - Thomas Klemm - 11-17-2015, 07:04 PM RE: [HP-50G/49G+] Trapezoidal rule integration in RPL - Marcio - 11-17-2015, 07:13 PM

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