MATLAB: Symbolic expansions, is it possible to express a solution as a series of exponentials

collectexpandexponentialsymbolic

Lets say I have something like
f_t = (A*cos(a*t) + B*sin(b*t))*(C*cos(c*t) + D*sin(c*t)),
what I would like is something of the form
f_t = c_1 exp(k1*t) + c_2 exp(k2*t) + … + c_N exp(kN*t) .
I can't find anything within the symbolic toolbox that allows expansion in this form. I don't really want to write one either until I know for sure there isn't one included / on the FEX. Anyone that can help?

Best Answer

There is one in the Symbolic Math Toolbox: rewrite!
To wit:
syms A a t
f_t = (A*cos(a*t) + B*sin(b*t))*(C*cos(c*t) + D*sin(c*t));
f_t = rewrite(f_t, 'exp')
produces:
f_t =
(A*(exp(-a*t*i)/2 + exp(a*t*i)/2) + B*((exp(-b*t*i)*i)/2 - (exp(b*t*i)*i)/2))*(C*(exp(-c*t*i)/2 + exp(c*t*i)/2) + D*((exp(-c*t*i)*i)/2 - (exp(c*t*i)*i)/2))
You’ll have to play with it it get the result in your example. There may not be any direct way to do that.