<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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:
<blockquote
cite="mid:000301cdbb4e$ffb38250$ff1a86f0$@carrico@free.fr"
type="cite">
<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:"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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
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;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></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]-->
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Dear all,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">This a stupid question,
but how can I solve directly in, Scilab an equation such as
: <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">0.403*X^(-0.121) +
60.5*X^(-0.73) – 0.1839 = 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is-it necessary to code
a function ? from memory : dichotomy method, secant method,
Brent one etc. …<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Regards<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Paul<o:p></o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Calixte Denizet
Software Development Engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
<a class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a></pre>
</body>
</html>