Message Boards Message Boards


Factor out known multipliers in algebraic expressions?

Posted 2 years ago
6 Replies
4 Total Likes

Hi there,

I have this function of a[t], and it's a long function of other variables in time and some constant parameter (Ixx, Iyy, Izz), which I really want to explicit in a somatory of any combination of those constant parameters. I've tried to Simplify and then Apart, but Mathematica doesn't group similar coefficients. I wonder if I could get this result applying some kind of mapping (...)?

Well, below is the function a[t]:

a[t_] := -((Cos[ϕ[t]]*
        Izz[t]*(Ty[t] - 
           Derivative[1][ψ][t] + 
          Cos[ϕ[t]]*(-Ixx[t] + Izz[t])*
                    (Sin[ψ[t]]*Derivative[1][θ][t] + 
              Tan[ϕ[t]]*Derivative[1][θ][t] + 
             Derivative[1][ψ][t]) + 

              Derivative[1][ϕ][t] + 
              Derivative[1][ψ][t])) - 

       Iyy[t]*Sin[ϕ[t]]*(Tz[t] + 
            t] + (Ixx[t] - 
             Iyy[t])*(Sin[ψ[t]]*Derivative[1][θ][t] + 
              Derivative[1][θ][t] + 
             Sin[ϕ[t]]*Derivative[1][ψ][t]) + 
              Derivative[1][ϕ][t] - 

        Cos[ψ[t]]*Iyy[t]*Izz[t] - 

Summarizing, what I want is a way to say : rewrite a[t] factorizing in a sum by these terms (Ixx, Iyy, Izz) on any combination between them. ( In other way, I could ask the same by rewriting a[t] factorizing in terms that don't vary in time? Would this be possible/easier? )

Can anybody suggest a good thing to try?


6 Replies

I am not quite sure what you want to do, but first of all in a [ t ] your "constant parameter (Ixx, Iyy, Izz)" are functions of t as well.

So I remove this

num = Numerator[a[t]] /. {Ixx[t] -> Ixx, Iyy[t] -> Iyy,  Izz[t] -> Izz} // Expand
den = Denominator[a[t]] /. {Ixx[t] -> Ixx, Iyy[t] -> Iyy,  Izz[t] -> Izz} // FullSimplify

and Collect terms

num1 = Collect[num, {Ixx, Iyy, Izz, Ixx Iyy, Ixx Izz, Iyy Izz}]

Check it

(a[t] - num1/den /. {Ixx[t] -> Ixx, Iyy[t] -> Iyy,     Izz[t] -> Izz}) // Simplify

You may well replace Ixx for Ixx [ t ] ans so on in num1 / den again....

Hope this helps.

Posted 2 years ago

Thanks for the help. Check the new file that I've uploaded below.

Posted 2 years ago

Thanks for the help! You are right, sorry for the mistake, Ixx[t] is Ixx; e this also aplies to Iyy and Izz.

However, I've tried to use it and still isn't what I want as an answer.

To put in other example,...

Let's say that I have this expression:

y = A*Cos [\[Theta]] + (B/A)*Sin[\[Theta]] + (B*A)*x + 
  A*Tan[x] + (B/A)*x^2

And, what I want to know is how to rewrite it like this, using Mathematica methods:

y = A*(Cos [\[Theta]]+Tan[x]) + (B/A)*(Sin[\[Theta]]+x^2) + (B*A)*x

Because I want "y" as a sum of the constant terms {A,B} in any combination between them, but also multiplying a function that do not include them, like above.

For example, this format o y, applying Apart for "B"

Apart[ y , {B}]

Results in:

{(B (A^2 x + x^2 + Sin[\[Theta]]))/A + A (Cos[\[Theta]] + Tan[x])}

Which doesn't help, because the first polynomial term contains "A", that I want only as a coefficient.

Thanks again for the help.


hmmm - ok. perhaps you should disguise the mixed terms. Seems that this

Collect[y /. {A B -> ab, A/B -> adb, B/A -> bda}, {A, B, ab, adb,bda}] /. {ab -> A B, adb -> A/B, bda -> B/A}

works in your simple example, but for sure it will get tedious in more complicated cases.

And what is wrong with the method I mentioned first? This gives num1 as a polynomial in Ixx, Ixx^2, Ixx * Iyy and so on with coefficients as functions depending only of t. Same for the denominator and then you can write your a [ t ] in the form you want.

Another method, perhaps easier to be made more general is: Find the "variables" - meaning the expressions not being dependet of A or B

vv = Complement[Variables[y], {A, B}]

Now find the coefficients of these variables

cc = Coefficient[y, #] & /@ vv

and then find the factors of these

Collect[y, cc]
Posted 2 years ago

Thank you!

This idea worked pretty neat! Precisely what I intended to obtain as an answer form of the equation. Very easy to understand.

Now I will try to apply those methods into a[t]. Because I need to simplify redundant functions for applying linear solving methods (non singular matrix).

I'm grateful! Thanks again.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract