Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Patterns_ to define linear operators?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71441] Re: Patterns_ to define linear operators?
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 18 Nov 2006 04:41:11 -0500 (EST)
  • Organization: 1&1 Internet AG
  • References: <ejgvpf$8tm$1@smc.vnet.net>

W. Craig Carter schrieb:
> Hello,
> I'd like to implement a rule that will factor out constants from 
> linear operators such as FourierTransform; i.e.,
> FourierTransform[a*f[x], x, k]  to a*FourierTransform[f[x],x,k]
> 
> Here is a method that seems sensible at first, but is potentially 
> dangerous:
> 
> MyRule1 =
> FourierTransform[a_ f_[y_], x_, k_] :-> a FourierTransform[f[y],x,k]
> (which would fail if a was not free of x)
> 
> An improvement is:
> 
> MyRule2 =
> FourierTransform[a_?(FreeQ[#,x]&), f_[y_], x_, k_] :-> a FourierTransform[f[y],x,k]
> (which would fail if a were a product, say b x)
> 
> Does anybody have advice on a robust way to implement this rule?
> 
> Thanks, Craig Carter
> 

Hi Craig,

I recommend essentially the same as Dimitris does, but use ReplaceRepeated
instead!


myrule=
 lintrans_[a_. * b_,x_,w_] :>
   a*lintrans[b,x,w] /; FreeQ[a,x] && MemberQ[b,x,Infinity];

and compare

ft[3*x*g[y]*y*h[x],x,w] /. myrule
--> 3 ft[x y g[y] h[x],x,w]

with

ft[3*x*g[y]*y*h[x],x,w] //. myrule
--> 3 y ft[x h[x],x,w] g[y]

I guess, the second one is what you expect.

Cheers,
 Peter


  • Prev by Date: Re: mathematica & fortran ??
  • Next by Date: Re: will someone explain the behavior of Unevaluated in this example?
  • Previous by thread: RE: Patterns_ to define linear operators?
  • Next by thread: VerifySolutions setting