# FindMinimum with Manipulate

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}][], {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.

• 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][], {p, 0, 10}], {\[CapitalDelta], 10^-6, 1000, Appearance -> "Labeled"}]  Nov 3 '20 at 3:15
• 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. Nov 5 '20 at 5:06 ## 1 Answer 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}][], {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}][], {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"}] • When picking parts [] and [], 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 [] and not []. I am still a lit bit confused with it. Nov 3 '20 at 15:34
• 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 Nov 3 '20 at 15:43
• 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. Nov 5 '20 at 0:03
{"ft_lang_label":"__label__en","ft_lang_prob":0.78646624,"math_prob":0.97803986,"size":2035,"snap":"2021-43-2021-49","text_gpt3_token_len":618,"char_repetition_ratio":0.10192024,"word_repetition_ratio":0.0068259384,"special_character_ratio":0.32972974,"punctuation_ratio":0.1847575,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99593234,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-11-28T20:28:19Z\",\"WARC-Record-ID\":\"<urn:uuid:c9f881ac-58f5-401f-89d6-aac0cd956779>\",\"Content-Length\":\"146342\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b99f5b2f-eb19-45b3-96fe-3ada2f8d9cfb>\",\"WARC-Concurrent-To\":\"<urn:uuid:194eb6ed-ccbe-496f-9d23-0cf3ce944a85>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/233964/findminimum-with-manipulate\",\"WARC-Payload-Digest\":\"sha1:EJGZRGUCF52JBRBYBHOXU3VCRMQLDMUO\",\"WARC-Block-Digest\":\"sha1:LP6IIC32YQ6FPDMQKALV3KBGPFY7RL6J\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964358591.95_warc_CC-MAIN-20211128194436-20211128224436-00076.warc.gz\"}"}