Being that this is a TI-focused forum, there doesn't seen to be too much of an audience for HP calcs, much less ones that don't graph. Being that as it is, my 35s arrived yesterday, and I'm discovering that it is as much defined by its flaws as its capabilities, as many others have noted. One deficiency that I'd like to address here is the lack of a cross-product function built-in. As this is a programmable calculator, I thought I'd take a crack at it.

There is a HP-supplied cross-product program in the manual, but it requires the user to enter in values for each of the components instead of using the built-in vectors. Here, we hit the second rough-edge in the 35s, as there is no easy way to get a component of a vector (or complex number [that I'm aware of]) other than taking the dot product with a unit normal vector, so that is the method I will use in my program. My initial approach was to put each of the components in its own variable, but this was slow, and I'd rather not clobber more than I have to. Instead, noting that the cross product of two vectors A=(u v w) and B=(x y z) is "((vz-wy) (wx-uz) (uy-vx))", we can describe this as a series of dot products of special vectors composed of specific components of the second vector with the first vector. For example, the first component of AxB is "A.(0 z -y)". The important thing to note here is that we only need four variables to calculate the cross product: A, x, y, and z. Since the 35s has a 4 variable stack, we only need to clobber one variable (to store B while we extract x y and z) instead of the 8 needed with the naive approach.

Of course, this presents the problem of composing the final vector, as it appears we would need to have 3 intermediate sums. Here, however, two of the features of the 35s come to our aid: vectors can be composed as EQN expressions, and within EQN mode we can access the stack through the REG variables (accessable through the R↓ key). This about describes the technical background for the program. To use it, just put your two vectors on the stack and hit [XEQ] [X] [Enter]. It runs in about 1.3s (calculated by running it in a loop), of which I suspect most time is taken doing the dot products. I don't think this can be optimized by splitting the vectors into variables, since any way you cut it you end up with 6 dot products.


Code:
X001 LBL X
X002 STO(I)  // Store the first vector in (I) so we can recall it later
X003 x<>y  // And put the first vector on the bottom of the stack so it doesn't get pushed off
X004 [0,0,1]  // We do this in reverse order so the stack variables correspond to vector components
X005 RCLx(I)
X006 [0,1,0]
X007 RCLx(I)
X008 [1,0,0]
X009 RCLx(I)
X010 [REGTx[0►(I),REGZ,-REGY],REGTx[-REGZ,0,REGX],REGTx[REGY,-REGX,0]]  CK=512E LN=65
X011 RET

CK=CB9D
LN=119


Most of the programs I've seen online seem to be surveying-oriented (seeing as this calc is one of the only RPN calcs allowed on a certain engineering exam). If you have any useful non-surveying-focused programs, feel free to post them here as well.

Edit: Shave a few bytes off the program by clearing (I) in the equation. Checksums and lengths have been updated to match.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement