MathGroup Archive 2001

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

Search the Archive

Re: Factorising operators??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30978] Re: [mg30959] Factorising operators??
  • From: Andrzej Kozlowski <andrzej at bekkoame.ne.jp>
  • Date: Sat, 29 Sep 2001 04:18:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I think the easiest way is as follows:

In[1]:=
Unprotect[Plus];

In[2]:=
(m_:1) a[x] +(n_:1)b[x_]+c_:0 :=(m a + n b+c)[x]

In[3]:=
Protect[Plus];

In[4]:=
3a[x]+5b[x]+2

Out[4]=
(2+3 a+5 b)[x]

In[5]:=
a[x]+5b[x]

Out[5]=
(a+5 b)[x]

One should always think twice before modifying such basic built in 
functions as Plus. You might therefore prefer to use a different 
approach. You might for example define a function f, that will transform 
your expression only when you apply f to it:

In[2]:=
f[(m_:1) a[x] +(n_:1)b[x_]+c_:0] :=(m a + n b+c)[x]

In[3]:=
f[3a[x]+5b[x]+2]

Out[3]=
(2+3 a+5 b)[x]

Or you might even find it convenient to use f as a transformation 
function in Simplify:

In[6]:=
Simplify[3a[x]+5b[x]+2,TransformationFunctions->{Automatic,f}]

Out[6]=
(2+3 a+5 b)[x]

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/

On Friday, September 28, 2001, at 04:55  PM, Mat Bowen wrote:

> Hello,
>
> I'm new to mathematica and looking for help with the following:
>
> I have two operators, a and b, that function as approximations to first 
> and
> second order derivatives. I can write (a+b)[x] and then use 
> Through[%,Plus]
> to generate a[x]+b[x] but I want to do the reverse, ie. Get mathematica 
> to
> output (a+b)[x] if I give it a[x]+b[x]. Is there any way (preferably 
> simple)
> to do this which will also work with more general cases ie. 
> a[x]+5b[x]+const
> c[x] should produce (a+5b+const)[x]
>
> Thanks,
> Mat Bowen
>
>
>



  • Prev by Date: Re: Help! FindRoot output to list...
  • Next by Date: Using NonlinearRegress with Dif. Equations
  • Previous by thread: Re: Factorising operators??
  • Next by thread: Re: Factorising operators??