MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Functions with vector arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36213] RE: [mg36192] Functions with vector arguments
  • From: "DrBob" <drbob at bigfoot.com>
  • Date: Tue, 27 Aug 2002 02:07:20 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

I get the expected results.  I suspect g was already defined at the
time.  For instance you might have set g={a,b} previously.  ClearAll[g]
goes before defining the function g.

Bobby Treat

-----Original Message-----
From: anhjunk [mailto:anhjunk at hotmail.com] 
To: mathgroup at smc.vnet.net
Subject: [mg36213] [mg36192] Functions with vector arguments

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





  • Prev by Date: RE: Obtaining sequences from lists of lists
  • Next by Date: Re: Obtaining sequences from lists of lists
  • Previous by thread: RE: Functions with vector arguments
  • Next by thread: Re: Functions with vector arguments