MathGroup Archive 1998

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

Search the Archive

Re: Derivatives D[ ] as Functions inside Tables; Need Help!


siegman at ee.stanford.edu wrote:

"I'm trying to define a function f1[a,x] and its derivative f2[a,x],
where from my point of view x is the independent variable and   "a" is
a parameter I'll change on different runs.  So I write, as a simple
example:

   Remove["Global`*"]

   f1[a_,x_] :=a Cos[x] + a^2 Sin[x]

   f1[a,x]

   f2[a_,x_] := D[f1[a,x],x]

   f2[a,x]

   a=2

   f1[a,x]

   f2[a,x]

   Table[{x, f1[a,x], f2[a.x]} // N, {x,0,4}] // TableForm

and everything looks fine -- except the function f2[a,x] will not
evaluate inside the Table[ ].  I don't understand this -- help in
understanding will be much appreciated."
*************************************

There seems to be two problems: (1), the iterator {x,0,4} defaults to
integer steps because it is given no stepsize; and (2),the derivitive
wrapped by the Table function in the must be evaluated befor a
numerical value of x is substituted. Try this. Keep everything the same
excepy the last statement. Replace it with

Table[{xx, f1[a,xx], f2[a.xx]}xx->x // N, {x,0,4,0.2}] // TableForm

Actually, the //N is redundant.

Regards.

Hugh Walker
Professsor Emeritus
University of Houston

Gnarly Oaks



  • Prev by Date: Re: 3D table plot Pbs
  • Next by Date: Re: coordinate transformation
  • Previous by thread: Re: Derivatives D[ ] as Functions inside Tables; Need Help!
  • Next by thread: Re: Derivatives D[ ] as Functions inside Tables; Need Help!