HP Forums
Defining a function with vectors - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Defining a function with vectors (/thread-20545.html)



Defining a function with vectors - Quadratica - 09-23-2023 11:26 PM

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.


RE: Defining a function with vectors - roadrunner - 09-24-2023 01:00 AM

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


RE: Defining a function with vectors - parisse - 09-24-2023 02:50 PM

If you define a cas program, you should not use Home reserved variables.
cp(a,b,c):=cross([a,b,c],[c,b,a])


RE: Defining a function with vectors - Quadratica - 09-24-2023 07:17 PM

Thanks Parisse, I had no idea I could define functions in this way. It works and my calculations have been made much easier !