Re: [Scilab-users] 'fsolver'

2016-01-28 Thread fujimoto2005
Hi, motterlet and Steer

Thanks a lot your helps.

Unfortunately 'lsqrsolve' did't give the smallest initial point for my
function.
The local minimum of f^2+a*x^2 is attained at x s.t. f(x)=-a*x.
So if a is small such x is a neighborhood of x s.t. f(x)=0.
But it is not necessarily of x which is the smallest one.
Probably my function is not well-behaved as like cos(x) so that it fail.

Now I get an awkward method.
I find the first x(i) s.t. f(x(i))>0 and f(x(i-1))<0 where x(i)=x0+i*dx and
x0 is some constant which is smaller than smallest solution of f(x)=0.
Then I modify f(x) to new function fnew(x) as
f(x)=f(x(i-1))+[f(x(i))-f(x(i-1))]/[x(i)-x(i-1)]*[x-x(i)] for x>=x(i) and
fnew(x)=f(x) for x<=x(i).
Using fsolv(x(i-1),fnew) gives the smallest solution of f(x)=0.
With your helps I could get a practical solution.
Thanks again.

Best regards.




--
View this message in context: 
http://mailinglists.scilab.org/fsolver-tp4033340p4033350.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'

2016-01-27 Thread fujimoto2005
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'

2016-01-27 Thread Stéphane Mottelet

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'

2016-01-27 Thread Serge Steer
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'

2016-01-27 Thread fujimoto2005
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


[Scilab-users] 'fsolver'

2016-01-27 Thread fujimoto2005
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'

2016-01-27 Thread Dang Ngoc Chan, Christophe
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'

2016-01-27 Thread Dang Ngoc Chan, Christophe
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' <users@lists.scilab.org>
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