Re: Functions with vector arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg36218] Re: Functions with vector arguments
- From: Alexander Dreyer <dreyer at itwm.fhg.de>
- Date: Tue, 27 Aug 2002 02:07:26 -0400 (EDT)
- Organization: Fraunhofer ITWM
- References: <akcpm8$557$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
anhjunk wrote: > > 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 Hello, in fact this call works fine on my Mathematicas (3.0 up to 4.1). Did You really use the minus character? Maybe some erroneous code was assigned to g before. Restart Mathematica or use Remove[g] to really start up from the beginning. Sincerly Alexander -- / Alexander Dreyer, Dipl.-Math. - Abteilung Adaptive Systeme \ / Fraunhofer Institut fuer Techno- und Wirtschaftsmathematik (ITWM) \ \ Gottlieb-Daimler-Strasse, Geb. 7^2=49/313 D-67663 Kaiserslautern / \ http://www.itwm.fhg.de Tel.:(0631)205-2851 Fax:(0631)205-4139 /