Using Nminimize and simulated annealing, I have been trying to numerically minimize the function:

$\qquad f(\theta,\,\phi) = {\mathsf{Abs}[\mathsf{Cos}\,{\theta/2}]^4 + e^{-2 \mathsf{Re}[I \phi]} \mathsf{Abs}[\mathsf{Cos}\,{\theta/2}]^2 \mathsf{Abs}[\mathsf{Sin}\,{\theta/2]}^2}$

where, $(0\le\theta\le\pi)$, $(0\le\phi\le2\pi)$.

Although the function returns a real value (I also declared $\theta$, $\phi$ as real), Mathematica produces the message

objective function should be scalar valued.

It would be very helpful if someone can point out what went wrong here.

  • 3
    $\begingroup$ Please, post the code you are using. $\endgroup$ – Sektor Jun 3 '17 at 10:30
  • 1
    $\begingroup$ Isn't $Re[I \phi]=0$ if $\phi$ is real...? Or is $I$ not the imaginary unit. $\endgroup$ – Marius Ladegård Meyer Jun 3 '17 at 11:10
  • $\begingroup$ $NMinimize[f({\theta},{\phi}),{0<= \theta <= \pi},{0<=\phi<= 2\pi},{\theta,\phi}]$. yes, "I" is imaginary. $\endgroup$ – sri Jun 3 '17 at 15:34
  • $\begingroup$ People here generally like users to post code as Mathematica code instead of images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful. You can edit your question to update it with the code. $\endgroup$ – Michael E2 Jun 3 '17 at 16:50
  • $\begingroup$ Isn't the minimum obviously 0? (Consider Cos[t/2] == 0 & f[...] >=0 .) $\endgroup$ – Michael E2 Jun 3 '17 at 16:56

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.