Re: Working with D, definition of a function

• To: mathgroup at smc.vnet.net
• Subject: [mg75995] Re: Working with D, definition of a function
• From: Szabolcs <szhorvat at gmail.com>
• Date: Mon, 14 May 2007 03:53:39 -0400 (EDT)
• Organization: University of Bergen
• References: <f26nfr\$450\$1@smc.vnet.net>

```Thomas Schmelzer wrote:
> Hi,
>
> I have defined a map
>
> ComPath[w_, mu_, bias_] := mu*(\[ImaginaryI]*w + 1)^2 + bias;
> Now, I would like to use the derivative with respect to w as a further
> function.
>
> D[ComPath[w, mu, 0], w]
>
> gives the answer I expect, but
>
> ComPathPrime[w_, mu_] := D[ComPath[w, mu, 0], w];
>
> doesn't seem to make sense
>
> ComPathPrime[2, 1]
>
> results in
>
> General::ivar : 2 is  not a valid variable.
>
>
>
> If it seems I have a lack of knowledge about the internals of Mathmatica -
> that's right.
>
> Can you briefly explain why this should not work?
>
> Best,
>
> Thomas

This is a common mistake new users make. Look up Set and SetDelayed (=
and :=). You don't need ; at the end of definitions here.

http://reference.wolfram.com/mathematica/tutorial/ImmediateAndDelayedDefinitions.html

You must use
ComPathPrime[w_, mu_] = D[ComPath[w, mu, 0], w]
to get the result you expect.

```

• Prev by Date: RE: Mathematica 6.0 - Legend
• Next by Date: Re: Working with D, definition of a function
• Previous by thread: Re: Working with D, definition of a function
• Next by thread: Re: Working with D, definition of a function