MathGroup Archive 1997

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

Search the Archive

Re: Q: Collect, Coefficient, and non-integer exponents [3]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8776] Re: [mg8733] Q: Collect, Coefficient, and non-integer exponents [3]
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Thu, 25 Sep 1997 12:26:10 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

The previious code does not deal with the constant parts and fails  
with some inexact number coefficients, since 0.0 a does not reduce  
automatically to 0.
Heres is a fix.

unZip2[expr_, x_, n_:Infinity] :=
  Rest[Thread[Rest[
  	FixedPointList[
  		{Chop[Expand[#1 - #2*x^#3]], #2,
  		 x^Chop[#3 - 1 - Exponent[expr, x]]
        }&[
        	#1, Coefficient[#1, x^#2], #2
          ]&[
     	   	 #1[[1]], Exponent[#1[[1]], x]
     	   	]& ,
      	{Chop[Expand[expr x^(1 + Exponent[expr, x])]], 0, 0},
      	n,
      	SameTest -> (#2[[1]] == 0 &)
    ]
  ]]]

Examples

unZip2[ a + 1.3 b x^1.2 + 2.4 c x^3.7,x]
	
	{{2.4 c, 1.3b, a}, {x^3.7, x^1.2, 1}}

unZip2[ 1.3 b x^1.2 + 2.4 c x^3.7,x]

	{{2.4c, 1.3b}, {x^3.7, x^1.2}}

Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK


  • Prev by Date: Trouble with FindRoot
  • Next by Date: $Prefereces and Cache
  • Previous by thread: Trouble with FindRoot
  • Next by thread: $Prefereces and Cache