# Finding coefficient of exponent in an expression

I am trying to find coefficient of an exponent term in an expression. For example, consider

tt = E^(I*T0*(ω+σ));

Doing

Coefficient[tt, E^(I*T0*(ω+σ))]
(* 1 *)

gives 1. However,

Coefficient[tt, E^(I*T0*ω)]
(* 0 *)

this returns 0. How do I obtain $$e^{i*T0*\sigma}$$ as output instead of $$0$$?

I thought PowerExpand will work, but it also did not. I couldn't find the command to expand exponents.

PS: The expression tt is just a dummy expression, my original expression is really big and contains a lot of terms.

• tt / E^(I*T0*ω)? – AccidentalFourierTransform Jul 6 at 20:15
• Actually the expression is really big, it contains a lot of other terms. That's why this method won't work. I'll add it in the question, thanks for the heads up – Aakash Gupta Jul 6 at 20:17
• The issue is that, from a math pov, the problem is simply ill-defined. It is meaningless to state that the coefficient of $f(t)$ in an arbitrary expression $F(t)$ is $g(t)$. You can do that, canonically, if (say) $F$ is a polynomial and $f$ a monomial (and $g$ is just a constant). But, in more general terms, the problem is not well-posed (e.g. you can always introduce factors of $1=f(t)/f(t)$ everywhere, which changes the putative $g(t)$). You will have to be much more explicit in what $F$ is, and what are your rules, if you want the problem to be solvable. Only then can MMA try to solve it. – AccidentalFourierTransform Jul 6 at 20:36

This should work for a lot of cases:

Coefficient[Expand[tt] /. E^(I*T0*(ω + x_.) + y_.) -> U * E^(I*T0*x + y), U]
(*    E^(I*T0*σ)    *)

If U happens to be a symbol that you use somewhere else in the code, then just use some different symbol here instead of U.

Updated version: Thanks to @AccidentalFourierTransform for pointing out that localizing U is required.

getcoeff[t_] := Module[{U},
Coefficient[Expand[t] /.
E^(a_.*(b_.*ω + x_.) + y_.) /; a*b == I*T0 -> U*E^(a*x + y),
U]]

This also works with cases like

getcoeff[E^(1/2*I*T0*(2ω+6))]
(*    E^(3*I*T0)    *)
• You could Block the variable U just to be sure. – AccidentalFourierTransform Jul 6 at 20:53
• Is _.a new feature in MMA12? – Ulrich Neumann Jul 7 at 12:53
• @UlrichNeumann no, Default has been around since version 1. See this tutorial. – Roman Jul 7 at 12:57