Prev: npermutek
Next: export overlapped area plots
From: Gene on 22 Apr 2010 15:40 "David_la_plata Jaume" <davidjaume(a)hotmail.com> wrote in message <hqnlt7$dko$1(a)fred.mathworks.com>... > Hi, I have a sistem of non-linear ecuations and Fsolve gives me an answer but it not satisface the 5th ecuations: -V(3)+(alfa*(1+V(7)*lambda))/(1-alfa)*(cu/V(2));. > > F= [-V(5) + (1-alfa)*((exp(mu+((sigma^2)/2)))*(normcdf((sigma-(log(V(2))-mu)/sigma),0,1))-V(2)*(1-logncdf(V(2),mu,sigma))); > -V(5) + (1-alfa)*(n*P-n*V(3)-sum(cp))*(V(2)*(1-logncdf(V(2),mu,sigma)))/V(3); > -V(4) + (V(6)/V(5))^2 + (V(7)/V(5))^2; > -V(1) + 0.05 + (1-V(4))^n * 0.05 /(((n-1)/n)^n); > -V(3)+(alfa*(1+V(7)*lambda))/(1-alfa)*(cu/V(2));]; > for j=1:n; > F(j+5)=-V(5+j) + (1-alfa)*(P-V(3)-cp(j))*(V(2)*(1-logncdf(V(2),mu,sigma)))/V(3); > end; > F(8)= -V(5)+ V(6)+V(7); > > In another m-file i define sigma, mu, P, n(2 in this case), cp. and try to use fsolve like this: > Initial= [r; sendow; pf; H; Q; q']; > Options = optimset('Display','iter'); > [XY,fval] = fsolve(@Outgrower_contracts,Initial,Options) > > but the answer is not making me 5th ecuation =0,So i tried doing this: > for j=1:100; > [XY,fval] = fsolve(@Outgrower_contracts,Initial,Options); > Initial=XY > count=j > end; > but the problem persist > > Someone can help me with this? David: I may be missing something but it seems that (for n=2) the variable V(8) does not appear in your set of residuals. I can't tell from what is supplied, but presumably 'Initial' has 8 components (else Matlab would complain about a non-square system). With V(8) missing you should get a message about a singular Jacobian. Do you ? As noted, I may be missing something but you should check your model. emc
From: David_la_plata Jaume on 22 Apr 2010 17:04 "Gene " <ecliff(a)vt.edu> wrote in message <hqq8nb$cjl$1(a)fred.mathworks.com>... > "David_la_plata Jaume" <davidjaume(a)hotmail.com> wrote in message <hqnlt7$dko$1(a)fred.mathworks.com>... > > Hi, I have a sistem of non-linear ecuations and Fsolve gives me an answer but it not satisface the 5th ecuations: -V(3)+(alfa*(1+V(7)*lambda))/(1-alfa)*(cu/V(2));. > > > > F= [-V(5) + (1-alfa)*((exp(mu+((sigma^2)/2)))*(normcdf((sigma-(log(V(2))-mu)/sigma),0,1))-V(2)*(1-logncdf(V(2),mu,sigma))); > > -V(5) + (1-alfa)*(n*P-n*V(3)-sum(cp))*(V(2)*(1-logncdf(V(2),mu,sigma)))/V(3); > > -V(4) + (V(6)/V(5))^2 + (V(7)/V(5))^2; > > -V(1) + 0.05 + (1-V(4))^n * 0.05 /(((n-1)/n)^n); > > -V(3)+(alfa*(1+V(7)*lambda))/(1-alfa)*(cu/V(2));]; > > for j=1:n; > > F(j+5)=-V(5+j) + (1-alfa)*(P-V(3)-cp(j))*(V(2)*(1-logncdf(V(2),mu,sigma)))/V(3); > > end; > > F(8)= -V(5)+ V(6)+V(7); > > > > In another m-file i define sigma, mu, P, n(2 in this case), cp. and try to use fsolve like this: > > Initial= [r; sendow; pf; H; Q; q']; > > Options = optimset('Display','iter'); > > [XY,fval] = fsolve(@Outgrower_contracts,Initial,Options) > > > > but the answer is not making me 5th ecuation =0,So i tried doing this: > > for j=1:100; > > [XY,fval] = fsolve(@Outgrower_contracts,Initial,Options); > > Initial=XY > > count=j > > end; > > but the problem persist > > > > Someone can help me with this? > > David: > > I may be missing something but it seems that (for n=2) the variable V(8) does not appear in your set of residuals. I can't tell from what is supplied, but presumably 'Initial' has 8 components (else Matlab would complain about a non-square system). With V(8) missing you should get a message about a singular Jacobian. Do you ? > > As noted, I may be missing something but you should check your model. > > emc Emc: The variable V(8) does not appear, but Initial has 7 components (q is a vector of two components). So I have 8 equations and 7 residuals, and the message es this: "Warning: Default trust-region dogleg method of FSOLVE cannot handle non-square systems; switching to Gauss-Newton method." And this give a solution that does not satisfices: -V(3)+(alfa*(1+V(7)*lambda))/(1-alfa)*(cu/V(2));] I have tried to extract the 8th ecuation becouse is not need to solve the problem (see that 2nd equation is equal to sum equations 6th and 7th), but in this way matlab takes a long time to find a solution and when is over it keep having the same problems. But the solutions are not exactly the same under the two methods. Another thing that i have noticed is this: if i change the initial values the solutions are not the same!! I dont now what to do with this problem! There have to be only one solution!. Thanks Emc!
|
Pages: 1 Prev: npermutek Next: export overlapped area plots |