Defining a function with vectors
09-23-2023, 11:26 PM
Post: #1
 Quadratica Junior Member Posts: 29 Joined: Aug 2023
Defining a function with vectors
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.
09-24-2023, 01:00 AM
Post: #2
 roadrunner Senior Member Posts: 440 Joined: Jun 2015
RE: Defining a function with vectors
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}))

09-24-2023, 02:50 PM
Post: #3
 parisse Senior Member Posts: 1,309 Joined: Dec 2013
RE: Defining a function with vectors
If you define a cas program, you should not use Home reserved variables.
cp(a,b,c):=cross([a,b,c],[c,b,a])
09-24-2023, 07:17 PM
Post: #4
 Quadratica Junior Member Posts: 29 Joined: Aug 2023
RE: Defining a function with vectors
Thanks Parisse, I had no idea I could define functions in this way. It works and my calculations have been made much easier !
 « Next Oldest | Next Newest »