Let we have linear combination of complex exponents with possibly complex coefficients:
N
∑
j=1
c
i
α
j
t

Under certain conditions it could be reduced to a linear combination of Sin and Cos without imaginary part.
This happens, for example, when we manually solve a linear differential equation, as in this question.
​But how to reduce exponents to a closed trigonometric form (if possible)?
Let’s try example from the question:
formExp =
c
1
- t

+
c
2
 t

+
c
3
-2  t

+
c
4
2  t

;
Obviously we try ExpToTrig:
In[]:=
complexFormTrig=ExpToTrig@formExp
Out[]=
Cos[t]
c
1
-Sin[t]
c
1
+Cos[t]
c
2
+Sin[t]
c
2
+Cos[2t]
c
3
-Sin[2t]
c
3
+Cos[2t]
c
4
+Sin[2t]
c
4
But how to convert it to trigonometric form without imaginary part?
We know that it’s possible, ‘cause formExp is solution of ODE:
In[]:=
x[t]/.First@DSolve[x''''[t]+5x''[t]+4x[t]==0,x[t],t]
Out[]=

3
Cos[t]+

1
Cos[2t]+

4
Sin[t]+

2
Sin[2t]
I tried many ways: ComplexExpand, TrigReduce etc. and created a question on this topic,
but proposed solutions are too partial or artificial. So I made some custom approach.
Firstly we need to refine trigonometric basis. We assume it contains only Sin[x_] or Cos[x_]so:
In[]:=
basis=Union@Cases[Level[complexFormTrig,{2}],Sin[x_]|Cos[x_]]
Out[]=
{Cos[t],Cos[2t],Sin[t],Sin[2t]}
Final trig form should be linear combination of basis:
In[]:=
formTrig=basis.Table
k
j
,{j,Length@basis}
Out[]=
Cos[t]
k
1
+Cos[2t]
k
2
+Sin[t]
k
3
+Sin[2t]
k
4
Coefficients in formExp may be different symbols, so let’s select them directly:
In[]:=
coeffsExp=Cases[Level[formExp,{2}],Except@Exp[x_]]
Out[]=
{
c
1
,
c
2
,
c
3
,
c
4
}
Finally we find such coeffsExp that formExp could be convert to closed trig form formTrig with real coeffs:
coeffsExpSubs=First@Solve[ForAll[Evaluate@basis,complexFormTrig==formTrig],coeffsExp]
Out[]=

c
1

1
2
(
k
1
+
k
3
),
c
2

1
2
(
k
1
-
k
3
),
c
3

1
2
(
k
2
+
k
4
),
c
4

1
2
(
k
2
-
k
4
)
And check it:
ComplexExpand[formExp/.coeffsExpSubs]==formTrig
Out[]=
True
Of course it is possible that the solution does not exist . This is taken into account in the final module.

Single module

Clear[linExpToTrig];​​linExpToTrig[linExp_]:= Module[{ce=Cases[Level[linExp,{2}],Except@Exp[x_]],​​ cft=ExpToTrig@linExp,ft,b,s},​​ ​​ b=Union@Cases[Level[cft,{2}],Sin[x_]|Cos[x_]];​​ ft=b.Table[
k
j
,{j, Length@b}];​​ s=Solve[ForAll[Evaluate@b,cft==ft],ce];​​ If[s=={},"No solution",​​ <|"TrigForm"->ft,"Coeffs"->First@s|>​​]];

Tests

In[]:=
linExpToTrig[
c
1
-t

+
c
2
t

]
Out[]=
TrigFormCos[t]
k
1
+Sin[t]
k
2
,Coeffs
c
1

1
2
(
k
1
+
k
2
),
c
2

1
2
(
k
1
-
k
2
)
linExpToTrig[aE^(-It)+bE^(It)+cE^(-2It)+dE^(2It)]
Out[]=
TrigFormCos[t]
k
1
+Cos[2t]
k
2
+Sin[t]
k
3
+Sin[2t]
k
4
,Coeffsa
1
2
(
k
1
+
k
3
),b
1
2
(
k
1
-
k
3
),c
1
2
(
k
2
+
k
4
),d
1
2
(
k
2
-
k
4
)
linExpToTrig[aE^(-2It)+bE^(It)+cE^(-3It)+dE^(2It)]
Out[]=
No solution

CITE THIS NOTEBOOK

Custom ExpToTrig Proposal​
by Denis Ivanov​
Wolfram Community, STAFF PICKS, March 5, 2024
​https://community.wolfram.com/groups/-/m/t/3135609