In: Computer Science
In Sciland code, use the Newton Method to find the root of f(x)=10-x^2 and tol =10^-5
NOTE : AS PER THE QUESTION, Sciland CODE IS MENTIONED. HOPEFULLY IT SEEMS TO BE Scilab CODE.
HERE THE PROBLEM IS SOLVED WITH Scilab PROGRAMMING CODE.
HOPE IT WILL HELP YOU.
PROGRAM
// define newton_method to calculate root
function r= newton_method(x);
h=func(x)/derivative(x);
// as per question tolerance value is 10^-5
tol=10^-5;
while(abs(h)>=10^-5)
h=func(x)/derivative(x);
x=x-h;
end
r=x;
disp("Root is :");
disp(r);
endfunction
// define function func with actual function
function f = func(m);
// return value
f= 10-m^2;
endfunction
// define function derivative,which stores derivative of actual
function
function d = derivative(n);
// return value
d= -2*n;
endfunction
newton_method(3); //here initial value of x as x0=3 is taken
SCREEN SHOT
OUTPUT