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

1 回表示 (過去 30 日間)
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?

採用された回答

Star Strider
Star Strider 2014 年 6 月 9 日
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.
  4 件のコメント
David H
David H 2014 年 6 月 10 日
編集済み: David H 2014 年 6 月 11 日
Currently the only way I can really see to do this after the rewrite to then apply "expand". This is products of exponentials
(A*C*exp(-a*t*i)*exp(-c*t*i))/4 + (A*C*exp(-a*t*i)*exp(c*t*i))/4 + (A*C*exp(a*t*i)*exp(-c*t*i))/4 + (A*C*exp(a*t*i)*exp(c*t*i))/4 + (A*D*exp(-a*t*i)*exp(-c*t*i)*i)/4 - (A*D*exp(-a*t*i)*exp(c*t*i)*i)/4 +...
I suppose now I would need a string search to identify exponential products and combine them into a single exponential, running this recursively until no more exponential products can be found. After this I would have to collate the coefficients on exponentials with identical exponents.
Edit: I wrote something to do this final step, regretably it is a bit of a hash but it seems to work for the examples I have tried! On the FEX (46905-express-as-exponential-series)
Star Strider
Star Strider 2014 年 6 月 10 日
編集済み: Star Strider 2014 年 6 月 11 日
It would seem so.
I also experimented with subexpr, but wasn’t sure that’s what you wanted to do, so didn’t suggest it earlier. If the constants are related in some way, subs may also help. To break them out into fractional numerators and denominators, numden could help.
Explore the options in the Formula Rearrangement and Rewriting section of the documentation. I’m not certain you can do exactly what you want, but you can probably get close. Delving into MuPad directly may also provide options the Symbolic Math Toolbox does not, at least easily.
EDIT — I’ll take a look at it!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by