MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

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[1]:= g[x_]:=D[Sin[x],x]

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

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

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

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

In[6]:= f[1.]
Out[6]= 0.540302

In[7]:= f[1]//N
Out[7]= 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[1]].

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

Thank you for your help,
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