Re: Re: Re: how to have a blind factorization of a polinomial?
- To: mathgroup at smc.vnet.net
- Subject: [mg54192] Re: [mg54151] Re: [mg54123] Re: how to have a blind factorization of a polinomial?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sun, 13 Feb 2005 00:21:24 -0500 (EST)
- References: <cud789$2t3$1@smc.vnet.net> <cuf453$gfb$1@smc.vnet.net> <200502110833.DAA09170@smc.vnet.net> <200502120656.BAA21687@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 12 Feb 2005, at 06:56, Andrzej Kozlowski wrote: > On 11 Feb 2005, at 08:33, foice wrote: > >> On Thu, 10 Feb 2005 07:57:23 +0000 (UTC), "Jens-Peer Kuska" >> <kuska at informatik.uni-leipzig.de> wrote: >> >>> Sqrt[x + y] /. a_ + x :> x*(a/x + 1) >> Thanks for your help. Probably is a viable method, but is a little >> less than you expect >> for a WorldWideFamous software as Mathematica. >> In this way you can chose the form of the output, you can also do >> mistaques typing >> something like >> Sqrt[x^3 + y^2] /. a_ + x :> x^3*(a/x + 1) >> and mathematica will not prevent you from the error giving an output >> in the form >> Sqrt[x^3*(y^2/x+1)] >> >> Is mathematica so feature poor to allow only a "requested form" >> factorization? >> I can't belive it. >> Why there isn't somethig as Collect but that can use also negatieve >> powers to collect? >> >> i.e. Collect[x+y,x,Blind] giving x(1+y/x) >> >> Or better, at least for my task, a Mathematica command converting a >> function f(x,y) into a >> function f(x,y/x) (if possible) >> >> Thanks >> > Such a function does not exist because there are infinitely many > similar "factorizations" that might be useful to some users but not to > 99% of others. Besides, it is easy to define it yourself: > > CollectBlind[expr_, {x_, y_}] := Block[{ > u}, MapAll[Factor, (expr /. y -> u x)] /. u -> y/x] > > > Then > > > CollectBlind[x + y, {x, y}] > > > x*(y/x + 1) > > and also, for example, > > > CollectBlind[x^2 + y, {x, y}] > > > x*(x + y/x) > > > CollectBlind[x^2 + y, {x^2, y}] > > > x^2*(y/x^2 + 1) > > > > Andrzej Kozlowski > Chiba, Japan > http://www.akikoz.net/~andrzej/ > http://www.mimuw.edu.pl/~akoz/ > > > I just noticed that my definition of CollectBlind does not work properly in the case Sqrt[x^3+y]. The reason and the fix are possibly interesting. The definition I gave above was: CollectBlind[expr_, {x_, y_}] := Block[{ u}, MapAll[Factor, (expr /. y -> u x)] /. u -> y/x] This will work fine in cases like: CollectBlind[Sin[x^3 + y], {x^3, y}] Sin[x^3*(y/x^3 + 1)] CollectBlind[f[x^3 + y], {x^3, y}] f[x^3*(y/x^3 + 1)] But not for: CollectBlind[Sqrt[x^3 + y], {x^3, y}] Sqrt[x^3 + y] It actually works as an intermediate step, but the last use of Factor returns the expression to the original form: Factor[Sqrt[x^3*(y/x^3 + 1)]] Sqrt[x^3 + y] So we need to change the definition as follows: Clear[CollectBlind] CollectBlind[expr_, {x_, y_}] := Block[{ u}, Map[Factor, (expr /. y -> u x), Infinity] /. u -> y/x] Now CollectBlind[Sqrt[x^3 + y], {x^3, y}] Sqrt[x^3*(y/x^3 + 1)] Of course the name CollectBlind is terrible, I only used it because that was what the original poster wanted. Andrzej Kozlowski
- References:
- Re: how to have a blind factorization of a polinomial?
- From: foice <NONfoiceSPAMMARE@tiscalinet.it>
- Re: Re: how to have a blind factorization of a polinomial?
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: how to have a blind factorization of a polinomial?