Re: Newbie Question About An Error Message

• To: mathgroup at smc.vnet.net
• Subject: [mg55456] Re: [mg55443] Newbie Question About An Error Message
• From: Sseziwa Mukasa <mukasa at jeol.com>
• Date: Thu, 24 Mar 2005 03:41:55 -0500 (EST)
• References: <200503231034.FAA04057@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Mar 23, 2005, at 5:34 AM, Adam Hartshorne wrote:

> 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]

To make answering your question easier I'm going to interrupt here and
comment on this function.  You have written a function abs which takes
one argument that should have at least three parts.

> Ok then I try
>
> D[(abs[{x-xi}])^2,x]

You have called your function abs with the argument {x-xi}, assuming x
and xi have not otherwise been defined this is a list with only one
part.

> 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.

I think these messages should make sense now.

> Any help will be much appreciated,

I hope this helped.

If you redefine your abs function as abs[x_]:=Sqrt[Plus@@#^2&/@x] then
you will no longer be making assumptions about the length of x and your
D[___] expression will work as you expected.

Regards,

Ssezi

```

• Prev by Date: Re: appending '.' in CForm
• Next by Date: Re: Newbie Question About An Error Message