Post Reply 
What Am I Missing (HP-71B)
11-03-2014, 04:53 AM
Post: #1
What Am I Missing (HP-71B)
I was messing around with some numbers this morning, preparing to explain to some not-very-technical students what a vector dot product is. Initially I grabbed my trusty 41CX, but then I thought this would be a chance to explore the 71. OK, there's no R->P conversion, but there's ANGLE(x,y) and that gets the job done just fine.

Then I thought, OK, let's write a user-definable function to calculate the dot product. First, I'll set up a couple of arrays as my 2D vectors (this is only to be a simple example!):

Code:
DIM A(1) @ DIM B(1)
A(0) = 4 @ A(1) = 4 @ B(0) = 5 @ B(1) = 4

But I ran into trouble when trying to define a function for the dot product. I thought the syntax would be something like this:

Code:
DEF FND(A,B) = A(0) * B(0) + A(1) * B(1)

I get an "Illegal context" error message immediately on entering that line. Figuring that it might be the way I'm trying to pass two array variables as parameters, I thought I'd backtrack to a simpler example:

Code:
DEF FNA(A) = A * A

But no - even that gives the "Illegal context" error, yet it looks just like the examples in the User's Guide, etc.

So, what am I doing wrong?

And for the more complex dot product UDF, I expect I have to dimension A and B somehow, but I can't see any examples of how this is done for formal parameters in the manuals.

Grateful for any help! (Meanwhile, I'll do the whiteboard work on dot products using the 32SII!)

--- Les
[http://www.lesbell.com.au]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
What Am I Missing (HP-71B) - Les Bell - 11-03-2014 04:53 AM
RE: What Am I Missing (HP-71B) - Les Bell - 11-03-2014, 10:45 AM
RE: What Am I Missing (HP-71B) - cruff - 11-03-2014, 01:41 PM
RE: What Am I Missing (HP-71B) - Les Bell - 11-03-2014, 10:21 PM
RE: What Am I Missing (HP-71B) - Les Bell - 11-04-2014, 01:01 AM
RE: What Am I Missing (HP-71B) - Joe Horn - 11-05-2014, 05:25 AM
RE: What Am I Missing (HP-71B) - Les Bell - 11-05-2014, 07:24 AM



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