We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8b27ff0 + 45d2f48 commit 0fba7a9Copy full SHA for 0fba7a9
Random Python Programs/bisection.py
@@ -0,0 +1,21 @@
1
+def equation(x):
2
+ return (x**3 - 4*x - 9)
3
+
4
+a = float(input("Enter the inital range value: "))
5
+b = float(input("Enter the final range value: "))
6
7
+iteration = int(input("Enter the number of Iteration: "))
8
9
+if(equation(a)*equation(b) > 0):
10
+ print("Wrong Input! Root does not exits")
11
+else:
12
+ while(iteration != 0):
13
+ x = (a+b)/2
14
+ if(equation(x)<0):
15
+ a = x
16
+ elif(equation(x)>0):
17
+ b = x
18
+ else:
19
+ print("Root is Zero")
20
+ print("Root : "+str(x))
21
+ iteration -= 1
0 commit comments