I am currently trying to apply the FindMinimum function to find the lowest energy of an expression. My current expression as of now is relatively complicated. It is the summation of 48 similar terms, and after simplifying one of these terms, I get the expression

((Cot[ϕ[1]] Cot[ϕ[6]/2] - Cot[ϕ[6]] Csc[ϕ[1]] - Csc[ϕ[1]] Csc[ϕ[6]] - I 
  Cos[θ[6]] Sin[θ[1]] +  Cos[θ[1]] (Cos[θ[6]] + I Sin[θ[6]]) + 
 Sin[θ[1]] Sin[θ[6]]) (Cot[ϕ[5]] Cot[ϕ[6]/2] - Cot[ϕ[6]] Csc[ϕ[5]] - 
 Csc[ϕ[5]] Csc[ϕ[6]] + I Cos[θ[6]] Sin[θ[5]] + Cos[θ[5]] (Cos[θ[6]] - I Sin[θ[6]]) + 
 Sin[θ[5]] Sin[θ[6]]) (-Cot[ϕ[2]] Csc[ϕ[1]] + Csc[ϕ[1]] Csc[ϕ[2]] + 
 I Cos[θ[2]] Sin[θ[1]] + Cos[θ[1]] (Cos[θ[2]] - I Sin[θ[2]]) + 
 Sin[θ[1]] Sin[θ[2]] - Cot[ϕ[1]] Tan[ϕ[2]/2]) (-Cot[ϕ[3]] Csc[ϕ[2]] + Csc[ϕ[2]] Csc[ϕ[3]] + I Cos[θ[3]] Sin[θ[2]] + Cos[θ[2]] (Cos[θ[3]] - I Sin[θ[3]]) + 
 Sin[θ[2]] Sin[θ[3]] - Cot[ϕ[2]] Tan[ϕ[3]/2]) (-Cot[ϕ[4]] Csc[ϕ[
    3]] + Csc[ϕ[3]] Csc[ϕ[4]] + I Cos[θ[4]] Sin[θ[3]] + 
 Cos[θ[3]] (Cos[θ[4]] - I Sin[θ[4]]) + Sin[θ[3]] Sin[θ[4]] - 
 Cot[ϕ[3]] Tan[ϕ[4]/2]) (-Cot[ϕ[5]] Csc[ϕ[4]] + Csc[ϕ[4]] Csc[ϕ[5]] + 
 I Cos[θ[5]] Sin[θ[4]] + Cos[θ[4]] (Cos[θ[5]] - I Sin[θ[5]]) + 
 Sin[θ[4]] Sin[θ[5]] - Cot[ϕ[4]] Tan[ϕ[5]/2]))/(√((1 + 
   Abs[Cot[ϕ[6]/2] (Cos[θ[6]] - I Sin[θ[6]])]^2) (1 + 
   Abs[Cot[ϕ[6]/2] (Cos[θ[6]] + I Sin[θ[6]])]^2) (1 + 
   Abs[(-Cos[θ[1]] + I Sin[θ[1]]) Tan[ϕ[1]/2]]^2) (1 + 
   Abs[(Cos[θ[1]] + I Sin[θ[1]]) Tan[ϕ[1]/2]]^2) (1 + 
   Abs[(-Cos[θ[2]] + I Sin[θ[2]]) Tan[ϕ[2]/2]]^2) (1 + 
   Abs[(Cos[θ[2]] + I Sin[θ[2]]) Tan[ϕ[2]/2]]^2) (1 + 
   Abs[(-Cos[θ[3]] + I Sin[θ[3]]) Tan[ϕ[3]/2]]^2) (1 + 
   Abs[(Cos[θ[3]] + I Sin[θ[3]]) Tan[ϕ[3]/2]]^2) (1 + 
   Abs[(-Cos[θ[4]] + I Sin[θ[4]]) Tan[ϕ[4]/2]]^2) (1 + 
   Abs[(Cos[θ[4]] + I Sin[θ[4]]) Tan[ϕ[4]/2]]^2) (1 + 
   Abs[(-Cos[θ[5]] + I Sin[θ[5]]) Tan[ϕ[5]/2]]^2) (1 + 
   Abs[(Cos[θ[5]] + I Sin[θ[5]]) Tan[ϕ[5]/2]]^2)))

