MathGroup Archive 2003

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

Search the Archive

Re: Re: Dealing with sums

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41046] Re: [mg41014] Re: Dealing with sums
  • From: "Carl K. Woll" <carl at woll2woll.com>
  • Date: Wed, 30 Apr 2003 04:21:48 -0400 (EDT)
  • References: <NDBBJGNHKLMPLILOIPPOIEIODIAA.djmp@earthlink.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi David,

I may be wrong, but I don't believe that the SubscriptSymbols package will
solve the problem. I have only glanced at the documentation, but it seems
that the package is designed to turn subscripts into symbols. If so, this is
exactly what we don't want to do. Consider the following definition
fragment:

D[Subscript[a,i_],Subscript[a,j_],NonConstants->{a}]:=DiscreteDelta[i-j]

In this definition it is absolutely imperative that the i_ and j_ values are
available, and not buried in a symbolized subscript such as a_Subscript_i as
the original notation packaged did.

I believe the approach I gave for handling derivatives of subscripted
variables is probably optimal, and I would need to see compelling evidence
to change my mind.

Carl Woll
Physics Dept
U of Washington

----- Original Message ----- 
From: "David Park" <djmp at earthlink.net>
To: mathgroup at smc.vnet.net
Subject: [mg41046] RE: [mg41014] Re: Dealing with sums


> Carl,
>
> Have you tried out Ted Ersek's SubscriptSymbols package? It should solve
the
> problem.
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> From: Carl K. Woll [mailto:carl at woll2woll.com]
To: mathgroup at smc.vnet.net
>
> Stepan,
>
> I originally considered this problem dealing with expressions like a[i]
> instead of a_i, and my proposed solution worked fine when dealing with
sums
> with functions of the a[i]. I was hasty in proposing the same solution for
> subscripted variables, since the Subscript head mucks things up when doing
> the derivatives which need to use the chain rule. As you probably noticed,
> Bob Hanlon's solution doesn't handle functions of a_i either. This is
> because Mathematica doesn't automatically use the chain rule so that your
> definitions for D can take effect. By including the NonConstants option in
> D, you force Mathematica to use the chain rule so that your new definition
> for D can have a chance to be excersized. Unfortunately, this mechanism
> doesn't quite work when you have subscripted variables, as the head
> Subscript gets differentiated.
>
> I see two possibilities here. Either work with terms like a[i] instead of
> subscripted variables, or delve into the mysterious underworld of
MakeBoxes
> and MakeExpression so that the internal form of the subscripted variables
is
> simply a[i]. Pursuing the second option, we make the following
definitions:
>
> MakeExpression[SubscriptBox["a", i_], f_] :=
>     MakeExpression[RowBox[{"a", "[", i, "]"}]]
>
> MakeBoxes[a[i_], f_] :=
>     SubscriptBox[MakeBoxes[a, f], MakeBoxes[i, f]]
>
> Now, whenever Mathematica encounters a subscripted variable a_i, it turns
it
> into a[i], and whenever Mathematica generates output with a[i], it
converts
> into a_i. Next, we need to add rules for D and Sum:
>
> Unprotect[D];
> D[a[m_], a[n_], NonConstants -> {a}] := DiscreteDelta[n - m]
> D[HoldPattern[Sum[t_, x_]], y__] := Sum[D[t, y], x]
> Protect[D];
>
> We are ready to test things out:
>
> In[12]:=
> \!\(D[Sum[a\_i\^2, {i, 0, n}], a\_m, NonConstants \[Rule] {a}]\)
> Out[12]=
> \!\(2\ a\_m\ UnitStep[m]\ UnitStep[\(-m\) + n]\)
>
> In the above I used StandardForm for both input and output to show that
the
> input as well as the output consisted of subscripted variables, and that
the
> use of the internal form a[i] was completely transparent to the user.
>
> Finally, I want to point out that I still think it is preferable to create
> new symbols d, sum and delta and create similar rules as the above. If you
> try using D on more complicated sums of functions of a_i I think you will
> see why.
>
> Carl Woll
> Physics Dept
> U of Washington
>
> ----- Original Message -----
> From: "Stepan Yakovenko" <yakovenko at ngs.ru>
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> Subject: [mg41046] [mg41014] Re[2]: Dealing with sums
>
>
> >
> >
> > Hello Carl !
> >
> > Thanks for you concern !
> > I'm greatly busy now, so I've no time to get into the heart of the
> > matter. Though I've got the natural question: would this work with
> > Sum[f[a_i],{i,1,N}] ?
>
>
>
>




  • Prev by Date: Re: Writing Applications for Mac OS X
  • Next by Date: RE: Show[] applied to a Plot[] and a ListPlot[] ??
  • Previous by thread: RE: Re: Dealing with sums
  • Next by thread: Example arrow