Re: [Scilab-users] 'fsolver'
The feature of my f(x) defined for x>0 is as follows. f(x)<0 for x0 for x1=x2 'fsolver' gives some x such as x>x2 as a solution. I want to get x1 as a solution. -- View this message in context: http://mailinglists.scilab.org/fsolver-tp4033340p4033345.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] 'fsolver'
Le 27/01/2016 16:54, fujimoto2005 a écrit : The feature of my f(x) defined for x>0 is as follows. f(x)<0 for x0 for x1=x2 'fsolver' gives some x such as x>x2 as a solution. I want to get x1 as a solution. -- View this message in context: http://mailinglists.scilab.org/fsolver-tp4033340p4033345.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users A quick and dirty way of finding the minimum norm solution is to use lsqrsolve and to penalize the residual with the squared norm of the solution, like in this example (find one of the two closest to zero solution of cos(x)=0) : function res=f1(x) res=cos(x) endfunction function res=f2(x, m) res=[f1(x) %eps^(1/4)*x] endfunction format(20) [x1,v,info]=fsolve(0,f1) disp(x1) [x2,v,info]=lsqrsolve(0,f2,2) [x1,v,info]=fsolve(x2,f1) disp(x1) But the main problem is the tuning of the penalization parameter. But when it works well, you can then start from x2, hoping that you are in the basin of attraction of your solution. S. -- Département de Génie Informatique EA 4297 Transformations Intégrées de la Matière Renouvelable Université de Technologie de Compiègne - CS 60319 60203 Compiègne cedex ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] 'fsolver'
May be you can use optim instead of fsolve using f(x)^2+alpha*norm(x)^2 as cost function with alpha small enough If you cannot compute the gradient of the cost function you can use the numderivative function to estimate it. Serge Le 27/01/2016 16:54, fujimoto2005 a écrit : The feature of my f(x) defined for x>0 is as follows. f(x)<0 for x0 for x1=x2 'fsolver' gives some x such as x>x2 as a solution. I want to get x1 as a solution. -- View this message in context: http://mailinglists.scilab.org/fsolver-tp4033340p4033345.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] 'fsolver'
Hi, Christophe I give a very small value as an initial point because it is known as the character of my actual problem that this small value is necessarily smaller than the smallest solution. But 'fsolver' gives the largest solution which is most apart from the initial point. Best regards. -- View this message in context: http://mailinglists.scilab.org/fsolver-tp4033340p4033343.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] optim
Hi,mottelet Now I understand I don't need to provide the value of 'Ind '. As explained in the help page, 'the ind input argument is a message sent from the solver to the cost function ' . Also I understand I have to provide the gradient explicitly even if I don't need its value. Unless an user does't provide the gradient explicitly, the solver must estimate it numerically even if there is an analytical form of the gradient. In general numerical estimation is time-consuming compared with the the analytical form. So solver asks a user to provide the gradient explicitly to avoid time-consuming estimation. Best regards -- View this message in context: http://mailinglists.scilab.org/optim-tp4033329p409.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
[Scilab-users] 'fsolver'
if f(x)=0 has multiple solutions and I want to get the smallest solution, is there any way to get a such solution by 'fsolver'? In my actual problem, 'fsolver' give the largest solution. Best regards -- View this message in context: http://mailinglists.scilab.org/fsolver-tp4033340.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] 'fsolver'
Hello, > De : fujimoto2005 > Envoyé : mercredi 27 janvier 2016 15:24 > > if f(x)=0 has multiple solutions and I want to get the smallest solution, is > there any way to get a such solution by 'fsolver'? > In my actual problem, 'fsolver' give the largest solution. I'm afraid the solution you get depends on the initial guest. The help page says it uses the Powell hybrid method; I don't know it, but the Wikipedia page for the Powell method tells it finds a *local* minimum https://en.wikipedia.org/wiki/Powell%27s_method So you probably have to seed with several initial guests (randomly or systematically) and select the smallest one (unless you have another method to get closer to the final solution). HTH -- Christophe Dang Ngoc Chan Mechanical calculation engineer This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] 'fsolver'
Of course, read "guess" instead of "guest" (-: -- Christophe Dang Ngoc Chan Mechanical calculation engineer -Message d'origine- De : Dang Ngoc Chan, Christophe Envoyé : mercredi 27 janvier 2016 16:00 À : 'Users mailing list for Scilab'Objet : RE: [Scilab-users] 'fsolver' Hello, > De : fujimoto2005 > Envoyé : mercredi 27 janvier 2016 15:24 > > if f(x)=0 has multiple solutions and I want to get the smallest solution, is > there any way to get a such solution by 'fsolver'? > In my actual problem, 'fsolver' give the largest solution. I'm afraid the solution you get depends on the initial guest. The help page says it uses the Powell hybrid method; I don't know it, but the Wikipedia page for the Powell method tells it finds a *local* minimum https://en.wikipedia.org/wiki/Powell%27s_method So you probably have to seed with several initial guests (randomly or systematically) and select the smallest one (unless you have another method to get closer to the final solution). HTH -- Christophe Dang Ngoc Chan Mechanical calculation engineer This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users