where I have included in the input code for it in Mathematica. The $\phi[i]$ and $\theta[i]$ are simply variables and the index $i$ ranges in $\{1..6\}$. I obtained an analogous version of this expression by simplifying with the assumptions that $0 \leq \phi[i] \leq 2*\pi,\quad 0 \leq \theta[i] \leq \pi$, however this took longer, and the expression didn't seem that much simpler.

My question is that since I'm trying to apply the FindMinimum function to a summation over 48 expressions, each of which are analogous to the expression above, should I bother simplifying the sum before applying the FindMinimum function to it? Are there any other things I could do to ease the expression for FindMinimum?

In addition, I know the minimum exists for the summation, and I'm trying to simultaneously find the minimum of this plus a much simpler expression. Hence, I was planning to use the built-in "goal programming" https://reference.wolfram.com/language/tutorial/ConstrainedOptimizationLocalNumerical.html with the added constraints of the intervals on the variables as mentioned above.

If it helps, I could provide the expression for the first term, before simplification to the above, purely in terms of $\theta$ and $\phi$. The above mess of trigonometric functions comes from transforming those coordinates to euclidean coordinates. As a note, one must fix values for $\theta$ and $\phi$ for one index $i$, before performing FindMinimum, so that one does not get infinite configurations of the same value.


  • 3
    $\begingroup$ It might be profitable here to use the Weierstrass substitution, so that you end up with the optimization of an algebraic function, which can be less expensive than maintaining the trigonometric formulation. $\endgroup$ Jul 31, 2015 at 19:41
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Jul 31, 2015 at 19:43
  • $\begingroup$ FullSimplify[Abs[Cot[ϕ[6]/2] (Cos[θ[6]] - I Sin[θ[6]])], θ[6] ∈ Reals] yields Abs[Cot[ϕ[6]/2]], which may be useful. $\endgroup$
    – bbgodfrey
    Aug 1, 2015 at 15:47

1 Answer 1


This expression, designated exp for convenience, can be simplified substantially as follows.

num = Map[FullSimplify[#] &, Numerator[exp]];
Map[FullSimplify[#, θ[_] ∈ Reals && ϕ[_] ∈ Reals] &, 
    Denominator[exp] /. Abs[z_]^2 :> FullSimplify[Abs[z]^2, θ[_] ∈ Reals && ϕ[_] ∈ Reals];
    /. Abs[z_]^2 :> z^2]
den = Map[FullSimplify[#, θ[_] ∈ Reals && ϕ[_] ∈ Reals] &, 
    Thread[%, Times]] /. Abs[z_^2] :> z^2;
(* Cos[ϕ[1]/2]^2 Cos[ϕ[2]/2]^2 Cos[ϕ[3]/2]^2 Cos[ϕ[4]/2]^2 Cos[ϕ[5]/2]^2 Sin[ϕ[6]/2]^2 
   (E^(-I (θ[1] - θ[6])) - Cot[ϕ[6]/2] Tan[ϕ[1]/2]) 
   (E^( I (θ[1] - θ[2])) + Tan[ϕ[1]/2] Tan[ϕ[2]/2]) 
   (E^( I (θ[2] - θ[3])) + Tan[ϕ[2]/2] Tan[ϕ[3]/2]) 
   (E^( I (θ[3] - θ[4])) + Tan[ϕ[3]/2] Tan[ϕ[4]/2]) 
   (E^( I (θ[5] - θ[6])) - Cot[ϕ[6]/2] Tan[ϕ[5]/2]) 
   (E^( I (θ[4] - θ[5])) + Tan[ϕ[4]/2] Tan[ϕ[5]/2]) *)

Still lengthy, but not nearly as much as before. Depending on the form of the other 47 expressions, it may be possible to achieve further simplifications when combining them. The Weierstrass substitution, as suggested by Guesswhoitis, will convert this expression into a polynomial, which should be easier to work with.

  • $\begingroup$ Very nice! I didn't realize that you could apply a rule to a result that is not printed to the output because of the semi-colon but I can see that it works. $\endgroup$ Aug 6, 2015 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.