Re: D[...] change in 5.1

• To: mathgroup at smc.vnet.net
• Subject: [mg58710] Re: D[...] change in 5.1
• From: Daniel Huber <dh at metrohm.ch>
• Date: Fri, 15 Jul 2005 03:02:29 -0400 (EDT)
• References: <db57qa\$4ri\$1@smc.vnet.net> <42D691EF.6020500@gmail.com> <200507141456.42362.akolzine@uiuc.edu>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Alexei,
You have a misunderstanding of pattern matching.
It is clear that the left hand side of a definition must match. This is
only the case if anything that is not marked as a pattern must match
literally. E.g. f[a] only matches f[a] and not f[b]. On the other hand
f[a_] matches f[b].

D[n[i_], x[j_], NonConstants -> n]

Here only i and j are pattern. Ther rest must match literally. This is not the case with:
D[1 + n[k], x[l], NonConstants -> n]
Here "1+" does not match. To make it match you would need a pattern like:
D[a_:0 + n[i_], x[j_], NonConstants -> n]
This accounts for an additive term with a default value of 0.

Further, I do not see why you need the "NonConstants -> n".

sincerely, Daniel

Alexei Akolzin wrote:

>I am sorry, here what I meant:
>
>In[1] := n /: D[n[i_], x[j_], NonConstants -> n] := (1/r)*(d[i, j] -
>n[i]*n[j]);
>
>In[2] := D[n[k], x[l], NonConstants -> n]
>Out[2] = (d[k, l] - n[k] n[l]) / r
>
>In[3] := D[1 + n[k], x[l], NonConstants -> n]
>Out[3] = D[n, x[l], NonConstants -> n]
>
>In[4] := \$Version
>Out[4] = "5.1 for Linux x86 (64 bit) (January 27, 2005)"
>
>From my point of view Out[3] should be exactly equal to Out[2]. It was
>in earlier versions, but it is not in 5.1! The difference gives all
>kind of problems in more complicated expressions. I try to combat this
>with Hold and ReleaseHold, but ran into a more peculiar problem, which
>is even more puzzling to me:
>
>In[1] := n /: D[ n[i_], x[j_], NonConstants -> {n, r} ] := ( \[Delta][i,
>j] - n[i] n[j]) / r;
>In[2] := r /: D[ r, x[i_], NonConstants -> {n,r} ] := n[i];
>
>In[3] := D[ \[Delta][i,j] BesselJ[0 , k r] , x[l], NonConstants ->
>{n,r} ]
>Out[3] = 0
>
>In[4] := D[ \[Delta][i,j] BesselJ[0 , k r] , x[m], NonConstants ->
>{n,r} ]
>Out[4] = - k BesselJ[1,k r] n[m] \[Delta][i,j]
>
>In[8] := ?k
>Global`k
>
>In[9]:= ? \[Delta]
>Global`\[Delta]
>
>Now, Out[3] and Out[4] should be the simmilar. The only difference is
>what simbol "m"  or "l" is used in respective differentiation by x[m]
>or x[l]. But again they are not. The problem disappears if I substitute
>"\[Delta]", which I enter from keyboard as Esc d Esc, for example by
>"d".
>
>Sincerely,
>Alexei.
>
>
>
>
>On Thursday 14 July 2005 11:25, you wrote:
>
>
>>Alexei Akolzin wrote:
>>
>>
>>>Hi,
>>>
>>>In previous version two lines below seemed to work as intended:
>>>
>>>In:
>>>n /: D[n[i_], x[j_], NonConstants -> {n,r}] := (1/r)( d[i,j] - n[i]
>>>n[j] ); D[ 1 + n[k], x[l] ]
>>>
>>>Out: (-n[k] n[l] + d[k,l]) \ r
>>>
>>>But now in ver 5.1 I get something like:
>>>Out: D[n, x[l], NonConstants -> {J, r, n}] (1)
>>>
>>>The funny part is that D[ n[k], x[l] ] is recognized and
>>>substituted by the expression associated with definition of n.
>>>
>>>I wonder whether there is a possibility to get Mathematica 5.1
>>>recognize n[k] as an indexed symbol n.
>>>
>>>Thanks.
>>>Alexei Akolzin.
>>>
>>>
>>Hi Alexei,
>>
>>Have you posted the correct expression? I am asking because here what
>>I get with Mathematica 5.1.1:
>>
>>In[1]:=
>>n /: D[n[i_], x[j_], NonConstants -> {n, r}] :=
>>     (1/r)*(d[i, j] - n[i]*n[j]);
>>
>>In[2]:=
>>D[1 + n[k], x[l]]
>>
>>Out[2]=
>>0
>>
>>In[3]:=
>>Information["n", LongForm -> False]
>>
>>n
>>
>>n /: D[n[i_], x[j_], NonConstants -> {n, r}] :=
>>      (1/r)*(d[i, j] - n[i]*n[j])
>>
>>In[4]:=
>>\$Version
>>
>>Out[4]=
>>"5.1 for Microsoft Windows (January 27, 2005)"
>>
>>Best regards,
>>/J.M.
>>
>>
>
>
>
>

--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.ch>
Internet:<http://www.metrohm.ch>

```

• Prev by Date: Re: Light and surface colors
• Next by Date: Re: How to display dates in plots
• Previous by thread: Re: D[...] change in 5.1
• Next by thread: Re: D[...] change in 5.1