From: Nicolas on

Hi everyone, i have this code.

x0 = [10^(7.0561);10^(8.9)];

options=optimset('Display','iter','MaxFunEvals',1e9,'MaxIter',1e9,'TolFun',1e-80,'TolX',1e-80);

resul = fsolve(@(x) myfun3(x,K_e,K_mu,g14,R,nu_b,nu_s,L_npe,L_ppe,L_npm,L_ppm,Delta_nfix,wwpto),x0,options)

final_t(k)=resul(1);
final_eta(k)=resul(2);


ad myfun3 is :

function F = myfun3(x,K_e,K_mu,g14,R,nu_b,nu_s,L_npe,L_ppe,L_npm,L_ppm,Delta_n,wwpto)
%F = [2*x(1) - x(2) - exp(-x(1)); -x(1) + 2*x(2) - exp(-x(2))];



f=@(T,eta) integra_1_ac(eta,T,Delta_n,L_npe,L_ppe,L_npm,L_ppm)/(K_e*wwpto)+1;
%g=@(T,eta) integra_2(eta,T,Delta_n,L_npe,L_ppe,L_npm,L_ppm)+L_gamma*T.^(2.42)-eta*(K_e+K_mu)*wwpto;
g=@(T,eta) integra_2_ac(eta,T,Delta_n,L_npe,L_ppe,L_npm,L_ppm)./(L_gamma*T.^(2.42))+1+eta*(K_e+K_mu)*wwpto./(L_gamma*T.^(2.42));

F=[f(x(1),x(2));g(x(1),x(2))];


i'm solving this for T and eta (the another variables are constants) and integra_1_ac and 2 depends on T and eta too.

So my problem is that i cant find the solution for the system if i give to the code a very very very accurate value of the "guess solution", and the stoppin criteria says:



No solution found.

fsolve stopped because the relative size of the current step is less than the
selected value of the step size tolerance squared, but the vector of function values
is not near zero as measured by the selected value of the function tolerance.

<stopping criteria details>


resul =

1.0e+08 *

0.1301
7.9432


fsolve stopped because the relative norm of the current step, 1.445392e-16, is less than
max(options.TolX^2,eps) = 2.220446e-16. However, the sum of squared function values,
r = 5.161027e-01, exceeds sqrt(options.TolFun) = 1.000000e-40.

Optimization Metric Options
relative norm(step) = 1.45e-16 max(TolX^2,eps) = 2e-16 (selected)
r = 5.16e-01 sqrt(TolFun) = 1.0e-40 (selected)


so i was searching the method to change the eps value but i dont know what it is :(.
I know why the code stop, but i cant find the place where this "eps" option can be changed...
Can anyone help me with this please?
From: Alan Weiss on
You seem not to understand that MATLAB calculates to about 16 digit
accuracy. So there is no point to setting tolerances below eps ~ 2e-16.
If you want to know what eps means, enter
doc eps

You problem is probably badly scaled. Your initial values, on the order
of 10^7 to 10^9, indicate that you already know this. You would probably
do better to rescale and recenter your problem. For one suggestion, see
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44iv5-1.html#br53duy-1
I suspect that a nonlinear transformation would be better for your
problem, but without details, I cannot be sure.

Have you tried plotting your function in the neighborhood of your
suspected root? The poor scaling should be evident.

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation

On 7/29/2010 5:01 PM, Nicolas wrote:
>
> Hi everyone, i have this code.
>
> x0 = [10^(7.0561);10^(8.9)];
>
> options=optimset('Display','iter','MaxFunEvals',1e9,'MaxIter',1e9,'TolFun',1e-80,'TolX',1e-80);
> resul = fsolve(@(x)
> myfun3(x,K_e,K_mu,g14,R,nu_b,nu_s,L_npe,L_ppe,L_npm,L_ppm,Delta_nfix,wwpto),x0,options)
>
> final_t(k)=resul(1);
> final_eta(k)=resul(2);
>
>
> ad myfun3 is :
>
> function F =
> myfun3(x,K_e,K_mu,g14,R,nu_b,nu_s,L_npe,L_ppe,L_npm,L_ppm,Delta_n,wwpto)
> %F = [2*x(1) - x(2) - exp(-x(1)); -x(1) + 2*x(2) - exp(-x(2))];
>
>
>
> f=@(T,eta)
> integra_1_ac(eta,T,Delta_n,L_npe,L_ppe,L_npm,L_ppm)/(K_e*wwpto)+1;
> %g=@(T,eta)
> integra_2(eta,T,Delta_n,L_npe,L_ppe,L_npm,L_ppm)+L_gamma*T.^(2.42)-eta*(K_e+K_mu)*wwpto;
>
> g=@(T,eta)
> integra_2_ac(eta,T,Delta_n,L_npe,L_ppe,L_npm,L_ppm)./(L_gamma*T.^(2.42))+1+eta*(K_e+K_mu)*wwpto./(L_gamma*T.^(2.42));
>
>
> F=[f(x(1),x(2));g(x(1),x(2))];
>
>
> i'm solving this for T and eta (the another variables are constants) and
> integra_1_ac and 2 depends on T and eta too.
> So my problem is that i cant find the solution for the system if i give
> to the code a very very very accurate value of the "guess solution", and
> the stoppin criteria says:
>
>
>
> No solution found.
>
> fsolve stopped because the relative size of the current step is less
> than the
> selected value of the step size tolerance squared, but the vector of
> function values
> is not near zero as measured by the selected value of the function
> tolerance.
>
> <stopping criteria details>
>
>
> resul =
>
> 1.0e+08 *
>
> 0.1301
> 7.9432
>
>
> fsolve stopped because the relative norm of the current step,
> 1.445392e-16, is less than
> max(options.TolX^2,eps) = 2.220446e-16. However, the sum of squared
> function values,
> r = 5.161027e-01, exceeds sqrt(options.TolFun) = 1.000000e-40.
>
> Optimization Metric Options
> relative norm(step) = 1.45e-16 max(TolX^2,eps) = 2e-16 (selected)
> r = 5.16e-01 sqrt(TolFun) = 1.0e-40 (selected)
>
>
> so i was searching the method to change the eps value but i dont know
> what it is :(.
> I know why the code stop, but i cant find the place where this "eps"
> option can be changed...
> Can anyone help me with this please?