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

JOSE KANTOLE jkantole at gmail.com
Fri Jan 14 08:48:56 CET 2011


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);
>
>



More information about the users mailing list