Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: derivatives of indexed variables

  • Subject: [mg2653] Re: derivatives of indexed variables
  • From: sherod at boussinesq.Colorado.EDU (Scott Herod)
  • Date: Thu, 30 Nov 1995 21:04:35 -0500
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: University of Colorado at Boulder

(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?



  • Prev by Date: Re: [Q] how fast is each machine with Mathematica ?
  • Next by Date: Re: Point Labels on XY plot
  • Previous by thread: Re: Re; Mathematica 2.2.1 upgrade/ChemicalElements
  • Next by thread: Re: Point Labels on XY plot