RE: Functions with vector arguments
- To: mathgroup at smc.vnet.net
 - Subject: [mg36231] RE: [mg36192] Functions with vector arguments
 - From: "David Park" <djmp at earthlink.net>
 - Date: Tue, 27 Aug 2002 02:07:49 -0400 (EDT)
 - Sender: owner-wri-mathgroup at wolfram.com
 
I don't have that problem in Version 4.1.
g[u_, v_] := u - v
g[{x1, y1}, {x2, y2}]
{x1 - x2, y1 - y2}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/ 
From: anhjunk [mailto:anhjunk at hotmail.com]
To: mathgroup at smc.vnet.net
Some functions with vector arguments work as expected and some give
errors. I would appreciate if someone can clarify why.
First an example of a function definition that works fine :
f[u_,v_] := u.v
Calling it with f[{x1,y1},{x2,y2}] gives the expected result x1 x2 +
y1 y2.
Now an example that does not work :
g[u_,v_] := u-v
Calling it with g[{x1,y1},{x2,y2}] one would expect the answer {x1-x2,
y1-y2} but instead one gets error messages.
Why ? And how do I fix g (i.e write a function that outputs the
difference of 2 vectors).
Thanks