summaryrefslogtreecommitdiff
path: root/260/CH4/EX4.2/4_2.sce
diff options
context:
space:
mode:
Diffstat (limited to '260/CH4/EX4.2/4_2.sce')
-rw-r--r--260/CH4/EX4.2/4_2.sce23
1 files changed, 23 insertions, 0 deletions
diff --git a/260/CH4/EX4.2/4_2.sce b/260/CH4/EX4.2/4_2.sce
new file mode 100644
index 000000000..4b0c67a63
--- /dev/null
+++ b/260/CH4/EX4.2/4_2.sce
@@ -0,0 +1,23 @@
+//Eg-4.2
+//pg-143
+
+clear
+clc
+
+xl=0;
+xu=1;
+for i=1:20
+ fl=xl-cos(xl);
+ fu=xu-cos(xu);
+ rt=(xl+xu)/2;
+ fr=rt-cos(rt);
+ if fl*fr<0 then
+ xu=(xl+xu)/2;
+ elseif fr*fu<0 then
+ xl=(xl+xu)/2;
+ else
+ rt=(xl+xu)/2;
+ end
+
+end
+printf('The solution after 20 iterations is %f',rt)