Why does NMinimize throw the error and how to fix it?
ClearAll["Global`*"]
eq[chi_, t_, a_, b_, gamma_, beta_] :=
a*(t - 315)*(chi)^(1/gamma) +
b*(chi)^(1/gamma + 1/beta)*1000^(1/beta) - 1;
Chi[t_, a_, b_, gamma_, beta_] :=
NSolve[eq[chi, t, a, b, gamma, beta] == 0, chi, Reals][[1, 1, 2]]
Chi[155, 0.7, 0.008, 1.6, 0.5]
(*0.12029*)
min[a_, b_, gamma_,
beta_] := (Chi[131, a, b, gamma, beta] - 62)^2
min[0.7, 0.008, 1.6, 0.5]
(*3828.06*)
NMinimize[Evaluate@min[a, b, gamma, beta], {a, b, gamma, beta}]
(*During evaluation of In[7]:=
ToBoxes[Refresh[Internal`MessageMenu["NSolve", "nsmet", 2, 7, 1, 34328787444913064695, "Local"], None], StandardForm]NSolve::nsmet: This system cannot be solved with the methods available to NSolve.*)
min[a,b,gamma,beta]
Mathematica saysNSolve::nsmet: This system cannot be solved with the methods available to NSolve.
!Mathematica graphics which is what you also show at the end. So need to solve this problem first before NMinimize can work $\endgroup$min[a,b,gamma,beta]
?NSolve
returnchi
for example in this casemin[0.7, 0.008, 1.6, 0.5]
$\endgroup$min[0.7,0.008,1.6,0.5]
andmin[a,b,gamma,beta]
are not the same? First case you are passing numerical values, in the second you are not. NDSolve sees the equation to solve as-1+1000^(1/beta) b chi^(1/beta+1/gamma)-184 a chi^(1/gamma)==0
in the second case, while in the first case it sees the equation as-1-128.8 chi^0.625+8000. chi^2.625==0
that is the difference. $\endgroup$NMinimize
substitute certain variable values into the functionmin[a,b,gamma,beta]
? $\endgroup$NMinimize
sees the input. So it is NSolve that is generating the error, notNMinimize
. $\endgroup$