Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11408 > unrolled thread

Defining a total derivative

Started byS16 <sownak27@gmail.com>
First post2012-08-18 07:46 +0000
Last post2012-08-23 06:53 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Defining a total derivative S16 <sownak27@gmail.com> - 2012-08-18 07:46 +0000
    Re: Defining a total derivative S16 <sownak27@gmail.com> - 2012-08-22 06:24 +0000
      Re: Defining a total derivative "Dr. Wolfgang Hintze" <weh@snafu.de> - 2012-08-22 09:20 +0000
      Re: Defining a total derivative Murray Eisenberg <murray@math.umass.edu> - 2012-08-23 06:53 +0000

#11408 — Defining a total derivative

FromS16 <sownak27@gmail.com>
Date2012-08-18 07:46 +0000
SubjectDefining a total derivative
Message-ID<k0nh82$avi$1@smc.vnet.net>
Hi,
I am very new to Mathematica, so need a bit of help!

I want to define a function (called say G) that is defined as

G = =E2=88=82/=E2=88=82x - ((=E2=88=82F/=E2=88=82x)/(=E2=88=82F/=E2=88=82=
y))*=E2=88=82/=E2=88=82y

Where F is some other function which will be defined.

So as you can see, G is a differenital operator. Want to define it so that I can just do G[ some function ] rather than repeatedly write out the whole thing.

Any help at all would be awesome!

-S16

[toc] | [next] | [standalone]


#11437

FromS16 <sownak27@gmail.com>
Date2012-08-22 06:24 +0000
Message-ID<k11tv8$t7e$1@smc.vnet.net>
In reply to#11408
On Saturday, August 18, 2012 8:46:10 AM UTC+1, S16 wrote:
> Hi,
> 
> I am very new to Mathematica, so need a bit of help!
> 
> 
> 
> I want to define a function (called say G) that is defined as
> 
> 
> 
> G = =E2=88=82/=E2=88=82x - ((=E2=88=82F/=E2=88=82x)/(=E2=88=82F/=E2=88=82=
> 
> y))*=E2=88=82/=E2=88=82y
> 
> 
> 
> Where F is some other function which will be defined.
> 
> 
> 
> So as you can see, G is a differenital operator. Want to define it so that I can just do G[ some function ] rather than repeatedly write out the whole thing.
> 
> 
> 
> Any help at all would be awesome!
> 
> 
> 
> -S16



Sorry, my message came out formatted all wrong. I have actually managed to solve this issue- but have a different question. 

Say I have defined an operator G, which involves partial derivatives in x and y

and I want to find expressions for G[G[ ]] , G[G[G[ ]]] - applying the operator multiple times. is there a way to define this on Mathematica (I want to put this in a package).  

[toc] | [prev] | [next] | [standalone]


#11449

From"Dr. Wolfgang Hintze" <weh@snafu.de>
Date2012-08-22 09:20 +0000
Message-ID<k1289n$10r$1@smc.vnet.net>
In reply to#11437
On 22 Aug., 08:24, S16 <sowna...@gmail.com> wrote:
> On Saturday, August 18, 2012 8:46:10 AM UTC+1, S16 wrote:
> > Hi,
>
> > I am very new to Mathematica, so need a bit of help!
>
> > I want to define a function (called say G) that is defined as
>
> > G = =E2=88=82/=E2=88=82x - ((=E2=88=82F/=E2=88=82x)/(=E2=88=82F/=E2=88=82=
>
> > y))*=E2=88=82/=E2=88=82y
>
> > Where F is some other function which will be defined.
>
> > So as you can see, G is a differenital operator. Want to define it so that I can just do G[ some function ] rather than repeatedly write out the whole thing.
>
> > Any help at all would be awesome!
>
> > -S16
>
> Sorry, my message came out formatted all wrong. I have actually managed to solve this issue- but have a different question.
>
> Say I have defined an operator G, which involves partial derivatives in x and y
>
> and I want to find expressions for G[G[ ]] , G[G[G[ ]]] - applying the operator multiple times. is there a way to define this on Mathematica (I want to put this in a package).
>
>

Let's take an example.

Define the operator g as

