Post Reply 
Defining a function with vectors
09-23-2023, 11:26 PM
Post: #1
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.
Find all posts by this user
Quote this message in a reply
09-24-2023, 01:00 AM
Post: #2
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}))

-road
Find all posts by this user
Quote this message in a reply
09-24-2023, 02:50 PM
Post: #3
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])
Find all posts by this user
Quote this message in a reply
09-24-2023, 07:17 PM
Post: #4
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 !
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: