0
$\begingroup$

I have an expression for the energy of a given physical system and I need to plot its minimum with respect to one of the parameters while the others are allowed to vary.

The expression is the following:

energy[c_,σ_,k_,Λ_,p2_,Δ_,Γ_]:=c/(2 σ^2) - (k*Λ)^2/ 2*Δ/(Δ^2 + Γ^2/4)*p2*c - π (k*Λ)^2*Δ*σ^2*p2*PolyLog[2, -(c/(2 *(Δ^2 + Γ^2/4)*π*σ^2))];

I want to plot this expression for the value of $\sigma$ (I start from a small value in FindMinimum, for instance, $10^{-6}$ in order to avoid the zero) which makes it minimum while $p$ and $\Delta$ are allowed to vary. The remaining variables have definite values. In my attempts, I have tried the following:

Manipulate[Plot[FindMinimum[energy[7*10^6, σ, 8.055*10^6, 0.0000659176, p, Δ, 1], {σ, 10^-6}][[2]], {p, 0, 10}], {Δ, 10^-6, 1000}]

When I run this last line, it gives me the manipulate plot. Nevertheless, it does return the following mistakes:

FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances

and

General: "Further output of FindMinimum::lstol will be suppressed during this calculation."

I am not sure this is the correct way to achieve what I need, so I wonder if anyone may shed some light on this problem.

Thanks in advance.

$\endgroup$
3
  • 1
    $\begingroup$ This works (i diveded function energy by 10^10 to help FindMinimum) Manipulate[ Plot[\[Sigma] /. FindMinimum[ Rationalize[ energy[7*10^6, \[Sigma], 8.055*10^6, 0.0000659176, p, \[CapitalDelta], 1], 0]/10^10, {\[Sigma], .01, 10}, MaxIterations -> 500, PrecisionGoal -> 5, WorkingPrecision -> 20][[2]], {p, 0, 10}], {\[CapitalDelta], 10^-6, 1000, Appearance -> "Labeled"}] $\endgroup$
    – Akku14
    Nov 3 '20 at 3:15
  • $\begingroup$ @Akku14 thanks! Just two additional questions. First, what is the necessity of Rationalize in your answer? Second, how to get rid of the errors related with replacement and reps being suppressed during calculation? I am getting those when running what you provided so Manipulate has not been working properly. $\endgroup$ Nov 4 '20 at 20:53
  • $\begingroup$ Your input parameters have MachinePrecision. See Precision[0.0000659176] which is $MachinePrecision about 16, depending an processor. Since i noticed that FindMinimum need higher Precision, i Rationalize the input to infinite precision. Otherwise WorkingPrecision -> 20 wouldn't work. Second, working with version 8.0, id didn't get any error messages. $\endgroup$
    – Akku14
    Nov 5 '20 at 5:06
1
$\begingroup$
Clear["Global`*"]

energy[c_, σ_, k_, Λ_, p2_, Δ_, Γ_] :=
  c/(2 σ^2) - (k*Λ)^2/2*Δ/(Δ^2 + Γ^2/4)*
    p2*c - π (k*Λ)^2*Δ*σ^2*p2*
    PolyLog[2, -(c/(2*(Δ^2 + Γ^2/4)*π*σ^2))];

Manipulate[Column@{
   Plot[FindMinimum[
      {energy[7*10^6, σ, 8055*^3, 659176*^-10, 
        p, Δ, 1], σ > 0}, {σ, 10^-6}][[1]],
    {p, 0, 10},
    WorkingPrecision -> 15,
    Frame -> True,
    FrameLabel -> (Style[#, 12, Bold] & /@
       {p, Subscript[energy, min]}),
    ImageSize -> Medium,
    ImagePadding -> {{70, 10}, {Automatic, 10}}],
   Plot[σ /. FindMinimum[
       {energy[7*10^6, σ, 8055*^3, 659176*^-10, 
         p, Δ, 1], σ > 0}, {σ, 10^-6}][[2]],
    {p, 0, 10},
    WorkingPrecision -> 15,
    Frame -> True,
    FrameLabel -> (Style[#, 12, Bold] & /@ {p, σ}),
    ImageSize -> Medium,
    ImagePadding -> {{70, 10}, {Automatic, 0}}]},
 {{Δ, 500, Style[Δ, 12, Bold]}, 10^-6, 1000, Appearance -> "Labeled"}]

enter image description here

$\endgroup$
4
  • $\begingroup$ When picking parts [[1]] and [[2]], could you please explain why it should be this way? I mean when plotting $sigma$ for the values in which the expression of the energy is minimum, you have to choose [[2]] and not [[1]]. I am still a lit bit confused with it. $\endgroup$ Nov 3 '20 at 15:34
  • $\begingroup$ Look at the output of With[{p = 5, \[CapitalDelta] = 500}, FindMinimum[{energy[7*10^6, \[Sigma], 8055*^3, 659176*^-10, p, \[CapitalDelta], 1], \[Sigma] > 0}, {\[Sigma], 10^-6}]]. The first part is the minimum energy and the second part is a rule with the value of \[Sigma] at which the minimum occurred. See documentation for FindMinimum $\endgroup$
    – Bob Hanlon
    Nov 3 '20 at 15:43
  • $\begingroup$ Oh, I got it now. Just a last remark. Whenever I try to run your code above, Mathematica always return errors, and the plot for sigma does not appear when Manipulate is running while that of energy appears but with irregular steps and errors. Is there any way to solve this this problem and get rid of errors? Errors commonly are: "{...} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing" and/or "Further output of ReplaceAll::reps will be suppressed during this calculation." $\endgroup$ Nov 4 '20 at 18:15
  • $\begingroup$ I cannot reproduce the errors that you mention. I am using v12.1.1 The errors that you report appear to indicate that FindMinimum may be returning unevaluated for you. Perhaps it is timing out. The starting value that you used (and I continued with) for σ of 10^-6 (in both FindMinimum) seems too small. Try converting both values to 1/10 and see if that helps. $\endgroup$
    – Bob Hanlon
    Nov 5 '20 at 0:03

Your Answer

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

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