Way to solve these non-linear equations since fsolve isn't working fine.

function F = Glc_Gal_Lac(y,u,gal,lac)
Yx_Gal = 138000000;
KGal = 18.23;
Yx_Glc = 1010000000;
mGlc = 0.0000000000343;
fGal = 0.35;
KcGal = 5.27;
Yx_Lac = 54000000;
YLac_div_Glc = 1.56;
Lac_max1 = 21.20;
Lac_max2 = 16;
mLac = 0.000000000187;
F(1) = y(1) - (((-1*(u/Yx_Glc)) - mGlc)*((KcGal/(KcGal + gal)).^(1 - ((fGal*y(1))/y(2))))); % qGlc
F(2) = y(2) - (-1*(u/Yx_Gal)*(gal/(gal + KGal))); % qGal
F(3) = y(3) - (((u/Yx_Lac) - (YLac_div_Glc*y(2)))*((Lac_max1 - lac)/Lac_max1)) + ((mLac*(Lac_max2 - lac))/Lac_max2); % qLac
end
I believe the above function is understandable, now upon solving it what I get is
Equation solved at initial point.
fsolve completed because the vector of function values at the initial point
is near zero as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
Error using fsolve (line 300)
Objective function is returning undefined values at initial point. FSOLVE cannot continue.
AND
Equation solved. The final point is the initial point.
The sum of squared function values, r = 6.140730e-22, is less than sqrt(options.FunctionTolerance) = 1.000000e-03.
The relative norm of the gradient of r, 4.417532e-11, is less than options.OptimalityTolerance = 1.000000e-06.
Now how to make this work, I have tried changing initial points. Plotting the function is difficult since other variables inputted are linked here and there. So, any alternate way you can suggest or any editing in code will be a great help for me to make it run successfully.

4 Kommentare

Why do you disagree with FSOLVE that the algortihm was successful? And what code do you use to run fsolve?
Code used to run fsolve
yp = [0 0 0];
y = fsolve(@(y) Glc_Gal_Lac(x,u,gal,lac), yp);
qGlc = y(1);
qLac = y(2);
qGal = y(3);
I disagree here, since in my program, it ran succesfully through other non-linear equation functions prior to it but got struck here.
your anonymous function looks messed up:
@(y) Glc_Gal_Lac(x,u,gal,lac)
should probably be
@(y) Glc_Gal_Lac(y,u,gal,lac)
Anyway you have tiny numbers and enormous numbers, which could be problematic and leading to numerically too-small residuals
When the input is ignored, the output would be constant which is curvature 0. J. Alex Lee's observation is probably the solution to the problem.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Chidvi Modala
Chidvi Modala am 9 Jun. 2021
The objective function supplied to FSOLVE must return a vector without any Inf or NaN entries. In your case, it is possible that objfun(xo) returns a NaN or errors out (where "objfun" is objective function and "xo" is the initial point). To avoid this error, you need to choose a better initial point.
You may refer to documentation for FSOLVE: http://www.mathworks.com/help/optim/ug/fsolve.html
This applies to other functions as well, such as LSQNONLIN.

1 Kommentar

I used a better initial point that needed to be used but now I am struck here getting this
fsolve completed because the vector of function values at the initial point
is near zero as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
Equation solved. The final point is the initial point.
The sum of squared function values, r = 1.067653e-22, is less than sqrt(options.FunctionTolerance) = 1.000000e-03.
The relative norm of the gradient of r, 1.038534e-11, is less than options.OptimalityTolerance = 1.000000e-06.
So, I was wondering way to change the tolerance limits displayed in the above two line. So, how to go about it?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2020b

Gefragt:

am 7 Jun. 2021

Kommentiert:

am 12 Jun. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by