Re: Working with D, definition of a function

*To*: mathgroup at smc.vnet.net*Subject*: [mg75961] Re: Working with D, definition of a function*From*: Norbert Marxer <marxer at mec.li>*Date*: Mon, 14 May 2007 03:35:48 -0400 (EDT)*References*: <f26nfr$450$1@smc.vnet.net>

On 13 Mai, 11:58, "Thomas Schmelzer" <thomas.... at balliol.ox.ac.uk> 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 Hello You should take the derivative with symbols (not with numbers): e.g. ComPath[w_, mu_, bias_] := mu*(I*w + 1)^2 + bias ComPathPrime[w_, mu_] := Block[{w0, mu0}, D[ComPath[w0, mu0, 0], w0] /. {w0 -> w, mu0 -> mu}] ComPathPrime[2, 1] will give -4 + 2*I Best Regards Norbert Marxer