0
$\begingroup$

I want to solve a non-linear equation derived with a forward march finite difference technique (defined as "f" in the code). I am using FindMinimum, since I know an approximate initial value for each point.

FindMinimum returns the following error:

cvecv : "Constrained optimization is only supported with scalar valued variables"

How do I resolve this error? All values are scalars.

(* Variable definition *)
zeta = w*(Sqrt[scurr*scurr + (1 + 1/w - lcurr1)^2] - 1); 
psi = psist*(zeta^(-12) - 2/zeta^6); 
K = (A/Rv^2)*Exp[-psi]; 
fact = nu0*(1 + sigma) + 1/K; 
chi = 0.5*(fact - Sqrt[fact^2 - 4*nu0*nu0*sigma]); 
y[i] = (lcurr1 - l[i - 1])/(scurr - s[i - 1]); 
c[i] = (lcurr1 - 2*l[i - 1] + l[i - 2])/(scurr - s[i - 1])^2; 
curv = Sqrt[1 + y[i]^2]; 
omega1 = 2*Pi*scurr*curv*12*psist*(1/zeta^12 - 1/zeta^6)*(1 - lcurr1 + 
1/w)*w*(w/(zeta*(zeta + w)))*chi*(1 - (psi/K)*(1/(nu0*(1 + sigma) + 1/K))); 
xi1 = 2*Pi*kb*(-y[i]^2/curv^2 + 1 - (3*scurr*y[i]*c[i])/curv^4)*(-2/\[Beta] 
+ y[i]/(scurr*curv) + c[i]/curv^3) + 
2*Pi*scurr*y[i]*((chi*psi + 0.5*kb*(-2/\[Beta] + y[i]/(scurr*curv) + c[i]/curv^3)^2)/curv); 
pai1 = 2*Pi*kb*((y[i] + y[i]^3 + scurr*c[i])/curv^5 - (2*scurr)/(\[Beta] + \[Beta]*y[i]*y[i])); 

(* Objective function definition *)
f[lcurr1] = omega1 - (xi1 - xi[i - 1])/(s[i] - s[i - 1]) + (pai1 - 2*pai[i - 1] + pai[i - 2])/(s[i] - s[i - 1])^2; 
guess = l[i - 1]; 
sol = FindMinimum[{f[lcurr1], lcurr1 >= 0, lcurr1 <= 4},{lcurr1, guess}]; 
$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE. Right now, your question lacks some definitions and the code cannot be evaluated. The good thing is, you can simply edit your question and include the missing parts. This will help others to give you advice on how to solve your problem. If you are new here, start by taking time to read the FAQ and the guidelines you find in the "Help Center" at the end of the FAQ. $\endgroup$ – halirutan Jun 28 '18 at 11:37
  • $\begingroup$ Thanks, hailrutan. I have made some changes. Does it look fine now? $\endgroup$ – modsim Jun 29 '18 at 5:34

Your Answer

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

Browse other questions tagged or ask your own question.