MathGroup Archive 2005

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

Search the Archive

Re: Newbie Question About An Error Message


Your definition requires that x be a list of dimension 3.  If it is not a list, then 
the parts don't exist and an error occurs.  A more general definition is

abs[x_]:=Sqrt[x.x];

abs[{x1,x2,x3}]

Sqrt[x1^2 + x2^2 + x3^2]

abs[{x1,x2}]

Sqrt[x1^2 + x2^2]

abs[{x1}]

Sqrt[x1^2]

abs[x]

Sqrt[x . x]

D[abs[{x-xi}]^2,x]

2 (x-xi)


Bob Hanlon

> 
> From: Adam Hartshorne <oracle3001 at yahoo.com>
To: mathgroup at smc.vnet.net
> Date: 2005/03/23 Wed AM 05:34:54 EST
> To: mathgroup at smc.vnet.net
> Subject: [mg55454] [mg55443] Newbie Question About An Error Message
> 
> Hi All,
> 
> I am a real newbie to mathematica and have just encountered the 
> following error message and I have no idea why and what it means.
> 
> I have written a function to calculate the abs of a vector as follows
> 
> abs[x_] := Sqrt[x[[1]]^2+x[[2]]^2+x[[3]]^2]
> 
> then i was doing the following fine until a few moments ago and 
> mathematica starting complaining. I am to my knowledge not asking 
> anything different to what I asked it before, but I don't know enough 
> about mathematica to know much more.
> 
> Ok then I try
> 
> D[(abs[{x-xi}])^2,x]
> 
> Which is know the answer to is 2(x-xi), and mathematica has given me the 
> answer. However now it is saying, maybe I have changed my input and no 
> am typing something wrong.
> 
> Part::partw: Part 2 of {x - xi} does not exist.
> 
> Part::partw: Part 3 of {x - xi} does not exist.
> 
> Any help will be much appreciated,
> 
> Adam
> 
> 


  • Prev by Date: Re: Newbie Question About An Error Message
  • Next by Date: Re: Newbie Question About An Error Message
  • Previous by thread: Re: Newbie Question About An Error Message
  • Next by thread: Re: Re: Newbie Question About An Error Message