# Failure in initial objective function evaluation. FSOLVE cannot continue

36 views (last 30 days)
osatohanmwen Evbuomwan on 8 Apr 2020
Edited: darova on 9 Apr 2020
Hello, i'm trying to solve a nonlinear system of equations and I saw on the web that the function I should be looking for was "fsolve" (I am a beginner MATLAB user). I created my personal function as the following:
C=45.80;
H=5.88 ;
O=46.45 ;
N=1.20 ;
MH=1.008;
MC=12.01;
MO=16.00;
MN=14.01;
ER=0.4;
MC=0.3;
a=(H*MC)/(C*MH);
b=(O*MC)/(C*MO);
c=(N*MC)/(C*MN);
e=((24*MC)/(18*(1-MC)));
f= (ER *(1+(a/4)-(b/2)));
T=725;
lnT=log(T);
K1_m=((7082.848/T)+(-6.567*lnT)+(((7.466*10^-3)/2)*T)+(((-2.164*10^-6)/6)*(T^2))+((0.701*10^5)/(2*(T^2)))+32.541);
K2_wgs=((5870.53/T)+(1.86*lnT)+((-2.7*10^-4)*T)+(-58200/T^2)+(-18.007));
Heres the function am trying to solve
function F = root(x)
F(1) = ((x(3)^2)*k1_m) + x(1) + x(2) - 1;
F(2) = (x(2)*x(3))-((e+(0.5*a)-2)* x(1)* k2_wgs)-(x(1)*x(3)*k2_wgs)+(2*(x(1)^2)*k2_wgs)+(2*(x(1)*x(2))*k2_wgs);
F(3) = (2+(2*f)+b-(0.5*a))-(3*x(1))- (4*x(2))+ (x(3)) ;
end
Then i opened anotherfile to call fsolve
fun=@root;
x0=[1 1];
x= fsolve(fun, x0)
But something is wrong with my code and i get this command box report.
Error: File: root2d.m Line: 33 Column: 14
Function with duplicate name "root2d" cannot be defined.
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in solved (line 3)
x= fsolve(fun, x0)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.

Alex Sha on 9 Apr 2020
You have three equations with three unknown parametrs, but initial start-values, you provide two only (x0=[1 1];), is this your problems?
##### 1 CommentShowHide None
osatohanmwen Evbuomwan on 9 Apr 2020
Hi Alex , i tried using x0=[1 1 1];. it executed an error. i dont know where the error is coming from thats why i need assitance to help me figure that
Attempt to execute SCRIPT root2d as a function:
/Users/Desktop/matlab script/root2d.m
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in solved (line 32)
x= fsolve(fun, x0)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.

### Categories

Find more on Support Vector Machine Regression in Help Center and File Exchange

R2018b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by