In[7]:= g = D[#1, x] + D[#1, y] &

Out[7]= D[#1, x] + D[#1, y] &

Test it

In[8]:= g[x + y]

Out[8]= 2

Chose a non trivial funcion

In[20]:= f = Sin[x*y]

Out[20]= Sin[x*y]

Now iterate g and apply it immediately to f

In[22]:= g[g[f]]

Out[22]= 2*Cos[x*y] - x^2*Sin[x*y] - 2*x*y*Sin[x*y] - y^2*Sin[x*y]

But this can be achieved more generally using Nest

In[23]:= Nest[g, f, 2]

Out[23]= 2*Cos[x*y] - x^2*Sin[x*y] - 2*x*y*Sin[x*y] - y^2*Sin[x*y]

Now the step you wanted. Definiting the interation of g without
applying it immediately.

In[27]:= gi[k_] := Nest[g, #1, k] &

Test it

In[28]:= gi[2][f]

Out[28]= 2*Cos[x*y] - x^2*Sin[x*y] - 2*x*y*Sin[x*y] - y^2*Sin[x*y]

Now the third iteration

In[29]:= gi[3][f]

Out[29]= (-x^3)*Cos[x*y] - 3*x^2*y*Cos[x*y] - 3*x*y^2*Cos[x*y] -
 y^3*Cos[x*y] - 6*x*Sin[x*y] - 6*y*Sin[x*y]

Best regards,
Wolfgang

[toc] | [prev] | [next] | [standalone]


#11461

FromMurray Eisenberg <murray@math.umass.edu>
Date2012-08-23 06:53 +0000
Message-ID<k14k20$7gh$1@smc.vnet.net>
In reply to#11437
For the benefit of the O.P., in case of discomfort with using pure 
functions here=85 one can use ordinary explicit function definitions as well:

   g[fn_] := D[fn, x] + D[fn, y]
  
   g[x + y]

   f[x, y] := Sin[x y]

   g[g[f[x,y]]
   Nest[g, f[x,y], 2]

   gi[k_][fn_]:= Nest[g, fn, k]

   gi[3][f[x, y]]

On the other hand, if one wanted to get fancier, he could provide additional arguments that specify the names of the variables with respect to which the derivatives are taken. I leave this as an exercise.

  
On Aug 22, 2012, at 5:19 AM, Dr. Wolfgang Hintze <weh@snafu.de> wrote:

> On 22 Aug., 08:24, S16 <sowna...@gmail.com> wrote:
>> On Saturday, August 18, 2012 8:46:10 AM UTC+1, S16 wrote:
>>> Hi,
>>
>>> I am very new to Mathematica, so need a bit of help!
>>
>>> I want to define a function (called say G) that is defined as
>>
>>> G = =E2=88=82/=E2=88=82x - =
((=E2=88=82F/=E2=88=82x)/(=E2=88=82F/=E2=88=82=
>>
>>> y))*=E2=88=82/=E2=88=82y
>>
>>> Where F is some other function which will be defined.
>>
>>> So as you can see, G is a differenital operator. Want to define it so that I can just do G[ some function ] rather than repeatedly write out the whole thing.
>>
>>> Any help at all would be awesome!
>>
>>> -S16
>>
>> Sorry, my message came out formatted all wrong. I have actually managed to solve this issue- but have a different question.
>>
>> Say I have defined an operator G, which involves partial derivatives in x and y
>>
>> and I want to find expressions for G[G[ ]] , G[G[G[ ]]] - applying the operator multiple times. is there a way to define this on Mathematica (I want to put this in a package).
>>
>>
>
> Let's take an example.
>
> Define the operator g as
>
> In[7]:= g = D[#1, x] + D[#1, y] &
>
> Out[7]= D[#1, x] + D[#1, y] &
>
> Test it
>
> In[8]:= g[x + y]
>
> Out[8]= 2
>
> Chose a non trivial funcion
>
> In[20]:= f = Sin[x*y]
>
> Out[20]= Sin[x*y]
>
> Now iterate g and apply it immediately to f
>
> In[22]:= g[g[f]]
>
> Out[22]= 2*Cos[x*y] - x^2*Sin[x*y] - 2*x*y*Sin[x*y] - y^2*Sin[x*y]
>
> But this can be achieved more generally using Nest
>
> In[23]:= Nest[g, f, 2]
>
> Out[23]= 2*Cos[x*y] - x^2*Sin[x*y] - 2*x*y*Sin[x*y] - y^2*Sin[x*y]
>
> Now the step you wanted. Definiting the interation of g without
> applying it immediately.
>
> In[27]:= gi[k_] := Nest[g, #1, k] &
>
> Test it
>
> In[28]:= gi[2][f]
>
> Out[28]= 2*Cos[x*y] - x^2*Sin[x*y] - 2*x*y*Sin[x*y] - y^2*Sin[x*y]
>
> Now the third iteration
>
> In[29]:= gi[3][f]
>
> Out[29]= (-x^3)*Cos[x*y] - 3*x^2*y*Cos[x*y] - 3*x*y^2*Cos[x*y] -
> y^3*Cos[x*y] - 6*x*Sin[x*y] - 6*y*Sin[x*y]
>
> Best regards,
> Wolfgang

---
Murray Eisenberg                                     =
murray@math.umass.edu
Mathematics & Statistics Dept.      
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                  413 545-2859 (W)
710 North Pleasant Street                      fax   413 545-1801
Amherst, MA 01003-9305





[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web