0
$\begingroup$

I am trying to enter a differential equation in mathematica. Example of such an equation is $$\bigg[\bigg(\frac{\partial{}}{\partial{t}}+\omega_\eta\bigg)\left(\frac{\partial{}}{\partial{t}}+\omega_\nu\right)+\omega_M^2\bigg]^2\left(\frac{\partial}{\partial{t}}+\omega_\kappa\right)\hat{u}_y=-4\omega_C^2\left(\frac{\partial{}}{\partial{t}}+\omega_\eta\right)^2\left(\frac{\partial}{\partial{t}}+\omega_\kappa\right)\hat{u}_y-\omega_A^2 \bigg[\left(\frac{\partial{}}{\partial{t}}+\omega_\nu\right)\left(\frac{\partial{}}{\partial{t}}+\omega_\eta\right)+\omega_M^2\bigg]\left(\frac{\partial{}}{\partial{t}}+\omega_\eta\right)\hat{u}_y,$$ where the unknown $\hat{u}_y$ is a function of time and space. How can it be entered into mathematica without expanding it completely on a paper and then writing the whole thing in mathematica? This is what I did

Le[f_] := \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]f\) + \[Omega]e f;
Ln[f_] := \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]f\) + \[Omega]n f;
Lk[f_] := \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]f\) + \[Omega]k f;
Lg[f_] := Le[Ln[f]] + \[Omega]M^2 f;
Lgg[f_] := Lg[Lg[Lk[f]]];
Lek[f_] := Le[Le[Lk[f]]];
Lge[f_] := Lg[Le[f]];

and then

Collect[Simplify[
  Lgg[u[t]] + 4 \[Omega]o^2 Lek[u[t]] + \[Omega]A^2 Lge[u[t]]], {
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", "5", ")"}],
Derivative],
MultilineFunction->None]\)[t], 
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", "4", ")"}],
Derivative],
MultilineFunction->None]\)[t], 
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[t], 
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", "2", ")"}],
Derivative],
MultilineFunction->None]\)[t], 
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", "1", ")"}],
Derivative],
MultilineFunction->None]\)[t], 
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", "0", ")"}],
Derivative],
MultilineFunction->None]\)[t]}]
$\endgroup$
2

1 Answer 1

1
$\begingroup$

One possibility is to first replace the derivative by a dummy (e.g. "der"). Then do the expand. And finally replace the dummy by the derivative. Here, as an example, the first line of your equation:

(((der + w1) (der + w2) + w3^2)^2 (der + w4) // Expand ) /. 
 der^(n_ : 1) -> Derivative[n][u[t]]

unfortunately, this results in an ugly unformatted expression if pasted directly. I therefore paste a picture of the formatted expression: enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.