0
$\begingroup$

The use of Together either cancels the common factor from numerator and denominator or multiplies them with a common factor.

In my code I do not want that manipulation.

q1

x[t_] := X0 + X1*E^(I*\[Omega]*t) + Xn1/E^(I*\[Omega]*t)
b[t_] := bb*(E^(I*\[Omega]*t) + E^((-I)*\[Omega]*t))
eq = Numerator[
  Together[Derivative[2][x][t] + 
    c*(Derivative[1][x][t] - Derivative[1][b][t]) + k*(x[t] - b[t]) - 
         ((X1*E^(I*\[Omega]*t) + 
         Xn1/E^(I*\[Omega]*t))/(\[Alpha]1*X1*
          E^(I*\[Omega]*t) + (\[Alpha]n1*Xn1)/E^(I*\[Omega]*t)))*
     x[t]]]

This gave me the following output

output1

Manual calculation using

enter image description here

eq1 = Expand[(\[Alpha]1*X1*E^(I*\[Omega]*t) + (\[Alpha]n1*Xn1)/
       E^(I*\[Omega]*t))*(Derivative[2][x][t] + 
      c*(Derivative[1][x][t] - Derivative[1][b][t]) + 
      k*(x[t] - b[t])) - 
       (X1*E^(I*\[Omega]*t) + Xn1/E^(I*\[Omega]*t))*x[t]]

produced

output2

Clearly Together has multiplied the numerator and the denominator with a common factor of $\mathrm{e}^{2\mathrm{i}\omega t}$.

The following code can be found in this forum. (Is there a version of Together that doesn't cancel common factors?)

Combine[x_] := 
 Module[{combinet1, combinet2}, 
  combinet2 = 
   Together[
     x /. Plus -> (If[
          FreeQ[{##}, _^_?Negative] && FreeQ[{##}, Rational], 
          combinet1[##], Plus[##]] &)] /. combinet1 -> Plus]

But this has also failed to produce the intended result.

combine

eq2 = Expand[
  Numerator[
   Combine[Derivative[2][x][t] + 
     c*(Derivative[1][x][t] - Derivative[1][b][t]) + k*(x[t] - b[t]) - 
           ((X1*E^(I*\[Omega]*t) + 
          Xn1/E^(I*\[Omega]*t))/(\[Alpha]1*X1*
           E^(I*\[Omega]*t) + (\[Alpha]n1*Xn1)/E^(I*\[Omega]*t)))*
      x[t]]]]

comb_result

This time the common factor is $\mathrm{e}^{\mathrm{i}\omega t}$

Any suggestion when the result of $\frac{a}{b}+\frac{a}{b}$ can be obtained as $\frac{ab+ab}{b^2}$ without any further manipulation so that I can get $2ab$ from the numerator?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.