       Re: Factorising operators??

• To: mathgroup at smc.vnet.net
• Subject: [mg30982] Re: [mg30959] Factorising operators??
• From: Tomas Garza <tgarza01 at prodigy.net.mx>
• Date: Sat, 29 Sep 2001 04:19:01 -0400 (EDT)
• References: <200109280755.DAA01722@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```I guess you might play around with strings and obtain what you want (they
say that everything in Mathematica is an expression). I think that the
function opFactor defined below does it:

In:=
opFactor[r_]:=
ToExpression[
StringReplace[
ToString[Collect[ToExpression[StringReplace[ToString[r],"[x]"->" y"]],
y]]," y"->"[x]"]]

(note that " y" has a leading blank space)

In:=
opFactor[a[x]+b[x]]
Out=
(a+b)[x]

In:=
opFactor[a[x]+5 b[x]+3 c[x]]
Out=
(a+5 b+3 c)[x]

Tomas Garza
Mexico City

----- Original Message -----
From: "Mat Bowen" <m.k.bowen at lboro.ac.uk>
To: mathgroup at smc.vnet.net
Subject: [mg30982] [mg30959] Factorising operators??

> 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: ListDensityPlot print problem + poll
• Next by Date: Re: Help! FindRoot output to list...
• Previous by thread: Factorising operators??
• Next by thread: Re: Factorising operators??