Message Boards Message Boards

9 Replies
4 Total Likes
View groups...
Share this post:

How to factor out known multipliers in algebraic expressions in mathematica

Posted 11 years ago
Hi There,

I have some very complicated expressions in the form of F[x,y,z,A,B,C]/(x^2 - y^2 - z^2) . Here F[ ] is a very long function of x,y,z as well as some other terms, A,B,C. There are places in F where  (x^2 - y^2 - z^2) could be completely canceled out, however, no matter what algebraic manipulation I try in mathematica (Simplify,Cancel,Factor, etc), I cannot get these terms to cancel!

What I want is a way to say: rewrite F in terms of groupings of (x^2 - y^2 - z^2) wherever you can (even if it makes F look overall messier). Note I've tried "Collect" and doesn't seem to work in this sense. 

Can anybody suggest a good thing to try? I can send the expression for F in a notebook, but I warn you it's very VERY long emoticon


POSTED BY: Alissa Bans
9 Replies
We are considering this functionality, but at the moment you could use any free upload services and provide a link for large notebooks. But anyway - your paste job looks good to me ;)
POSTED BY: Vitaliy Kaurov
Alissa, even thought your expressions are large, do you think it is possible to find a compact sub-expression that illustrates the nature of the problem? 
POSTED BY: Vitaliy Kaurov
Posted 11 years ago
Like I said Simplify[ F, R==(x^2 - y^2 - z^2)] seems to mostly do the job, but here a notebook to illustrate the problem in case people have other suggestions.

Basically, I know that part of "Denom" can be factored out of "F" , the output I'm really interested in is F/Denom, but I'm aiming cancel out Denom every place I can. Does that make sense?
Again, thanks to everyone for replying! 
 F := (m r (K^2)[r] \[Sigma][r] \[CapitalSigma][
      r]^2 (bz^2 r^(2 nz) +
       c[r]^2 \[CapitalSigma][r]) (-bz^2 r^(2 nz) -
       c[r]^2 \[CapitalSigma][r] +
       r^2 \[Sigma][r]^2 \[CapitalSigma][r]) +
    2 \[CapitalOmega][
      r] (-I bz^5 b\[Theta]g r^(1 + 5 nz)
         Derivative[1][\[CapitalSigma]][r] +
       bz^3 r^(3 nz) \[CapitalSigma][
        r] (I bz^2 b\[Theta]g (1 + nz) r^(2 nz) -
         3 I b\[Theta]g r c[r]^2 Derivative[1][\[CapitalSigma]][r] +
         r^2 (2 I b\[Theta]g r + bz m r^nz) \[Sigma][r]^2 Derivative[
           1][\[CapitalSigma]][r]) -
      m r c[r] \[Sigma][r] \[CapitalSigma][
        r]^4 (2 r^3 \[Sigma][r]^3 Derivative[1][c][r] +
         r^2 c[r] \[Sigma][
           r]^2 (\[Sigma][r] + 2 \[CapitalOmega][r] +
            r Derivative[1][\[CapitalOmega]][r]) -
         c[r]^3 (3 \[Sigma][r] + 2 \[CapitalOmega][r] +
            3 r Derivative[1][\[CapitalOmega]][r])) +
      bz r^nz \[CapitalSigma][
        r]^2 (-2 I b\[Theta]g r c[r]^4 Derivative[1][\[CapitalSigma]][
           r] + c[r]^2 (I bz^2 b\[Theta]g (2 + 3 nz) r^(2 nz) +
            2 r^2 (I b\[Theta]g r + bz m r^nz) \[Sigma][
              r]^2 Derivative[1][\[CapitalSigma]][r]) +
         bz^2 r^(1 + 2 nz) \[Sigma][
           r] ((-I b\[Theta]g (-1 + 3 nz) r + 3 bz m r^nz) \[Sigma][
              r] + 2 (I b\[Theta]g r + bz m r^nz) \[CapitalOmega][r] +
             r (2 I b\[Theta]g r + 3 bz m r^nz) Derivative[
              1][\[CapitalOmega]][r])) + \[CapitalSigma][
        r]^3 (-2 I bz b\[Theta]g r^(3 + nz)
           c[r] \[Sigma][r]^2 Derivative[1][c][r] +
         c[r]^4 (I bz b\[Theta]g (1 + 2 nz) r^nz +
            m r^2 \[Sigma][r]^2 Derivative[1][\[CapitalSigma]][r]) -
         bz r^(3 + nz) \[Sigma][
           r]^3 (bz m (1 + 2 nz) r^nz \[Sigma][r] +
            2 I b\[Theta]g r \[CapitalOmega][r] +
            2 bz m r^nz \[CapitalOmega][r] +
            bz m r^(1 + nz) Derivative[1][\[CapitalOmega]][r]) +
         r c[r]^2 \[Sigma][
           r] (bz r^
             nz (-I b\[Theta]g (-1 + 2 nz) r + 6 bz m r^nz) \[Sigma][
              r] - m r^3 \[Sigma][r]^3 Derivative[1][\[CapitalSigma]][
              r] + 2 bz r^
             nz ((I b\[Theta]g r + 2 bz m r^nz) \[CapitalOmega][r] +
               r (I b\[Theta]g r + 3 bz m r^nz) Derivative[

Denom := (2 m c[r]^2 \[Sigma][r]^2 \[CapitalSigma][
    r]^3 (bz^2 r^(2 nz) + c[r]^2 \[CapitalSigma][r] -
     r^2 \[Sigma][r]^2 \[CapitalSigma][r]) \[CapitalOmega][r])

(*here the (x^2-y^2-z^2) -> (bz^2 r^(2 nz)+c[r]^2 \
\[CapitalSigma][r]-r^2 \[Sigma][r]^2 \[CapitalSigma][r]) *)

(*I am looking for a for sure way to cancel (bz^2 r^(2 nz)+c[r]^2 \
\[CapitalSigma][r]-r^2 \[Sigma][r]^2 \[CapitalSigma][r]) from parts \
of F, so I guess I want every term that doesn't have to be over that \
denomator to not be over that denomenator  *)
POSTED BY: Alissa Bans
Posted 11 years ago
Okay, also I have no idea of the best way to express mathematica notebooks in this forum, my paste job up there seems pretty messy. Can I just attach the notebook somehow?
POSTED BY: Alissa Bans
You might want to try:
Simplify[F,R==(x^2 - y^2 - z^2)]
Posted 11 years ago
Thanks! Simplify[ F, R==(x^2 - y^2 - z^2)]  helps a lot, I believe it's grouping all the factors of (x^2 - y^2 - z^2)  into 'R' which makes it very easy for me to cancel it out. 

Wow, this forum is really a great tool. Thanks everybody!
POSTED BY: Alissa Bans
By "map Factor over..." I mean something like this (which maybe is what you did):
Map[Factor, Expand[F[x,y,z,A,B,C]/(x^2 - y^2 - z^2]
This way Factor is used on each term separately.
POSTED BY: Daniel Lichtblau
You might try mapping `Factor` over the sum of terms obtained from using `Expand` on the expression.
POSTED BY: Daniel Lichtblau
Posted 11 years ago
Thanks for the suggestion. Applying 'Factor' to the 'Expand'ed form seems to just mix up the terms of F more, i.e. it sort of multiplies everything out. But I may be mistaking what you mean by mapping Factor?

Thanks either way for the reply!
POSTED BY: Alissa Bans
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract