I generally try to find real and imaginary parts of long expressions such as in the following example. But it takes too long time.
a) How can we speed up it? (and it includes terms such as Abs[U[\[Eta]]]^(4 n)
where n
is a positive real number.)
b) How can we automatize the assumptions by assuming the U[\[Eta]]
and its derivatives are real numbers?
expr = (Subscript[c, 4]*U[\[Eta]] + Subscript[c, 3]*U[\[Eta]]*(U[\[Eta]]^2)^(n/2) + (U[\[Eta]]^2)^n*(Subscript[c, 2]*U[\[Eta]] + Subscript[c, 1]*U[\[Eta]]*(U[\[Eta]]^2)^(n/2) +
(U[\[Eta]]^2)^n*(U[\[Eta]]*(\[Gamma] - \[Omega] + \[Kappa]*((-\[Kappa])*Subscript[\[Alpha], 1]) + Subscript[\[Mu], 1]*(U[\[Eta]]^2)^(n/2) +
(U[\[Eta]]^2)^n*(Subscript[\[Mu], 3]*(U[\[Eta]]^2)^(n/2) + Subscript[\[Mu], 4]*(U[\[Eta]]^2)^n)) - I*(v + 3*\[Kappa]^2*Subscript[\[Beta], 2])*Derivative[1][U][\[Eta]] +
Subscript[\[Alpha], 1]*Derivative[2][U][\[Eta]] - 6*\[Kappa]^2*Derivative[2][U][\[Eta]] + 3*\[Kappa]*Subscript[\[Beta], 2]*Derivative[2][U][\[Eta]] -
4*I*\[Kappa]*Derivative[3][U][\[Eta]] + I*Subscript[\[Beta], 2]*Derivative[3][U][\[Eta]] + Subscript[\[Alpha], 2]*Derivative[6][U][\[Eta]])))/(U[\[Eta]]^2)^(2*n);
realpart = FullSimplify[ComplexExpand[Re[expr]], {Element[U[\[Eta]], Reals], Element[Derivative[1][U][\[Eta]], Reals], Element[Derivative[2][U][\[Eta]], Reals],
Element[Derivative[3][U][\[Eta]], Reals], Element[Derivative[4][U][\[Eta]], Reals], Element[Derivative[6][U][\[Eta]], Reals]}]
imagpart= FullSimplify[ComplexExpand[Im[expr]], {Element[U[\[Eta]], Reals], Element[Derivative[1][U][\[Eta]], Reals], Element[Derivative[2][U][\[Eta]], Reals],
Element[Derivative[3][U][\[Eta]], Reals], Element[Derivative[4][U][\[Eta]], Reals], Element[Derivative[6][U][\[Eta]], Reals]}]
Simplify
rather thanFullSimplify
. The simplification is helped if you can tell it something aboutn
, e.g., integer? nonnegative integer? positive integer? The derivatives can be covered byElement[Derivative[_][U][\[Eta]], Reals]
$\endgroup$n
is a positive real number. $\endgroup$