1
$\begingroup$

I bid you a good day.

I want Mathematica to plug this assumed solution into the left hand side of a differential equation. Then collect terms of powers of $\alpha$.

$\psi (x,y)=\alpha f_1(y)e^{i x}+\alpha ^2 f_2(y)e^{2 i x}$

$u=\frac{\partial\psi} {\partial y}$

$v=-\frac{\partial\psi} {\partial x}$

The left hand side of the differential equation is: $u \frac{\partial u}{\partial x}+v \frac{\partial u}{\partial y}$

Here is my code that accomplishes this:

    ψ[{x, y}] = y +
  (α^1) (f1[y]).Exp[1*I*x] +
  (α^2) (f2[y]).Exp[2*I*x] + (α^2) (g2[y]);

u = D[ψ[{x, y}], y];

v = -D[ψ[{x, y}], x];

Collect[Distribute[u D[u, x]] + Distribute[v D[u, y]], α]

This give the result

$ \alpha f_1'(y)(ie^{i x})+\alpha^2 [f_1'(y).(ie^{i x})*f_1'(y).(e^{i x})+f_2'(y)e^{2 i x}-f_1(y)(ie^{i x})*f_1''(y).(e^{i x})]$

which is the desired result.

I would like to know if Mathematica can lexicographically scan each term and compare the $e^{m i x}$ terms? I only posted $\psi$ up to the second order so each $e^{m i x}$ terms in $\alpha^2 $ have the same order but when you calculate the third or higher orders, there will be terms that are of the form $e^{m i x}e^{n i x}$ where $m \neq n$. I want to conjugate the lower order term of $e^{m i x} and $e^{n i x}$.

For example, when calculating the third order terms, one term that arises is $f_1'(y).(ie^{i x})*f_2'(y).(2ie^{2 i x})$. I would like to Mathematica to identify that $f_1'(y).(ie^{i x})$ is the lower order term and then apply the rule

$\Re(A)\Re(B)=\Re[\frac12A(B+\bar B)]$

where $A=f_2'(y).(2ie^{2 i x})$ and $B=f_1'(y).(ie^{i x})$.

To restate the question: Can Mathematica lexicographically search an expression and compare terms in the expression?

Thank you for any assistance.

$\endgroup$

0

Your Answer

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

Browse other questions tagged or ask your own question.