MathGroup Archive 2009

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

Search the Archive

Re: Naming Operators in Pure Function form

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101860] Re: Naming Operators in Pure Function form
  • From: earthnut at web.de (Bastian Erdnuess)
  • Date: Mon, 20 Jul 2009 05:59:50 -0400 (EDT)
  • References: <h3s1u3$61l$1@smc.vnet.net>

Mathematica cannot know that you want to explain the sum of to operators
pointwise, i.e.

  (X+T)(f) = X(f) + T(f)  .

You can "teach" Mathematica a simple operator algebra (@ as
multiplication) with the lines

  Unprotect[Function];
  a_Function + b_Function ^:= a[##] + b[##] &
  Function /: a_?NumberQ * b_Function := a * b[##] &
  Protect[Function];

Then your example works as you desired:

  X = D[ #, x ] &
  T = D[ #, x ] &
  (X + T) @ (X - T) @ f[ t, x ]

  -->  f^(0,2) [ t, x ] - f^(2,0) [ t, x ]

But be careful, I'm not sure if it is a good idea to do that.
  
Bastian

Sid <pcoords29 at gmail.com> wrote:

> Dear Mathgroup,
> 
> I am having a problem with naming differential operators wriiten as
> pure functions.
> 
> Consider the simple example   (1-D wave operator)
> 
>         (D[#1, x] + D[#1, t] & ) @ (D[#1, x] - D[#1, t] & )   ...
> (*)
> 
> I want to name the diffl operators as follows :
> 
>  Let  X  be  d/dx  and  T  be d/dt
> 
> Now, if I  define  X = D[#1, x] &   and   T =  D[#1, t]  &,  that
> 
> won't do.  Also, omitting an ampersand will give zero.
> 
> So , how should I define pure functions X and T so that (*) above
> 
> can be written  as
> 
>                         (X +T ) @ (X -T )
> 
>  (In my actual problem, I have in place of X  a spherical Laplacian
> plus some first-order operators and constants. )
> 
> 
>  Any hints to help me suss this out  will be most appreciated.
> 
> Thanking you in advance.
> 
> Regards.
> 
> Sid.


  • Prev by Date: Re: Odd behavior?
  • Next by Date: Re: Odd behavior?
  • Previous by thread: Re: Naming Operators in Pure Function form
  • Next by thread: i need package help or dyanamic help