Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Factoring

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65146] Re: Factoring
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Wed, 15 Mar 2006 06:30:41 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <dv6847$nq4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <dv6847$nq4$1 at smc.vnet.net>,
 "Matt" <anonmous69 at netscape.net> wrote:

> Hello Mathgroup,
>   I'm sure that I've overlooked something obvious, but for the past two
> and a half hours, I've been trying to figure out how to use built-in
> Mathematica functions to just factor the imaginary number 'I' out of
> this:
> 
> 4*I*r^2*Sin[2*θ] + I*r^5*Sin[5*θ]
> 
> using Factor[] gives me I*r^2*(4*Sin[2*θ] + r^3*Sin[5*θ])
> 
> using FactorTerms[] gives me I*(4*r^2*Sin[2*θ] + r^5*Sin[5*θ]) which
> is what I want, but as soon as I add in a common numerical factor, it
> also factors that out as well,
> 
> e.g. 4*I*r^2*Sin[2*θ] + 8*I*r^5*Sin[5*θ]

ComplexExpand does what you want:

 ComplexExpand[I Sin[5 x] r^5 + 4 I Sin[2 x] r^2]

Note that FullForm can be very useful in understanding what is required 
here. For example,

  FullForm[ 4 I ]

is _not_ Times[4, Complex[0,1]].

> As an additional example, what
> if I just wanted to extract 2*x*I out of the following:
> 
> 4*x*I*Sin[t] + 28*x^3*I*Cos[t]
> 
> how would I do that?  In general, I'm looking for a function that says
> "Given an expression 'expr' and another expression 'sub' that is common
> to all additive terms of 'expr', give a result that is the product of
> 'sub' and the result of factoring 'sub' out of 'expr'".

Well, you've described exactly the procedure for doing this. Essentially 
"divide" 'expr' by 'sub' and then back multiply:

 FactorOut[expr_, sub_, var_]:= sub PolynomialQuotient[expr, sub, var] /;
   PolynomialQ[expr, var] && PolynomialQ[sub, var]

 FactorOut[28 I Cos[t] x^3 + 4 I Sin[t] x, 2 x I, x]

Cheers,
Paul

_______________________________________________________________________
Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    
AUSTRALIA                               http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Sorting Rows of a Matrix
  • Next by Date: Re: Total Derivative and Output Display Question
  • Previous by thread: Re: Factoring
  • Next by thread: Origin Link for Mathematica