HP 35s "Low footprint" Linear Interpolation « Next Oldest | Next Newest »

 ▼ Elliott W Jackson Junior Member Posts: 17 Threads: 7 Joined: Feb 2009 02-08-2009, 08:55 AM Hello, I went to college from '80-'84, and lived and died by my HP 41CV. I wrote dozens of programs for it as I progressed through my courses. I recently picked up a new HP 35s, and decided to convert one of my oldest, most-used HP41 programs to the 35 as a learning exercise mainly. The program just does simple linear interpolation. Suppose we have a table of data such as ```... X1 Y1 X2 Y2 ... ``` Given any value X, it simply estimates Y using linear interpolation. The equation to do that is brutally simple, it is just such a frequent need that it is a great candidate for a quickie program. As a further requirement however, I decided that I wanted to make it "low footprint," i.e. such that it only used the absolute minimum of the 26 A..Z named storage registers, and relied instead on the 800 indirect-addressed unnamed storage registers for any temporary storage requirements. I'm not sure how strong a need that is, frankly, but I thought it might be, to preserve the named registers for use as variables in equations, and allow those values to remain unmolested and untrampled-upon. That design decision did complicate things a bit, resulting in some muddy-looking code as the program plays games with the stack, but it's not too bad. Program Name: "L" (it lived for years as "LIP" in my HP41 calculators) Named storage registers used: I Un-named indirect addressed storage registers used: "n" through "n+3", where the value of "n" is set early in the program and can be easily changed if needed. Default = 10. ```L001 LBL L L002 10 Base register 'N' for storage L003 STO I N stored in I L004 SF 10 L005 X2,X1,X Prompt for X2 enter X1 enter X L006 CF 10 L007 STO(I) X stored in N L008 1 L009 STO+ I N+1 stored in I L010 RDN L011 RDN L012 STO(I) X1 stored in N+1 L013 1 L014 STO+ I N+2 stored in I L015 RDN L016 RDN L017 STO(I) X2 stored in N+2 L018 1 L019 STO+ I N+3 stored in I L020 SF 10 L021 Y2,Y1 Prompt for Y2 enter Y1 L022 CF 10 L024 STO(I) Y1 stored in N+3 L025 - (Y2-Y1) L026 1 L027 STO- I N+2 stored in I L028 RDN L029 RCL(I) X2 L030 1 L031 STO- I N+1 stored in I L032 RDN L033 RCL(I) X1 L034 - (X2-X1) L035 / (Y2-Y1)/(X2-X1) L036 RCL(I) X1 L037 1 L038 STO- I N stored in I L039 RDN L040 RCL(I) X L041 X<>Y L042 - (X-X1) L043 * (X-X1)*(Y2-Y1)/(X2-X1) L044 3 L045 STO+ I N+3 stored in I L046 RDN L047 RCL(I) Y1 L048 + (X-X1)*(Y2-Y1)/(X2-X1) + Y1 L049 RTN Y is left in X-register LN=166 CK=FC9A ``` As mentioned, the linear interpolation equation is trivial and straightforward and not really worthy of much discussion. The only thing possibly novel in this program is my attempt to make it "low footprint", and use the un-named storage registers as much as possible for temporary storage needs, rather than the named A..Z registers. That decision did complicate the code a bit, as I had to manipulate I in the middle of the "real math", which complicates the listing somewhat. Best, Elliott ▼ Cliff V Junior Member Posts: 1 Threads: 0 Joined: Jan 1970 02-15-2009, 08:04 AM thanks for the program. step 23 is missing. ▼ Elliott W Jackson Junior Member Posts: 17 Threads: 7 Joined: Feb 2009 02-15-2009, 08:39 PM Oops, thanks for noticing. It's actually not missing, my line numbers are just messed up. The LN and CK numbers are correct, and the program should end on line L048.

 Possibly Related Threads... Thread Author Replies Views Last Post HP prime: linear solver app Alberto Candel 1 1,092 11-21-2013, 01:57 AM Last Post: Michael Carey HP Prime: Linear Solver app bug BruceH 0 831 11-15-2013, 06:36 PM Last Post: BruceH Very low Price of HP Prime? Harold A Climer 14 3,319 10-10-2013, 01:51 PM Last Post: Frank Boehm (Germany) Low battery slow mode Marcel Samek 4 1,308 09-18-2013, 02:02 PM Last Post: Harald Low power warning for HP-15C LE and batteries Nick_S 1 1,166 09-16-2013, 09:34 AM Last Post: Hans Brueggemann New article on a new type of neo linear equations Namir 0 1,108 08-11-2013, 10:27 AM Last Post: Namir Linear Optimization/Programming fhub 14 3,338 08-04-2013, 06:27 AM Last Post: fhub Linear Programming - Simplex Algorithm LarryLion 5 1,348 09-04-2012, 10:57 PM Last Post: David Hayden Where is linear regression on an HP-41 Palmer O. Hanson, Jr. 22 4,614 08-13-2012, 10:43 PM Last Post: Gerson W. Barbosa New Quadratic Lagrangian Interpolation Method Namir 2 1,128 07-20-2012, 04:32 PM Last Post: Namir

Forum Jump: