MathGroup Archive 2007

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

Search the Archive

Re: Factorise with respect to a variable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79640] Re: Factorise with respect to a variable
  • From: Andrew Moylan <andrew.j.moylan at gmail.com>
  • Date: Wed, 1 Aug 2007 04:53:52 -0400 (EDT)
  • References: <200707301043.GAA01238@smc.vnet.net><f8n2bt$koe$1@smc.vnet.net>

Clever solution Andrzej! For those who are interested, you can add
something like these extra definitions to generalise it to factorise
with respect to multiple variables:

FF[expr_, {x_}] := FF[expr, x]

FF[expr_, xx_List] := With[{FFx = FF[expr, First[xx]]},
   Union[{First[FFx]}, FF[FFx[[2]], Rest[xx]]]]

Now FF[1/(x y z),{x,y}] becomes {1/x,1/y,1/z}.




On Jul 31, 8:19 pm, Andrzej Kozlowski <a... at mimuw.edu.pl> wrote:
> Its not perfect, but (I think) close enough:
>
> FF[expr_, x_] :=
>   Module[{ls = FactorList[expr], s},
>    s = DeleteCases[ls, _?(FreeQ[#, x] &), {1}]; {Times @@ (Power[##]
> & @@@ s),
>     Times @@ (Power[##] & @@@ Complement[ls, s])}]
>
> Then
>
>   FF[1/(2*x*y^2), x]
>   {1/x, 1/(2*y^2)}
>
> FF[1/(2*x*y^2), y]
> {1/y^2, 1/(2*x)}
>
> and
>
> expr = (E^(I*(2*chi2 - kappa + 2*chi1*n1 - kappa*n1 - 2*chi2*n2 +
> kappa*n2 +
>            I*x*SuperStar[x] + I*y*SuperStar[y]))*Sqrt[1 + n1]*Sqrt[n2]
> *x^n1*
>       y^n2*SuperStar[x]^(1 + n1)*SuperStar[y]^(-1 + n2))/
>     Sqrt[n1!*(1 + n1)!*(-1 + n2)!*n2!];
>
> FF[expr, n1]
> {(E^(2*I*chi1*n1 - I*kappa*n1)*Sqrt[n1 + 1]*x^n1*
>      SuperStar[x]^n1)/Sqrt[n1!*(n1 + 1)!*(n2 - 1)!*
>       n2!], E^(-2*I*n2*chi2 + 2*I*chi2 - I*kappa +
>       I*kappa*n2 - x*SuperStar[x] - y*SuperStar[y])*
>     Sqrt[n2]*y^n2*SuperStar[x]*SuperStar[y]^(n2 - 1)}
>
> Andrzej Kozlowski
>
> On 30 Jul 2007, at 12:43,AndrewMoylanwrote:
>
> > Here's an arbitrary expression that depends (non-polynominally) on
> > n1 and
> > some other variables:
>
> > expr = (E^(I*(2*chi2 - kappa + 2*chi1*n1 - kappa*n1 - 2*chi2*n2 +
> >                 kappa*n2 + I*x*SuperStar[x] + I*y*SuperStar[y]))*
> >     Sqrt[1 + n1]*
> >         Sqrt[n2]*x^n1*y^n2*SuperStar[x]^(1 + n1)*
> >     SuperStar[y]^(-1 + n2))/
> >      Sqrt[n1!*(1 + n1)!*(-1 + n2)!*n2!]
>
> > Is it possible to use Mathematica to factor out the dependence of
> > expr on
> > n1? That is, I would like to factorise expr into {expr1,expr2},
> > such that
> > (i) expr1 depends on n1, (ii) expr2 does not depend on n1, and such
> > that
> > (given (i) and (ii)) expr1 is as simple as possible.
>
> > Here's a simpler example: When I factorise 1/(2*x*y^2) "with
> > respect to" x,
> > I want the result to be {1/x, 1/(2*y^2)}.
>
> > Do you think it's possible to easily get Mathematica to do
> > something like
> > this?




  • Prev by Date: Re: How do you set up third party (or your own) packages?
  • Next by Date: RE: Re: Re: Where is the Navigate menu
  • Previous by thread: Re: Unbearably slow plotting (v6)David Bailey,http://www.dbaileyconsultancy.co.uk
  • Next by thread: RE: Re: Re: Where is the Navigate menu