Uncertainty in using fsolve correctly

Hey there,
I'm trying to solve an equatation with fsolve which I have never used beforehand.
if a<=1/3
fun=@(anew) (4*anew(k)*F*(1-anew(k))-CT(k));
a0=a;
[anew(k),fval]=fsolve(fun,a0);
else
fun=@(anew1) (4*anew1*F*(1-0.25*anew1*(5-3*anew1))-CT(k));
a0=a;
[anew1,fval]=fsolve(fun,a0);
anew2=CT/(4*F*(1-0.25*anew1*(5-3*anew1)));
b=0.1;
anew(k)=b*anew2+anew1*(1-b);
anew(k)=interp1(anew(k),a0);
end
anew is so far an empty vector.
My script says that for the last loop.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
Equation solved. The sum of squared function values, r = 4.444741e-27, is less than
sqrt(options.FunctionTolerance) = 1.000000e-03. The relative norm of the gradient of r,
1.983593e-13, is less than options.OptimalityTolerance = 1.000000e-06.
Optimization Metric Options
relative norm(grad r) = 1.98e-13 OptimalityTolerance = 1e-06 (default)
r = 4.44e-27 sqrt(FunctionTolerance) = 1.0e-03 (default)
Is that something I have to be aware of? Or is that literally a statement that it has been solved?Or are these ranges showing me some errors?
Thank you in advance, cheers.

Respuestas (1)

Torsten
Torsten el 25 de Sept. de 2018
This is not an error message, but the message that "fsolve" solved your problem.
Nevertheless, you should change
if a<=1/3
fun=@(anew) (4*anew(k)*F*(1-anew(k))-CT(k));
a0=a;
[anew(k),fval]=fsolve(fun,a0);
to
if a<=1/3
fun=@(anew1) (4*anew1*F*(1-anew1)-CT(k));
a0=a;
[anew(k),fval]=fsolve(fun,a0);
Best wishes
Torsten.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Ali
el 25 de Sept. de 2018

Editada:

Ali
el 19 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by