Error in fsolve (line 219) fuser = feval(funf​cn{3},x,va​rargin{:})​; Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.

I wrote this m-file to solve a 57 equations system using fsolve, but from the command window when I I call the file it gives me the following:
Error in fsolve (line 219) fuser = feval(funfcn{3},x,varargin{:}); Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
Can somebody help me, please, to understand what's wrong? Thanks in advance.
Below the code
function F = sistema_non_lineare_rev1(x)
PM_acido=98.079;
PM_pet=192.171;
PM_soda=39.997;
PM_stp=210.095;
PM_pta=166.131;
PM_gla=322.192;
PM_eg=62.068;
PM_aq=18.015;
PM_solf=142.042;
F1=1000;
xi_F1=0.1000;
xpet_F1=0.9000;
ecc=0.1;
f_pri=0.98;
f_snd=0.98;
f_trz=1.00;
xpta_F16=0.9960;
xgla_F11=0.9000;
xaq_F4=1.000;
xaq_F22=1.000;
xaq_F16=0.0040;
xaq_F11=0.1000;
xeg_F25=1.000;
xsoda_F2=1.000;
xacido_F5=1.000;
xaq_F20=1.000;
xaq_F15=0.1200;
F5=x(1);
F14=x(2);
xi_F14=x(3);
F2=x(4);
F18=x(5);
F11=x(6);
F25=x(7);
xeg_F14=x(8);
F4=x(9);
F22=x(10);
F17=x(11);
F13=x(12);
xi_F13=x(13);
F3=x(14);
xi_F3=x(15);
xeg_F13=x(16);
xeg_F3=x(17);
F8=x(18);
xsoda_F8=x(19);
xi_F8=x(20);
xeg_F8=x(21);
F6=x(22);
xpet_F6=x(23);
xsoda_F6=x(24);
xi_F6=x(25);
xeg_F6=x(26);
xstp_F6=x(27);
F7=x(28);
xsoda_F7=x(29);
xaq_F7=x(30);
F9=x(31);
xaq_F9=x(32);
xstp_F7=x(33);
xstp_F9=x(34);
xpta_F9=x(35);
xsolf_F9=x(36);
F12=x(37);
xi_F12=x(38);
xi_F17=x(39);
F20=x(40);
xeg_F12=x(41);
xpet_F17=x(42);
F10=x(43);
xstp_F10=x(44);
F15=x(45);
xpta_F15=x(46);
xaq_F10=x(47);
xsolf_F10=x(48);
F26=x(49);
xstp_F26=x(50);
xaq_F26=x(51);
xgla_F26=x(52);
F21=x(53);
xaq_F21=x(54);
xstp_F21=x(55);
F19=x(56);
F16=x(57);
eq_10=F5-((PM_acido/PM_pet*xacido_F5)*F1*xpet_F1*((1+ecc)-f_pri+f_pri*f_snd));
eq_9=(0.3*F1*xi_F1)-(F14*xi_F14);
eq_11=F2-((PM_soda/xsoda_F2)*(((2*F1*xpet_F1)/PM_pet)*(f_pri+((1+ecc)-f_pri)*f_trz)));
eq_14=F18-((PM_stp/PM_pet)*F1*xpet_F1*f_pri*(1-f_snd));
eq_15=F16-((PM_pta/xpta_F16)*((F1*xpet_F1*f_pri*f_trz)/PM_pet));
eq_16=F11-((PM_gla*F1*xpet_F1)/(PM_pet*xgla_F11)*(f_pri*f_snd+((1+ecc)-f_pri)*f_trz));
eq_12=F25-(F14*xeg_F14)+((F1*xpet_F1*f_pri)/PM_pet)*PM_eg;
eq_13=(F4*xaq_F4)-(F22*xaq_F22)-(F16*xaq_F16)-(F11*xaq_F11)+(2*((F1*xpet_F1)/PM_pet)*((1+ecc)-f_pri)*f_trz)*PM_aq;
eq_17=F4-(F14+F17+F18+F22+F16+F11-F5-F2-F1-F25);
eq_7_1=xeg_F14+xi_F14-1;
eq_18=(F13*xi_F13)-(F3*xi_F3);
eq_19=(F25*xeg_F25)+(F13*xeg_F13)-(F3*xeg_F3);
eq_20=F2-(F8*xsoda_F8);
eq_21=(F3*xi_F3)-(F8*xi_F8);
eq_20_1=xi_F8+xsoda_F8+xeg_F8-1;
eq_23=(F1*xpet_F1)-(F6*xpet_F6)-(F1*xpet_F1)*f_pri;
eq_24=(F8*xsoda_F8)-(F6*xsoda_F6)-((2*F1*xpet_F1*f_pri*PM_soda)/PM_pet);
eq_25=(F8*xi_F8)+(F1*xi_F1)-(F6*xi_F6);
eq_26=(F8*xeg_F8)-(F6*xeg_F6)+((F1*xeg_F1*f_pri*PM_eg)/PM_pet);
eq_27=(-F6*xstp_F6)+((F1*xpet_F1*f_pri*PM_stp)/PM_pet);
eq_28=xpet_F6+xsoda_F6+xi_F6+xeg_F6+xstp_F6-1;
eq_30=(F7*xsoda_F7)+PM_soda*(((-2*F1*xpet_F1)/PM_pet)*((1+ecc)-f_pri)*f_trz);
eq_31=(F7*xaq_F7)-(F9*xaq_F9)+PM_aq*(((2*F1*xpet_F1)/PM_pet)*((1+ecc)-f_pri)*f_trz);
eq_32=(F7*xstp_F7)-(F9*xstp_F9)-((F1*xpet_F1*PM_stp*f_pri*f_snd)/PM_pet);
eq_33=(-F9*xpta_F9)+PM_pta*((F1*xpet_F1*f_pri*f_snd)/PM_pet);
eq_34=(-F9*xsolf_F9)+((PM_solf*F1*xpet_F1)/PM_pet)*(f_pri*f_snd+((1+ecc)-f_pri)*f_trz);
eq_35=(F6*xi_F6)-(F12*xi_F12)-(F17*xi_F17);
eq_1=(0.3*F1*xi_F1)-(F12*xi_F12);
eq_36=(F20*xaq_F20)-(F7*xaq_F7);
eq_37=(F6*xeg_F6)-(F12*xeg_F12);
eq_38=(F6*xpet_F6)-(F17*xpet_F17);
eq_39=(F6*xstp_F6)-(F7*xstp_F7);
eq_40=(F6*xsoda_F6)-(F7*xsoda_F7);
eq_43=F12-F14-F13;
eq_45=xi_F12-xi_F13;
eq_46=xi_F12-xi_F14;
eq_47=xi_F14+xeg_F14-1;
eq_48=xi_F13+xeg_F13-1;
eq_49=(F9*xstp_F9)-(F10*xstp_F10);
eq_50=(F9*xpta_F9)-(F15*xpta_F15);
eq_51=(F9*xaq_F9)-(F15*xaq_F15)+(F10*xaq_F10);
eq_52=(F9*xsolf_F9)-(F10*xsolf_F10);
eq_53=xaq_F15+xpta_F15-1;
eq_54=xsolf_F10+xaq_F10+xstp_F10-1;
eq_55=(F15*xaq_F15)-F22-(F16*xaq_F16);
eq_56=(F15*xpta_F15)-(F16*xpta_F16);
eq_57=(F10*xstp_F10)-(F26*xstp_F26);
eq_58=(F10*xaq_F10)-(F26*xaq_F26)-PM_aq*((10*F10*xsolf_F10)/PM_solf);
eq_59=(-F26*xgla_F26)+((F10*xsolf_F10*PM_gla)/PM_solf);
eq_60=(F26*xgla_F26)-(F11*xgla_F11);
eq_61=(F26*xaq_F26)-(F11*xaq_F11)-(F21*xaq_F21);
eq_62=(F26*xstp_F26)-(F21*xstp_F21);
eq_63=xaq_F21+xstp_F21-1;
eq_64=xgla_F26+xaq_F26+xstp_F26-1;
eq_65=(F21*xstp_F21)-F19;
eq_66=(F21*xaq_F21)-F18;
eq_67=F4+F19-F20;
F = [eq_10;eq_9;eq_11;eq_14;eq_15;eq_16;
eq_12;eq_13;eq_17;eq_7_1;
eq_18;eq_19;
eq_20;eq_21;eq_20_1;
eq_23;eq_24;eq_25;eq_26;eq_27;eq_28;
eq_30;eq_31;eq_32;eq_33;eq_34;
eq_35;eq_1;eq_36;eq_37;eq_38;eq_39;eq_40;
eq_43;eq_45;eq_46;eq_47;eq_48;
eq_49;eq_50;eq_51;eq_52;eq_53;eq_54;
eq_55;eq_56;
eq_57;eq_58;eq_59;
eq_60;eq_61;eq_62;eq_63;eq_64;
eq_65;eq_66;
eq_67];
end

1 Comment

Hi, Aldo, in your equation:
eq_26=(F8*xeg_F8)-(F6*xeg_F6)+((F1*xeg_F1*f_pri*PM_eg)/PM_pet);
what is "xeg_F1"?

Sign in to comment.

Answers (1)

This usually means that you didn't test your objective function to verify that it works before giving it to fsolve.

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Asked:

on 19 Jan 2021

Commented:

on 19 Jan 2021

Community Treasure Hunt

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

Start Hunting!