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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.