HP Forums
[WP 34s] Trapezoidal approximation of area under curve - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: [WP 34s] Trapezoidal approximation of area under curve (/thread-4047.html)



[WP 34s] Trapezoidal approximation of area under curve - Marcio - 06-01-2015 01:53 PM

Hello all,

Is it possible to have access to data keyed into the calc using the \(\sum +\) for other procedures other than stat functions? If so, I am planning on creating a program that would take advantage of that so it would be possible to easily calculate the area under a curve defined by data, as shown below:

\[ \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}) \]

Many thanks

Marcio


RE: [WP 34s] Trapezoidal approximation of area under curve - Marcus von Cube - 06-01-2015 03:54 PM

(06-01-2015 01:53 PM)Marcio Wrote:  Is it possible to have access to data keyed into the calc using the \(\sum +\) for other procedures other than stat functions?
The SUMS catalog has all the accumulated data ready for access. All commands in this catalog are programmable.


RE: [WP 34s] Trapezoidal approximation of area under curve - Dave Britten - 06-01-2015 05:36 PM

(06-01-2015 03:54 PM)Marcus von Cube Wrote:  
(06-01-2015 01:53 PM)Marcio Wrote:  Is it possible to have access to data keyed into the calc using the \(\sum +\) for other procedures other than stat functions?
The SUMS catalog has all the accumulated data ready for access. All commands in this catalog are programmable.

The problem is that the trapezoidal approximation appears to require the individual data points, and not just the sums. You'll probably have to write a custom program that accumulates its own sums, either on the fly, or by using a block of registers to store x and y data points.


RE: [WP 34s] Trapezoidal approximation of area under curve - Thomas Klemm - 06-01-2015 06:56 PM

(06-01-2015 01:53 PM)Marcio Wrote:  If so, I am planning on creating a program that would take advantage of that so it would be possible to easily calculate the area under a curve defined by data, as shown below:

\[ \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}) \]

You could use something like:
Code:
001 LBL'TPZ'
002 CLΣ
003 LBL 00
004 STOP
005 R↑
006 RCL+ Z
007 R↑
008 RCL- Z
009 Σ+
010 R↓
011 R↓
012 GTO 00
013 END

Usage:
\(y_1\) ENTER \(x_1\) XEQ'TPZ'
\(y_2\) ENTER \(x_2\) R/S
(...)
\(y_n\) ENTER \(x_n\) R/S
Σxy
-2 ÷

Not a sophisticated program but I hope you get the idea.

Cheers
Thomas


RE: [WP 34s] Trapezoidal approximation of area under curve - Marcio - 06-02-2015 02:46 AM

Works like a charm.
Thank you


RE: [WP 34s] Trapezoidal approximation of area under curve - Dieter - 06-02-2015 09:23 PM

(06-01-2015 06:56 PM)Thomas Klemm Wrote:  Not a sophisticated program but I hope you get the idea.

A bit of sophistication can be added by using the 34s' complex functions:

Code:
01 LBL"TRP"
02 CLΣ
03 CLSTK
04 STOP
05 LBL 01
06 STOP
07 cplx x<> Z
08 +/-
09 cplx RCL+ Z
10 Σ+
11 cplx DROP
12 GTO 01

XEQ"TRP"
y1 ENTER x1 R/S
y2 ENTER x2 R/S
...
Σxy 2 ÷


Dieter


RE: [WP 34s] Trapezoidal approximation of area under curve - Marcio - 06-16-2015 10:47 AM

Hello again,

Does anyone know how to do \(RCL+ Z\) on the 35s? From what I saw in the manual, one has to use the EQN inside the program in order to recall the \(z\)-register, which is somewhat dangerous.

Thanks.


RE: [WP 34s] Trapezoidal approximation of area under curve - Dieter - 06-16-2015 11:31 AM

(06-16-2015 10:47 AM)Marcio Wrote:  Does anyone know how to do \(RCL+ Z\) on the 35s?

Yes. You can't. Recall-arithmetics is not available for the stack registers.
Of course you can do a RCL+Z with variable Z, but that's a completely different story.

Dieter


RE: [WP 34s] Trapezoidal approximation of area under curve - Thomas Klemm - 06-16-2015 12:38 PM

(06-16-2015 10:47 AM)Marcio Wrote:  Does anyone know how to do \(RCL+ Z\) on the 35s?

You can use the following program:

Code:
T001 LBL T
T002 CLΣ
T003 STOP
T004 REGY+REGT
T005 REGY-REGT
T006 Σ+
T007 R↓
T008 R↓
T009 GTO T003

Usage:
\(y_1\) ENTER \(x_1\) XEQ T
\(y_2\) ENTER \(x_2\) R/S
(...)
\(y_n\) ENTER \(x_n\) R/S
Σxy
2 ÷


Cheers
Thomas


RE: [WP 34s] Trapezoidal approximation of area under curve - Marcio - 06-16-2015 12:57 PM

Thank you Thomas.

I myself created a program with more than 2 times as many lines as yours, which is not only simpler but also much more elegant.

Very much appreciated.

Marcio