       Re: Numerical calculation of derivative functions

• To: mathgroup at smc.vnet.net
• Subject: [mg17033] Re: [mg17000] Numerical calculation of derivative functions
• From: Maarten.vanderBurgt at icos.be
• Date: Wed, 14 Apr 1999 02:11:50 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Lars,

You should use the Evaluate[ ] command.
Have a look at the difference between the functions g and f below.

In:= g[x_]:=D[Sin[x],x]

In:= ?g
"Global`g"
g[x_] := D[Sin[x], x]

In:= g[1.]
General::"ivar": 1.`is not a valid variable.

In:= f[x_]:=Evaluate[D[Sin[x],x]]

In:= ?f
"Global`f"
f[x_] := Cos[x]

In:= f[1.]
Out= 0.540302

In:= f//N
Out= 0.540302

Maarten

___________________________________________________________________________
____

Maarten van der Burgt

R&D Department

ICOS Vision Systems
Esperantolaan 9
B-3001 Leuven
Belgium
tel.    + 32 16 398220       direct  + 32 16 398316     fax.    + 32 16
400067
e-mail: maarten.vanderburgt at icos.be

___________________________________________________________________________
____

L B Venema <lvenema at kvi.nl> on 10-04-99 08:13:35 AM

Subject: [mg17033]  [mg17000] Numerical calculation of derivative functions

Probably this question is very trivial, but can someone inform me
how I can force mathematica to calculate the numerical result from a
previously evaluated formal solution, like

f[x_]:=D[sin[x],x];
f[x]/.x->1
Also N[%] is not more specific than D[sin].

I think the problem is related that I cannot force Mathematica to first
evaluate the differential and subsequently substitutes the x by 1 in the
cos. (My real problem involves unknown dimensions of arrays in a non-linear
optimization problem).

Lars Venema

```

• Prev by Date: Border on Tables
• Next by Date: Re: ListDensityPlot[ ] and DensityGraphics
• Previous by thread: Re: Numerical calculation of derivative functions
• Next by thread: Re: Numerical calculation of derivative functions