summaryrefslogtreecommitdiff
path: root/191/CH3/EX3.1
diff options
context:
space:
mode:
Diffstat (limited to '191/CH3/EX3.1')
-rwxr-xr-x191/CH3/EX3.1/Example3_1.sce35
-rwxr-xr-x191/CH3/EX3.1/Figure3_1.pngbin0 -> 4048 bytes
-rwxr-xr-x191/CH3/EX3.1/Result3_1.txt28
3 files changed, 63 insertions, 0 deletions
diff --git a/191/CH3/EX3.1/Example3_1.sce b/191/CH3/EX3.1/Example3_1.sce
new file mode 100755
index 000000000..5a09ca883
--- /dev/null
+++ b/191/CH3/EX3.1/Example3_1.sce
@@ -0,0 +1,35 @@
+//Bisection Method
+clc;
+clear;
+close();
+format('v',9);
+b(1)=1;a(1)=0;k=5;
+deff('[fx]=bisec(x)','fx =(x+1).^2.*exp(x.^2-2)-1');
+x = linspace(0,1);
+plot(x,((x+1).^2).*(exp(x.^2-2))-1);
+//in interval [0,1]changes its sign thus has a root
+//k = no of decimal place of accuracy
+//a = lower limit of interval
+//b = upper limit of interval
+//n = no of iterations required
+n = log2((10^k)*(b-a));
+n = ceil(n);
+disp(n,'Number of iterations : ')
+for i = 1:n-1
+ N(i) = i;
+ c(i) = (a(i)+b(i))/2;
+ bs(i) = bisec(c(i));
+ if (bisec(b(i))*bisec(c(i))<0)
+ a(i+1)=c(i);
+ b(i+1)=b(i);
+ else
+ b(i+1)=c(i);
+ a(i+1)=a(i);
+ end
+end
+N(i+1)=i+1;
+c(i+1) = (a(i+1)+b(i+1))/2;
+bs(i+1) = bisec(c(i));
+ann = [N a b c bs];
+disp(ann , 'The Table : ');
+disp(c(i),'The root of the function is : ') \ No newline at end of file
diff --git a/191/CH3/EX3.1/Figure3_1.png b/191/CH3/EX3.1/Figure3_1.png
new file mode 100755
index 000000000..55872eef9
--- /dev/null
+++ b/191/CH3/EX3.1/Figure3_1.png
Binary files differ
diff --git a/191/CH3/EX3.1/Result3_1.txt b/191/CH3/EX3.1/Result3_1.txt
new file mode 100755
index 000000000..c78d978b7
--- /dev/null
+++ b/191/CH3/EX3.1/Result3_1.txt
@@ -0,0 +1,28 @@
+
+ Number of iterations :
+
+ 17.
+
+ The Table :
+
+ 1. 0. 1. 0.5 - 0.609009
+ 2. 0.5 1. 0.75 - 0.272592
+ 3. 0.75 1. 0.875 0.023105
+ 4. 0.75 0.875 0.8125 - 0.139662
+ 5. 0.8125 0.875 0.84375 - 0.062448
+ 6. 0.84375 0.875 0.859375 - 0.020775
+ 7. 0.859375 0.875 0.867188 0.000881
+ 8. 0.859375 0.867188 0.863281 - 0.010017
+ 9. 0.863281 0.867188 0.865234 - 0.004585
+ 10. 0.865234 0.867188 0.866211 - 0.001857
+ 11. 0.866211 0.867188 0.866699 - 0.000489
+ 12. 0.866699 0.867188 0.866943 0.000196
+ 13. 0.866699 0.866943 0.866821 - 0.000147
+ 14. 0.866821 0.866943 0.866882 0.000025
+ 15. 0.866821 0.866882 0.866852 - 0.000061
+ 16. 0.866852 0.866882 0.866867 - 0.000018
+ 17. 0.866867 0.866882 0.866875 - 0.000018
+
+ The root of the function is :
+
+ 0.866867 \ No newline at end of file