I wanted to simplify this nasty equation, which I couldn't seem to format also properly.

$U[k_]:= 1/2 E^(-I k) (2 E^(I k)
 Cos[A] Cos[F] - (1 + E^(2 I k)) Sin[A] Sin[F] - Sqrt[
   4 E^(2 I k)
  Cos[A]^2 Cos[F]^2 + (1 + E^(2 I k))^2 Sin[A]^2 Sin[F]^2 - 
2 E^(2 I k) (2 + Cos[k] Sin[2 A] Sin[2 F])])
PowerExpand@FullSimplify[$U];(* This won't simplify anything, eventhough simplification exist just by seeing *)

Are there any other command which simplify this expression? I need to later do plotting.

    Manipulate[Plot[$U[k], {k, -\[Pi], \[Pi]}, 
  PlotLegends -> "Expressions"], {A, 
  0, \[Pi]}, {F, 0, \[Pi]}]

This is what I getting: enter image description here

I strongly apologies for the formatting of my text, but I don't know how to put it properly.

  • $\begingroup$ [$U] should be [$U[k]]. There are no obvious simplifications. From documentation for PowerExpand "PowerExpand in general disregards all issues of branches of multivalued functions, so may not preserve the numerical values of expressions." Consequently, use only when you know that operation is safe. In general, add Assumptions (constraints) or use Assuming to assist simplification. $\endgroup$
    – Bob Hanlon
    Apr 10, 2017 at 17:59

1 Answer 1


Since $U[k] is complex, in addition to assigning numeric values to A and F you must use Re, Im, Abs, or Arg to Plot.

Due to scoping issues with Manipulate, you need to define $U with three arguments or move the definition of $U into the Manipulate.

$U[k_, A_, F_] := 
  1/2 E^(-I k) (2 E^(I k) Cos[A] Cos[F] - (1 + E^(2 I k)) Sin[A] Sin[F] - 
     Sqrt[4 E^(2 I k) Cos[A]^2 Cos[F]^2 + (1 + E^(2 I k))^2 Sin[A]^2 Sin[
          F]^2 - 2 E^(2 I k) (2 + Cos[k] Sin[2 A] Sin[2 F])]);

 Plot[Evaluate[#@$U[k, A, F] & /@ {Re, Im, Abs, Arg}], {k, -Pi, Pi},
  Frame -> True, Axes -> False, 
  PlotLegends -> Placed[{"Re", "Im", "Abs", "Arg"}, {0.9, 0.2}]],
 {{A, Pi/2}, 0, Pi, Appearance -> "Labeled"},
 {{F, Pi/2}, 0, Pi, Appearance -> "Labeled"}]

enter image description here

  • $\begingroup$ Thanks a lot for this. But I am not able to reproduce it on my Mathematica 11.1. This is what I am getting. So, no plot unfortunately. $\endgroup$
    – Shamina
    Apr 11, 2017 at 7:25
  • 1
    $\begingroup$ @Shamina - the error message clearly shows that an old definition for $U is precluding the new definition from working. Start with a fresh kernel and reevaluate the code. $\endgroup$
    – Bob Hanlon
    Apr 11, 2017 at 13:58
  • $\begingroup$ I was facing some problem, so thought of clearing them. If I have say two functions(or multiple) $U1 and $U2. How to implement it? I got stuck and getting some weird plots. e.g. $U2 = -$U1 $\endgroup$
    – Shamina
    Apr 19, 2017 at 12:03
  • $\begingroup$ @Shamina - Post a question (including your data and code for a minimal working example) and explain what you are trying to do and what you expect as output. $\endgroup$
    – Bob Hanlon
    Apr 19, 2017 at 14:57
  • $\begingroup$ Should I post a new question or editing this one will work? $\endgroup$
    – Shamina
    Apr 19, 2017 at 15:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.