1
$\begingroup$

I hope you are doing well.

If I have expressions stored in a list such as this $ \{ f_1'(y)(ie^{i x}) , f_2'(y)(2ie^{2 i x}) \}$, is there any way for Mathematica to compare the $e^{m x i}$ terms and determine which is the higher order in $x$, then return the higher ordered expression in the list? When determining which is the higher order, Mathematica should disregard the functions in front of each term.

I naively asked this question here: Limit at Infinity of Arbitrary Functions, forgetting I was working with complex exponentials. Finding the limit at infinity of the quotient of the expressions would have worked if they were normal exponentials and not complex exponentials.

Edit 1: I have an initial idea which piggy backs off my limits at infinity idea.

list = {(f_{1}'(y)*e^{i x}, f_{2}'(y)*e^{2 i x}}};
Factor1 = list[[1]];
Factor2 = list[[2]];

Factor1temp = Simplify[Factor1]./ {I*x->x}
Factor2temp = Simplify[Factor2]./ {I*x->x}

This returns

e^x f_{1}'(y)
e^{2 i x} f_{2}'(y)

The first expression the $i x$ got replaced with just $x$ but the second expression the $2 i x$ did not get changed to $2 x$. I can change the /. {I*x->x} to /. {2*I*x->x} but is there a way to tell Mathematica to ignore the integers out front and just replace the $ix$ to $x$.

Factor2temp = Simplify[Factor2]./ {2*I*x->2x}

returns

2 i e^{2 x} f_{2}'(y)

In any case now that they are no longer complex exponentials I can compare the terms by taking their limit at infinity.

Limit[Factor1temp/Factor2temp, x -> \[Infinity]]

This returns 0, therefore Factor2 is the higher ordered term. This one however,

Limit[Factor2temp/Factor1temp, x -> \[Infinity]]

returns

((i \[Infinty]) f_2 '(y))/f_1 '(y)

instead of $\infty$. Is there a way to make Mathematica output $\infty$ instead of what's given. The $f$ functions here are arbitrary but finite so the returned answer should give $\infty$.

Thank you for any help.

$\endgroup$
5
  • $\begingroup$ What is $\theta$? $\endgroup$
    – Roman
    Commented Apr 2, 2020 at 15:42
  • $\begingroup$ I apologize. I meant to say $x$ not $\theta$. $\endgroup$ Commented Apr 2, 2020 at 15:50
  • $\begingroup$ Your syntax seems a bit off. Please be careful with parentheses () and function arguments []. Which ones do you mean? $\endgroup$
    – Roman
    Commented Apr 2, 2020 at 16:03
  • $\begingroup$ This might become more comprehensible if you use Mathematica notation throughout. The mix of Mathematica and (unrendered) LaTeX is more than I can handle. Also a simple example of (Mathematica-format) input and desired output would be useful. $\endgroup$ Commented Apr 3, 2020 at 0:47
  • $\begingroup$ @Roman I will do better. $\endgroup$ Commented Apr 6, 2020 at 2:15

1 Answer 1

1
$\begingroup$

Not sure I understand correctly. Assuming that you want the largest prefactor of $x$ in the exponent,

L = {f1'[y][I E^(I x)], f2'[y][2 I E^(2 I x)]};
MaximalBy[L, # /. _[_. E^(b_. x)] -> b/I &]

(*    {Derivative[1][f2][y][2 I E^(2 I x)]}    *)

or if your definitions (which are a bit unclear) are rather

L = {f1'[y] (I E^(I x)), f2'[y] (2 I E^(2 I x))};
MaximalBy[L, # /. _. E^(b_. x) -> b/I &]

(*    {2 I E^(2 I x) Derivative[1][f2][y]}    *)

(using Default patterns)

Update

A more stable version that works even for $e^{0 i x}$ terms is to use the Exponent function:

L = Table[c[m] E^(I m x), {m, -3, 0}]
(*    {E^(-3 I x) c[-3], E^(-2 I x) c[-2], E^(-I x) c[-1], c[0]}    *)

MaximalBy[L, Exponent[#, E^(I x)] &]
(*    {c[0]}    *)
$\endgroup$
6
  • $\begingroup$ Thank you, that worked perfectly. If I may ask what you did there with the # /. _. in the 'MaximalBy[] function? I have tried looking around and from what I can decipher is that # would mean you are taking the items in the list, /. is replace, and _. is blank argument. So you are taking the item in the list and replacing the f1'[y] I E^(I x) with whatever is in front of the x by b/I and then the MaximalBy[]returns the item in the lisst which has the highest value of all these replacements. Is this correct? The only thing I couldn't decipher was what the & does at the end. $\endgroup$ Commented Apr 6, 2020 at 2:39
  • 1
    $\begingroup$ Your analysis is correct. # /. _. E^(b_. x) -> b/I & is an anonymous function and the & sign marks the end of the function. This function takes something of the form $a e^{b x}$ and replaces it by $b/i$. $\endgroup$
    – Roman
    Commented Apr 6, 2020 at 7:14
  • $\begingroup$ One more question, I actually ran into a problem when calculating terms that have E^(0 I x). In my original expression, I have terms like g2''[y] E^(0 I x) where I have to use HoldForm@ to keep the E^(0 I x) otherwise Mathematica evaluates this to 1. When comparing terms like -f1[y] I E^(I x) and g2''[y] E^(0 I x), the function MaximalBy[] returns g2''[y] E^(0 I x) and MinimalBy[] returns -f1[y] I E^(I x) where it should return the opposite. I have tried ReleaseHold[] in many places to see how it would affect the output but no luck. $\endgroup$ Commented Apr 6, 2020 at 14:22
  • $\begingroup$ I can make a separate question if you would like so you can get the credit for the answer. $\endgroup$ Commented Apr 6, 2020 at 14:24
  • 1
    $\begingroup$ @CarlosVilleda see update using Exponent. $\endgroup$
    – Roman
    Commented Apr 6, 2020 at 19:41

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.