diff options
Diffstat (limited to '1670/CH2/EX2.12')
-rwxr-xr-x | 1670/CH2/EX2.12/2_12.sce | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/1670/CH2/EX2.12/2_12.sce b/1670/CH2/EX2.12/2_12.sce new file mode 100755 index 000000000..ec4e893d2 --- /dev/null +++ b/1670/CH2/EX2.12/2_12.sce @@ -0,0 +1,18 @@ +//Example 2.12
+//Iteration Formula
+//Page no. 28
+clc;clear;close;
+deff('x=f(x)','x=1/sqrt(1+x)')
+printf('n\txn\t\t\f(xn)\t\tXn+1\t\tError\n')
+printf('---------------------------------------------------------------------------\n')
+x0=0.75;e=0.00001
+for i=1:8
+ x1=f(x0)
+ e1=abs(x0-x1)
+ printf(' %i\t%.10f\t%.10f\t%.10f\t%.10f\n',i-1,x0,f(x0),x1,e1)
+ x0=x1;
+ if abs(x0)<e then
+ break;
+ end
+end
+printf('\n\nTherefore, the root is %.6f',x0)
\ No newline at end of file |