[scilab-Users] Re: Re: Can u help to write the code scilab to solve the transcendantal equation by Newton Raphson?

Michaël Baudin michael.baudin at scilab.org
Fri Jan 14 15:51:51 CET 2011


Hi,

That is true. But why not using the fsolve function ?

After all, the whole purpose of Scilab is to save time by providing 
these "basic" algorithms, isn'it ?

Best regards,

Michaël Baudin

Le 14/01/2011 08:48, JOSE KANTOLE a écrit :
> Thank you for your feedback!
>
> On 1/13/11, Wojciech Artichowicz<w_artichowicz at o2.pl>  wrote:
>> Hello there,
>>
>>
>>
>> Here You have a quite general Newton-Raphson function.
>>
>> Just fill function F(x) and use the code below. :]
>>
>> good luck and best regards.
>>
>>
>>
>> function y=F(x)
>>
>>    y=your formula;
>>
>> endfunction
>>
>>
>>
>> function x1=NewtonRaphson(f,x0,Epsf,Epsx,h)
>>
>>    x1=x0;
>>
>>    if h==[] then, h=1e-10; end; //step for numerical derivative computation
>>
>>    while abs(f(x1))>Epsf | abs(x1-x0)>Epsx do //checking the condition to
>> finish iterations
>>
>>      x0=x1;
>>
>>      df=(f(x0+h)-f(x0-h))/(2.0*h); //numerical derivative (central scheme)
>>
>>      x1=x0-f(x0)/df;
>>
>>    end
>>
>> endfunction
>>
>>
>>
>>
>>
>>
>>
>> x0 = starting value,
>>
>> Epsf=0.0000000001;
>>
>> Epsx=0.00000001;
>>
>> h=0.0000000001;
>>
>> solution=NewtonRaphson(F,x0,Epsf,Epsx,h);
>>
>>


-- 
Michaël Baudin
Ingénieur de développement
michael.baudin at scilab.org
-------------------------
Consortium Scilab - Digiteo
Domaine de Voluceau - Rocquencourt
B.P. 105 - 78153 Le Chesnay Cedex
Tel. : 01 39 63 56 87 - Fax : 01 39 63 55 94





More information about the users mailing list