rorschack

QT_Prac_NewtonRaphsons_1C

Mar 1st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.31 KB | None | 0 0
  1. /*
  2. f(x)=x^4-20
  3. x0=2
  4. Ans:
  5.    2.125
  6.  
  7.    2.1148166
  8.  
  9.    2.1147425
  10.  
  11.    2.1147425
  12. */
  13.  
  14. function[] = newton_raphsons(f)
  15.     x0=input('Value of x0: ')
  16.     for i=1:4
  17.         x=x0-(f(x0)/numderivative(f,x0))
  18.         x0=x
  19.         disp(x)
  20.     end
  21. endfunction
  22.  
  23. deff('y=f(x)','y=x^4-20')
  24. newton_raphsons(f)
Add Comment
Please, Sign In to add comment