# HP Forums

Full Version: Simpson's Rule on HP17b/19b/200LX anyone?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Does anyone have available a routine which allows to integrate
functions with Simpson's Rule (or even Romberg's algorithm ...) on one of the Solver-equipped calculator series (and it's newer siblings) above?

Hints for implemention or code snippets would be welcome!

Reason: To enter the function in question only once - as demonstrated in Ed Keefe's articles on Palmptop Papers, where he used an implementation of the Trapezoid Rule.

TIA.

Best regards

Peter A. Gebhardt

couldn't be reached - temporarily shutdown or gone forever ???

Any mirrors / backups available?

Edited: 9 July 2007, 11:19 a.m.

1424241

Edited: 9 July 2007, 12:19 p.m.

Peter,

If you have the HPMuseum DVD or CD's, then check out pages 36 thru 41 of the "HP-27S and HP-19B Technical Applications Step-by-Step Solutions" book.

It's a Solver example of Numerical Integration using Simpson's Rule.

This should also be usable for the HP-200LX and the HP-17BII.

Bill

Thx. a lot Bill!

I've already ordered the DVD from Dave today.

What bothers me conc. the implementation on the Solver is, how to get rid of the nuissance to enter the function several times (as demonstrated by y(0),y(i) and y(n) in the following code snippet:

Quote:
``` h = (xn - x0) / n
Integral = y(0)
For i = 1 To n - 1
If i Mod 2 = 0 Then
Integral = Integral + 2 * y(i)
Else
Integral = Integral + 4 * y(i)
End If
Next
Integral = Integral + y(n)
```

Either achieving minimal error for a given number of function evaluations and?/or computing an approximation having a given error bound, at minimal cost.

Best regards

Peter A. Gebhardt

PS: @Bill Platt, thank you too, for reminding me to express the problem in a way better to understand ;-)

Edited: 9 July 2007, 5:58 p.m.

Hi Peter,

Quote:
I've already ordered the DVD from Dave today.

Great - be sure to set aside some time (a lot of time) for perusing them. They are a great resource.

Quote:
how to get rid of the nuissance to enter the function several times

The secret is to use the SUM function to loop. When you get the DVD and look at the Technical Applications Book, it'll all become clear (or, in my case, a little less murky). Using the Sum let's you enter the function only one time.

The Technical Applications book is a Must Read for anyone wanting to make good use of the Solver. It has a great section on the Let and Get functions that I haven't found in any other reference book.

Bill

Current status - I have a working solution, BUT:

The implementation of an algorithm (as an example this one here)

does work reliably only with N == powers of 2. Using other multiples of 2 shows an oscillating behaviour of the results dampening out with increasing N. (clearly visible thanks to the PLOT function of the HPCALC Solver!)

Excuse me for asking for help still - I suppose that this is an effect of the used algorithm (the integration) as such - are there any enhancements, I should/can add?

It's about 40 years since I was used to calculus, so pls. could you point me to some information where I can find useful info targetted to the 200LX Solver capabilities. For example, solutions using arrays for intermediate storage are a no-no, because of the read-only characteristics of the .STA lists.

TIA

Peter A. Gebhardt

Edited: 10 July 2007, 7:35 p.m.

Peter,

You might want to try MERCURY from the HP200LX SUPER Site. It's supposed to be a replacement for Borlands Eureka's program and can be run on the HP-200LX. It does Integration as well as many other equations. You can find it here:

Bill

Bill,

Thx. again for your help offered. Because of the advisory process I use, I can't leave the Solver (data has to be used with other equations later on), so your advice is very welcome, but not what I'm looking for.

As an example, part of my work requires solving an Exponential Reciprocal Gamma Function, where part of the function is the Integral over x^(alpha-1)*exp(-x/beta) dx (for what I'm wanting to implement the algorithm).

So I'm still looking for a solution which I can "integrate" (no pun intended!) into the Solver environment.

Best regards

Peter A. Gebhardt

Peter,

I went through my set of The HP Palmtop Paper On Disk and found the following Solver Equation:

```Integral
!CALC Num'cal Integration from TECH APP  booklet E.G. Set
A=-1,B=1,X=1 N=20 and find the area of a circle(I)!
I=L( H:(A-B)/(-2*N))/3*
SIGMA(R,
0,
2*N,
1,
0*L(X,A+R*G(H))+(SGN(R)+SGN(2*N-R)+2*MOD(R,2))*
( ! function goes on next line(s) !
! e.g. area under a line (right triangle)!
! X !
(2*SQRT(1-X^2))
!area in top and bottom of circle!  )
)
```

This is based on the one in the Tech App Guide.

You can just replace (2*SQRT(1-X^2)) with your F(X).

Note that N=20 means 40 iterations.

Have Fun.

Bill

Edited: 11 July 2007, 1:03 p.m.

Bill,

Thx. a lot!

Peter A. Gebhardt