From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 149/CH24/EX24.5/ques5.sce | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 149/CH24/EX24.5/ques5.sce (limited to '149/CH24/EX24.5') diff --git a/149/CH24/EX24.5/ques5.sce b/149/CH24/EX24.5/ques5.sce new file mode 100755 index 000000000..a11557622 --- /dev/null +++ b/149/CH24/EX24.5/ques5.sce @@ -0,0 +1,17 @@ +//ques 5 +disp(' To find the roots of f(x)=3x-cos(x)-1 by newtons method '); +disp('f(0)=-ve and f(1) is +ve so a root lies between 0 and 1'); +l=0; +m=1; +function y=f(x) + y=3*x-cos(x)-1; +endfunction +x0=0.6; +disp('let us take x0=0.6 as the root is closer to 1'); +disp("Root is given by r=x0-f(xn)/der(f(xn)) "); +disp('approximated root in each steps are'); +for i=1:3 + k=x0-f(x0)/derivative(f,x0); + disp(k); + x0=k; +end -- cgit