<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><P>Thanks Eric,</P>
<P> </P>
<P>But what do you mean defining x0 inside vs outside?  The func_for_fsolve function is declaired as </P>
<P>      function [y] = func_for_fsolve ( x0 )<BR>and the caller provides the x0 as an vector into it...  </P>
<P>      [x_result,v,info]=fsolve([ret_age, mu_tree, delta_t, sigma_b],func_for_fsolve);</P>
<P> </P>
<P>Should be okay right?</P>
<P> </P>
<P>Also, are you able to run the simplified test_fsolve.sci and test_fsolve_caller.sce?  Do they work for you?  Or are you also getting error 98?</P>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><A href="http://www.imagingspot.com/scilab/test_fsolve.sci.txt" target=_blank rel=nofollow><SPAN class=yshortcuts id=lw_1205453746_0><FONT color=#810081>http://www.imagingspot.com/scilab/test_fsolve.sci.txt</FONT></SPAN></A></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><A href="http://www.imagingspot.com/scilab/test_fsolve_caller.sce.txt" target=_blank rel=nofollow><SPAN class=yshortcuts id=lw_1205453746_1><FONT color=#810081>http://www.imagingspot.com/scilab/test_fsolve_caller.sce.txt</FONT></SPAN></A></DIV>
<P> </P>
<P>Jerry</P>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><BR><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">----- Original Message ----<BR>From: Eric Dubois <grocer.toolbox@gmail.com><BR>To: users@lists.scilab.org<BR>Sent: Thursday, March 13, 2008 2:16:49 PM<BR>Subject: Re: [scilab-Users] Solving multi-variable function<BR><BR>I cannot run your function because you do not provide the function ABSPredictor. But, if your function <SPAN class=q>func_for_fsolve.sci </SPAN>is exactly what is on your website, there are some oddities. In particular, you should not define x0 inside the function to maximise, but outside. <BR><BR>Eric.<BR><BR>
<DIV><SPAN class=gmail_quote>2008/3/13, Jerry Wang <<A href="mailto:jerrwang@yahoo.com" target=_blank rel=nofollow ymailto="mailto:jerrwang@yahoo.com">jerrwang@yahoo.com</A>>:</SPAN>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<P>Oh, sorry, somehow the website doesn't like the .sci extension.  Please see it here:</P>
<P><U><FONT color=#996699><A href="http://www.imagingspot.com/scilab/func_for_fsolve.txt" target=_blank rel=nofollow>http://www.imagingspot.com/scilab/func_for_fsolve.txt</A></FONT></U><A href="http://www.imagingspot.com/scilab/" target=_blank rel=nofollow></A></P>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">Yes, I provided initial values to the 4 variables.  The "caller" function has:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">chdir('C:\MyScilab');<BR>getf('ABSPredictor.sci')<SPAN class=q><BR>getf('func_for_fsolve.sci');<BR></SPAN>tic();<BR>ret_age=60;<BR>mu_tree=36000;<BR>delta_t=0.85;<BR>sigma_b=0.50;<SPAN class=q><BR>[x_result,v,info]=fsolve([ret_age, mu_tree, delta_t, sigma_b],func_for_fsolve);<BR></SPAN>time_length=toc()<BR>beep();  <BR> <BR></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">When debugging, the func_for_fsolve does fine for the first iteration.  Then it gives that error at the end of the first iteration.</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV><SPAN class=sg>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">Jerry</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR> </DIV></SPAN>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><SPAN class=q>----- Original Message ----<BR>From: Eric Dubois <<A href="mailto:grocer.toolbox@gmail.com" target=_blank rel=nofollow ymailto="mailto:grocer.toolbox@gmail.com">grocer.toolbox@gmail.com</A>><BR>To: <A href="mailto:users@lists.scilab.org" target=_blank rel=nofollow ymailto="mailto:users@lists.scilab.org">users@lists.scilab.org</A><BR></SPAN>
<DIV><SPAN class=e id=q_118a9bdaa6db77ae_8>Sent: Thursday, March 13, 2008 12:46:42 PM<BR>Subject: Re: [scilab-Users] Solving multi-variable function<BR><BR>Unfortunately, the function is not available at the provided address...<BR><BR>Did you provide values to ret_age, mu_tree, delta_t, sigma_b, in order to  feed the optimization program?<BR><BR>Eric.<BR><BR><BR>
<DIV><SPAN class=gmail_quote>2008/3/13, Jerry Wang <<A href="mailto:jerrwang@yahoo.com" target=_blank rel=nofollow ymailto="mailto:jerrwang@yahoo.com">jerrwang@yahoo.com</A>>:</SPAN> 
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">I did attempt to collapse the 4 variables into a single vector array but I received an error after fsolve reaches the end of the first iteration.  The error is:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">!--error 98<BR> variable returned by scilab argument function is incorrect</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>I add the function into the scope via:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">    getf('func_for_fsolve.sci');</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>I call the function via:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>    [x_result,v,info]=fsolve([ret_age, mu_tree, delta_t, sigma_b],func_for_fsolve);</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>Inside func_for_solve I have:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>function [y] = func_for_fsolve ( x0 )<BR>...</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">ret_age = round(x0(1));<BR>mu_tree = x0(2);<BR>delta_t = x0(3);<BR>sigma_b = x0(4);</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">...</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">[statistical_sustainable] = ABSPredictor(mc,now_age,ret_age,mu_tree,delta_t,sigma_b);</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">...</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">y = abs(statistical_sustainable(index)./100 - 0.90);</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">...</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">y = y + penalties;</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">disp('testing123');<BR>disp('testing234');</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">endfunction</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR>--------------------------------------</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">--------------------------------------</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR>I tried testing the code by reducing the supplied argument x0 into 1 scalar variable instead of the 4 scalar vector, and the function call worked.  That's why I went ahead and assumed that fsolve takes only one variables.  Can you see what I am doing wrong that's causing me to receive:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">!--error 98<BR> variable returned by scilab argument function is incorrect</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">Thank you!</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">Jerry</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">ps. the complete func_for_fsolve.sci is uploaded here for your viewing:</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><A href="http://www.imagingspot.com/scilab/func_for_fsolve.sci" target=_blank rel=nofollow>http://www.imagingspot.com/scilab/func_for_fsolve.sci</A></DIV>
<DIV><SPAN>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR> </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">----- Original Message ----<BR>From: Eric Dubois <<A href="mailto:grocer.toolbox@gmail.com" target=_blank rel=nofollow ymailto="mailto:grocer.toolbox@gmail.com">grocer.toolbox@gmail.com</A>><BR>To: <A href="mailto:users@lists.scilab.org" target=_blank rel=nofollow ymailto="mailto:users@lists.scilab.org">users@lists.scilab.org</A><BR>Sent: Thursday, March 13, 2008 5:41:21 AM<BR>Subject: Re: [scilab-Users] Solving multi-variable function<BR><BR>
<DIV>Fsolve takes one variable input, but the input can be a vector of any size.</DIV>
<DIV> </DIV>
<DIV>So, collapse your 4 variables into a single vector and adapt your fonction accordingly.</DIV>
<DIV> </DIV>
<DIV>Eric.<BR><BR> </DIV>
<DIV><SPAN class=gmail_quote>2008/3/13, Jerry Wang <<A href="mailto:jerrwang@yahoo.com" target=_blank rel=nofollow ymailto="mailto:jerrwang@yahoo.com">jerrwang@yahoo.com</A>>:</SPAN> 
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif">
<DIV>Hello Scilab-ers,</DIV>
<DIV> </DIV>
<DIV>Can any one point me to the right direction?  I want to find the zero point of a function that has 4 variables.  I want scilab to solve for the values of the 4 variables that would give me a result = 0 for the answer.  I initially tried fsolve, but I discovered that fsolve only take one variable input.</DIV>
<DIV> </DIV>
<DIV>Any thoughts?  Thanks!</DIV>
<DIV> </DIV><SPAN>
<DIV>Jerry</DIV></SPAN></DIV><BR><SPAN>
<HR SIZE=1>
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. <A href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ" target=_blank rel=nofollow>Try it now.</A></SPAN></DIV></BLOCKQUOTE></DIV><BR></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR></DIV></SPAN></DIV></DIV><SPAN><BR>
<HR SIZE=1>
Never miss a thing. <A href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs" target=_blank rel=nofollow>Make Yahoo your homepage.</A> </SPAN></DIV></BLOCKQUOTE></DIV><BR></SPAN></DIV></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR></DIV></DIV>
<DIV><SPAN class=e id=q_118a9bdaa6db77ae_10><BR>
<HR SIZE=1>
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. <A href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ" target=_blank rel=nofollow>Try it now.</A></SPAN></DIV></DIV></BLOCKQUOTE></DIV><BR></DIV><BR></DIV></div><br>
      <hr size=1>Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a></body></html>