HP Forums

Full Version: Defining a function with vectors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to define a function to calculate the cross product of two vectors

cross([A,B,C],[C,B,A]) I give it the name cp

when I define it all that happens is it replaces A,B,C with some number values and the tick boxes to show that it accepts and recognises A,B,C as variable arguments do not show up.

Other definitions like sin(A+B/C*D) work as expected and can be used in the CAS screen.

any help is appreciated as I'm doing lots of vector work lately and looking for shortcuts.
That's definitely a weird issue. You can work around it by putting the three variables into lists and then converting the lists to vectors with ListToMat, like this:

CROSS(ListToMat({A, B, C}),ListToMat({C, B, A}))

-road
If you define a cas program, you should not use Home reserved variables.
cp(a,b,c):=cross([a,b,c],[c,b,a])
Thanks Parisse, I had no idea I could define functions in this way. It works and my calculations have been made much easier !
Reference URL's