<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"Préformaté HTML Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.PrformatHTMLCar
        {mso-style-name:"Préformaté HTML Car";
        mso-style-priority:99;
        mso-style-link:"Préformaté HTML";
        font-family:"Consolas","serif";
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:90442408;
        mso-list-type:hybrid;
        mso-list-template-ids:-1029937172 -1353948568 67895299 67895301 67895297 67895299 67895301 67895297 67895299 67895301;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>Hi Calixte,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>Your suggestion looks encouraging … I’ll have a deeper look on that specific issue  when all the aspects of my new project will be bracketed ! Many thanks …<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>And Yes:<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='color:#0070C0'><span style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>          </span></span></span><![endif]><span lang=EN-US style='color:#0070C0'>The exponents are always negative<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='color:#0070C0'><span style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>          </span></span></span><![endif]><span lang=EN-US style='color:#0070C0'>The coefficients are always positive<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>To go ahead, in one aspect of the project, only the last constant change (it won(t be the case in a second stage), I mean :<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>0.403*X^(-0.121) + 60.5*X^(-0.73) </span><span lang=EN-US style='font-family:Wingdings;color:#0070C0'>è</span><span lang=EN-US style='color:#0070C0'> always the same == constant !<o:p></o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='color:#0070C0'>– 0.1839</span></b><span lang=EN-US style='color:#0070C0'> </span><span lang=EN-US style='font-family:Wingdings;color:#0070C0'>è</span><span lang=EN-US style='color:#0070C0'> it changes … may  be either positive or negative in a first understanding<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>Imagine I’ve a matrix (n x1) where reach line is independent from the others, and where it’s necessary to solve such equation … I’ve been thinking using a loop:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>For i=1:n<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>   Solve my non-linear equation<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>End<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>(n from hundred thousand’s to million’s)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>It may be interesting to slip that loop onto several processor (solving by “blocks”), isn’t it ?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#0070C0'>Paul<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> users-bounces@lists.scilab.org [mailto:users-bounces@lists.scilab.org] <b>De la part de</b> Calixte Denizet<br><b>Envoyé :</b> lundi 5 novembre 2012 16:10<br><b>À :</b> users@lists.scilab.org<br><b>Objet :</b> Re: [Scilab-users] root calculation<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi Paul,<br><br>If the exponent are always negative and the coefficients are always positive, the function is strictly decreasing (so the derivative is non-null), you can use a Newton method.<br><br>function y=newton(fun, dfun, x0, eps)<br>    y=fun(x0)<br>    while abs(y) > eps<br>        x0 = x0 - y / dfun(x0);<br>        y = fun(x0)<br>    end<br>    y = x0;<br>endfunction<br><br>deff('y=foo(x)','y=0.403*x.^(-0.121)+60.5*x.^(-0.73)-0.1839')<br>deff('y=dfoo(x)','y=0.403*-0.121*x.^(-1.121)+60.5*-0.73*x.^(-1.73)')<br><br>To find a "good" starting point:<br>If x is a solution then 0.403*x^(-0.121)<=0.1839 and 60.5*x^(-0.73)<=0.1839, so x >=max((0.1839/0.403)^(-1/0.121), (0.1839/60.5)^(-1/0.73))<br><br>newton(foo,dfoo,2806,1e-10)<br><br>A faster way:<br>function y=newton2(coeffs, expo, cste, x0, eps)<br>    y = coeffs * (x0 .^ expo)' - cste;<br>    dcoeffs = coeffs .* expo;<br>    dexpo = expo - 1;<br>    while abs(y) > eps<br>        x0 = x0 - y / (dcoeffs * (x0 .^ dexpo)');<br>        y = coeffs * (x0 .^ expo)' - cste;<br>    end<br>    y = x0;<br>endfunction<br><br>newton2([0.403 60.5], [-0.121 -0.73],0.1839,2806,1e-10)<br><br>Calixte<br><br>On 05/11/2012 13:13, Paul Carrico wrote: <o:p></o:p></p><p class=MsoNormal><span lang=EN-US>Dear all,</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>This a stupid question, but how can I solve directly in, Scilab  an equation such as : </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>0.403*X^(-0.121) + 60.5*X^(-0.73) – 0.1839 = 0</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>?</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>Is-it necessary to code a function ? from memory : dichotomy method, secant method, Brent one etc. …</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>Regards</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>Paul</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><br><br><br><o:p></o:p></span></p><pre>_______________________________________________<o:p></o:p></pre><pre>users mailing list<o:p></o:p></pre><pre><a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><o:p></o:p></pre><pre><a href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a><o:p></o:p></pre><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><br><br><br><o:p></o:p></span></p><pre>-- <o:p></o:p></pre><pre>Calixte Denizet<o:p></o:p></pre><pre>Software Development Engineer<o:p></o:p></pre><pre>-----------------------------------------------------------<o:p></o:p></pre><pre>Scilab Enterprises<o:p></o:p></pre><pre>143bis rue Yves Le Coz - 78000 Versailles, France<o:p></o:p></pre><pre><a href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a><o:p></o:p></pre></div></body></html>