# Faster computation?

I have this code

f[x_, n_] := Sum[ComplexExpand@Abs[Sin[x + k]], {k, 0, n}]
Table[Minimize[{f[x, n], -Pi <= x <= Pi}, x], {n, 5}] // TableForm


It works but the computation time is so big. There is an easy modification of the code to achieve the same result faster?

• Try to remove the SetDelay. use = not := – zhk Mar 12 '17 at 17:11
• Depending on your goals, you could also omit ComplexExpand and use NMinimize instead. – Jens Mar 12 '17 at 18:33