From 8b4a0d0ee35521d70a4177034d4631754451f4f8 Mon Sep 17 00:00:00 2001
From: VaishnavaHari S <cb.en.u4mee16159@cb.students.amrita.edu>
Date: Thu, 11 Oct 2018 14:42:59 +0530
Subject: [PATCH] Add new file

---
 bisection.m | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 bisection.m

diff --git a/bisection.m b/bisection.m
new file mode 100644
index 0000000..bf28d53
--- /dev/null
+++ b/bisection.m
@@ -0,0 +1,23 @@
+function p = bisection(f,a,b)
+
+% provide the equation you want to solve with R.H.S = 0 form. 
+% Write the L.H.S by using inline function
+% Give initial guesses.
+% Solves it by method of bisection.
+% A very simple code. But may come handy
+
+if f(a)*f(b)>0 
+    disp('Wrong choice bro')
+else
+    p = (a + b)/2;
+    err = abs(f(p));
+    while err > 1e-7
+   if f(a)*f(p)<0 
+       b = p;
+   else
+       a = p;          
+   end
+    p = (a + b)/2; 
+   err = abs(f(p));
+    end
+end
-- 
GitLab