(Original article follows)
Mathematica does not know the difference between indexed functions
and functions of an integer. Apparently when you try to compute the
derivative of something like a[1] you get
Dt[a[1],x] = Dt[1,x]*Derivative[1][a][1]
This is useful if you want to make constants without having to worry about
derivatives acting correctly. Unfortunately it makes it hard to create
indexed functions.
One workaround that I have used is to move back and forth between two forms
of the function a[i]. I create a sequence of functions a1, a2, etc
and convert between them using;
Cat[dumx_,dumy_] := ToExpression[StringJoin[ToString[dumx],ToString[dumy]]];
subI = {a[i_] :> Cat[a,i]};
and
subII = Table[Cat[a,i] -> a[i], {i,numberofa}]
=================================
In[3]:= a[4] /. subI
Out[3]= a4
In[4]:= numberofa = 10
Out[4]= 10
In[6]:= a4 /. subII
Out[6]= a[4]
=================================
Of course this is pretty crude and requires that you know how many indexed
functions you are going to have.
A second method is to make "a" an array of Function objects.
For example:
===================================
In[9]:= Clear[a]
In[10]:= a = {Sin, Cos, (1 + #)^2 &};
In[11]:= a[[1]][t]
Out[11]= Sin[t]
In[12]:= a[[3]][x]
2
Out[12]= (1 + x)
==================================
Then you can differentiate elements of the vector "a"
=================================
In[14]:= Dt[a[[3]],x]
2
Out[14]= Dt[(1 + #1) , x] &
In[15]:= %[x^2]
2
Out[15]= 4 x (1 + x )
=================================
Scott Herod
Applied Mathematics
University of Colorado, Boulder
sherod at newton.colorado.edu
In article <49je70$53i at dragonfly.wri.com>, george at mech.seas.upenn.edu ( George Jefferson ) writes:
|> What am I missing?
|>
|> total derivative of unspecified y:
|>
|> In[1]:= Dt[y,x]
|>
|> Out[1]= Dt[y, x]
|>
|> But if we take the derivaitve of an undefined indexed variable
|> it is assumed to be a constant..
|>
|> In[2]:= Dt[a[1],x]
|>
|> Out[2]= 0
|>
|> note however that the indexed symbol could easily represent a non-constant.
|>
|> In[3]:= a[1]=y; Dt[a[1],x]
|>
|> Out[3]= Dt[y, x]
|>
|>
|> clearly the trouble is that there is no distinction between an indexed
|> symbol and a function evaluated at a fixed point..
|> Is there a workaround?