# What is the most efficient/optimal way to simplify the given function? Does the given code need more assumptions?

I have a very long function for $$\{x,b\}\in\mathbb{R}$$ and $$n=\{1,2,3,4,5,6,7,8,9,10\}$$; here, I have only mentioned a short part of that. The function is a sum of the complex exponentials (a picture is attached below).

I want to simplify such a function in the shortest and simplest form possible; I am somehow sure that there should be a multiplicative factor $$i$$ in the whole function.

My question

What is the most efficient/optimal way to simplify the given function? Does the code  exp // ExpandAll // ExpToTrig // TrigExpand // TrigFactor // Simplify[#, Assumptions -> x > 0 && x \[Element] Reals && b \[Element] Reals && n \[Element] Integers && 0 < n < 11 ] & do the job for me? Since the function is too long, I am afraid of using FullSimplify due to timing. In particular, is the assumption $$0 < n < 11$$ sufficient (since $$n=\{1,2,3,4,5,6,7,8,9,10\}$$ only)?

exp := -462 E^( 9 I b + (2 I n \[Pi])/11 +
20 I x) (10 + E^((2 I n \[Pi])/11) + E^((14 I n \[Pi])/11) +
10 E^((16 I n \[Pi])/11) + 7 E^((18 I n \[Pi])/11)) (-1 + E^(
2 I x)) +
66 E^((2 I n \[Pi])/11 +
9 I (b + 2 x)) (-3 + 5 E^((2 I n \[Pi])/11) +
5 E^((14 I n \[Pi])/11) - 3 E^((16 I n \[Pi])/11) +
9 E^((18 I n \[Pi])/11)) (-1 + E^(6 I x)) +
55 E^(9 I b + (2 I n \[Pi])/11 +
16 I x) (7 - 3 E^((2 I n \[Pi])/11) - 3 E^((14 I n \[Pi])/11) +
7 E^((16 I n \[Pi])/11) + 31 E^((18 I n \[Pi])/11)) (-1 + E^(
10 I x)) -
E^(9 I b + (2 I n \[Pi])/11 +
14 I x) (319 - 55 E^((2 I n \[Pi])/11) +
4749 E^((4 I n \[Pi])/11) + 4749 E^((12 I n \[Pi])/11) -
55 E^((14 I n \[Pi])/11) + 319 E^((16 I n \[Pi])/11) +
1903 E^((18 I n \[Pi])/11)) (-1 + E^(14 I x)) +
E^(11 I b + (2 I n \[Pi])/11 +
12 I x) (963 + 147 E^((2 I n \[Pi])/11) -
11 E^((4 I n \[Pi])/11) - 11 E^((16 I n \[Pi])/11) +
147 E^((18 I n \[Pi])/11)) (-1 + E^(18 I x)) -
E^(9 I b + (2 I n \[Pi])/11 +
10 I x) (37 - E^((2 I n \[Pi])/11) - E^((14 I n \[Pi])/11) +
37 E^((16 I n \[Pi])/11) + 253 E^((18 I n \[Pi])/11)) (-1 + E^(
22 I x)) -
528 E^(12 I b + (13 I n \[Pi])/11 +
19 I x)  (5 Cos[(n \[Pi])/11] + Cos[(3 n \[Pi])/11]) (-1 + E^(
4 I x)) -
528 E^(10 I b + I n \[Pi] +
19 I x)  (3 Cos[(n \[Pi])/11] + 2 Cos[(3 n \[Pi])/11] +
Cos[(5 n \[Pi])/11]) (-1 + E^(16 I x)) -
E^(11 I b + (2 I n \[Pi])/11 +
14 I x) (1903 +
2 E^((10 I n \[Pi])/
11) (4749 Cos[(4 n \[Pi])/11] - 55 Cos[(6 n \[Pi])/11] +
319 Cos[(8 n \[Pi])/11])) (-1 + E^(14 I x)) • Nov 8, 2022 at 0:46
• @user293787 It is not related; I have used the code there to simplify my function, and now, I have another obstacle. Nov 8, 2022 at 0:52
• This function has period $2\pi$ in the real number $x$, period $2\pi$ in the real number $b$, and period $11$ in the integer $n$. One can write it as a Fourier series in $x$, Fourier series in $b$, discrete Fourier series in $n$, which is roughly what you have after TrigToExp. That is a natural way of writing it, because the Fourier basis is linearly independent. I guess more simplifications are possible in principle, maybe one can Factor somehow, but it would seem that such further simplifications depend on knowing all terms, not just the selection that you have given. Nov 8, 2022 at 2:26
• @user293787 Thanks. Is my assumption for $n$ correct? Since the result is different for $0$ and multiples of $11$, then, is this $0<n<11$ sufficient? Nov 8, 2022 at 12:29

Try using new variables t,u,v as follows:

e1 = TrigToExp[TrigToExp[exp] /. {n->11*Log[t]/(Pi*I)}
//ExpToTrig //Simplify] /. {x->Log[u]/I, b->Log[v]/I};
e2 = e1/(t^2*v^9*(1-u^2)*u^10) //Factor //FullSimplify;


You can check the result with the original with, for example:

N[{exp, e2*(t^2*v^9*(1-u^2)*u^10)} /.
{t->E^(Pi*I*n/11), v->E^(b*I), u->E^(x*I)} /.
{x->3/10*I, b->2/13*I, n->5/7}, 50]


The timing is not long with this approach. The test of if the result is "simpler" than the original is up to you. The e2 is a polynomial in t,u,v with integer coefficients.