Re: defining a function with D

• To: mathgroup at smc.vnet.net
• Subject: [mg37175] Re: defining a function with D
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Tue, 15 Oct 2002 04:17:48 -0400 (EDT)
• References: <aodnti\$mlg\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Jason,

We have

dfx[x_,t_]= D[f[x,t],x]

t Cos[t x]

One advantage of using = rather than := is that it differentiates once, when
the definition is stored,

Definition[dfx]

t Cos[t x]

With := we get

Clear[dfx]

dfx[x_,t_]:= D[f[x,t],x]

Definition[dfx]

dfx[x_, t_] := D[f[x, t], x]

So the differentiation is done each time that the function dfx is evaluated.

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Jason Miller" <millerj at truman.edu> wrote in message
news:aodnti\$mlg\$1 at smc.vnet.net...
> Dear Listers,
>
> I find myself defining functions in terms of differentiation.  For
example,
>
> f[x_,t_]:=Sin[x*t]
> dfx[x_,t]:=D[Sin[y,t],y]/.y->x
>
> This works well, but it seems to me that there should be a better way
> to do this.  That is, there should be a better way to define a
> 'derivative' of a previous function without going through the
> replacement contortions.   I can't find the answer in the archive.
> Can someone tell me the most straightforward way to do this?  Will it
> work to define a gradient vector or Jacobian matrix?  A Hessian
> matrix?
>
> --
> Jason Miller, Ph.D.
> Division of Mathematics and Computer Science
> Truman State University
> 100 East Normal St.
> Kirksville, MO  63501
> http://vh216801.truman.edu
> 660.785.7430
>

```

• Prev by Date: Re: Get rid of onion-like parentheses
• Next by Date: Re: re: Accuracy and Precision
• Previous by thread: Re: defining a function with D
• Next by thread: Re: Re: defining a function with D