Thursday, May 30, 2019

HP Prime and HP 17BII: Trapezoid Rule Using Distinct Points

HP Prime and HP 17BII: Trapezoid Rule Using Distinct Points


We can estimate the area of any surface by the use of sums and integral.  In calculus, we usually are given a function f(x), but here we are using measurements from one end to the other at various intervals. 

Technically, the intervals between each measurement do not have to be equal length.  However, having intervals of equal length makes things a lot easier, and in this blog entry, we assume they are. 

We have various methods to estimate the area.  One of the easiest ways is the Trapezoid Rule:

Area ≈ h/2 * ( y_1 + y_n + 2 * Σ( y_k , k, 2, n-1 ) )


h = interval length
y_k = length of each measurement, there are  n measurements
y_1 and y_n:  measurement of lengths at each end, respectively

Another rule to estimate area is the Simpson's Rule:

Area ≈ h/3 ( y_0 + y_n + 4 * Σ( y_k, k, 1, n-1, 2) + 2 * Σ( y_k, k, 2, n-2, 2) )

The program presented here uses the Trapezoid Rule. 

HP Prime Program AREAHGT

Two arguments:  h, a list of measurements

// h:  increment between measurements
// ms: list of measurements
// 2019-05-09 EWS
LOCAL k,n:=SIZE(ms);
RETURN h/2 * (ms(1) + ms(n) + 2 * Σ( ms(k), k, 2, n-1 ));

HP 17BII+ (Silver)/HP 17BII Solver:  Trapezoid Rule

First:  define a SUM list named MS.  The solver uses that list to get the reference measurements.


AREAHGT: AREA = 0 * L(N:SIZES(MS)) + H÷2 * (ITEM(MS:1) + ITEM(MS:G(N)) + 2 * Σ(K:2: G(N)-1: 1: ITEM(MS:K) )


h = 0.5

y_1 = 1174
y_2 = 1078
y_3 = 979
y_4 = 984
y_5 = 810
y_6 = 779
y_7 = 800
y_8 = 852
y_9 = 966

Area:  3676


All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

1 comment:

Σ(1 / (a^n)) from n=1 to m

 Σ(1 / (a^n)) from n=1 to m This blog entry covers the sum of the series: Σ[1 / (a^n), n=1 to m] with n and m positive integers Specific Cas...