Can u help to write the code scilab to solve the transcendantal equation by Newton Raphson?

Wojciech Artichowicz w_artichowicz at o2.pl
Thu Jan 13 21:48:05 CET 2011


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110113/1207d703/attachment.htm>


More information about the users mailing list