Post Reply 
[WP 34s] Trapezoidal approximation of area under curve
06-01-2015, 01:53 PM (This post was last modified: 06-01-2015 02:31 PM by Marcio.)
Post: #1
[WP 34s] Trapezoidal approximation of area under curve
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
Find all posts by this user
Quote this message in a reply
06-01-2015, 03:54 PM
Post: #2
RE: [WP 34s] Trapezoidal approximation of area under curve
(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.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
06-01-2015, 05:36 PM
Post: #3
RE: [WP 34s] Trapezoidal approximation of area under curve
(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.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2015, 06:56 PM (This post was last modified: 06-01-2015 07:06 PM by Thomas Klemm.)
Post: #4
RE: [WP 34s] Trapezoidal approximation of area under curve
(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
Find all posts by this user
Quote this message in a reply
06-02-2015, 02:46 AM
Post: #5
RE: [WP 34s] Trapezoidal approximation of area under curve
Works like a charm.
Thank you
Find all posts by this user
Quote this message in a reply
06-02-2015, 09:23 PM
Post: #6
RE: [WP 34s] Trapezoidal approximation of area under curve
(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
Find all posts by this user
Quote this message in a reply
06-16-2015, 10:47 AM (This post was last modified: 06-16-2015 10:49 AM by Marcio.)
Post: #7
RE: [WP 34s] Trapezoidal approximation of area under curve
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.
Find all posts by this user
Quote this message in a reply
06-16-2015, 11:31 AM
Post: #8
RE: [WP 34s] Trapezoidal approximation of area under curve
(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
Find all posts by this user
Quote this message in a reply
06-16-2015, 12:38 PM
Post: #9
RE: [WP 34s] Trapezoidal approximation of area under curve
(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
Find all posts by this user
Quote this message in a reply
06-16-2015, 12:57 PM
Post: #10
RE: [WP 34s] Trapezoidal approximation of area under curve
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
Find all posts by this user
Quote this message in a reply
Post Reply 




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