# Collect and simplify coefficients of functions (Exp[a x])

I have a quite cumbersome expression in Mathematica and browsing through it I can identify that it could be written as

$$f(t) = A e^{a t} + B e^{b t}+ C e^{c t} ...$$

I wanted to be able to use something like Collect[f, {Exp[a t], Exp[b t], Exp[c t], ...}, Simplify], so that I could obtain the expression written as above and simplify the coefficients.

My first take would be to use a ReplaceAll and change each of these exponential to a constant {Exp[a t], Exp[b t], Exp[c t], ...}-> {X, Y, Z, ...} and then apply Collect. However, these exponentials are themselves ugly beasts, and the only way to do the replacements that I found was to go through the cumbersome expression itself and copy-paste each exponential. These worked to some extent, but not fully and is far from satisfactory.

Is there a proper way to collect for a family of functions of a given variable $$f_a(t)=e^{a t}$$ ? Or a nice implementation of inner product for exponential functions that makes the above substitution systematic?

EDIT: This turned out to be a matter o simple syntax, as pointed out by @Lukas Lang. I now clarify my original question with a minimal example and solution.

First, I meant to collect for functions (mathematical functions) and not necessarily functions in the sense of mathematima f[t_]:= ...

So, the minimal example is

f = A1*Exp[a] + A2*Expa[a] + B1*Exp[b] + B2*Exp[b]


Using

Collect[f,Exp[_]]


we get $$f = (A_1 + A_2)e^{a} + (B_1+ B_2) e^{b}$$

Finally, we use the same syntax to simplify the coefficients. For instance, let $$A_1 = \cos^2(\theta),~A_2 = \sin^2(\theta),~B_1 = 2A_1,~ B_2 = 2 A_2$$

With which we apply Simplify,

fp = f/.{A1 -> Cos[\[Theta]]^2, B1 -> 2 Cos[\[Theta]]^2,
A2 -> Sin[\[Theta]]^2, B2 -> 2 Sin[\[Theta]]^2}

Collect[fp, Exp[_], Simplify]


And obtain, $$f'= e^{a} + 2e^{b}$$

The above is a bit trivial, since one could Simplify the whole expression easily, but it works for me with a very big expression, which simply hitting Simplify would not do.

• Collect[f, {Exp[a t], Exp[b t], Exp[c t], ...} It will be better and easier to answer if you give a concrete example of your f and the output you want. i.e. example input and the output. Jan 4 at 17:16
• In many cases, Collect[..., Exp[_]] should already be enough Jan 4 at 18:47
• @LukasLang, the syntax that you suggest is exactly what I needed! Thanks. As soon as I have time I will edit my question to make it more transparent. Jan 5 at 12:58

I create some sample function:

f[x_] = Sum[
Symbol["A" <> ToString[i]] Exp[I  Symbol["a" <> ToString[i]] x], {i,4}]


If you simply want all the factors of Exp[...]:

Cases[f[x] , c_ Exp[__] -> c]


If you also want the factors in the exponentials:

Cases[f[x] , c1_ Exp[I c2__ x] -> {c1, c2}]