bisection-iteration-1
August 6, 2025
[ ]: #Guru Gobind singh Collage Of Engineering and reserch center , nashik
#Subject Name : Numerical and Statistical Method (302041)
#Year and class : Third Year Mechanical Engineering (2019 pattern)
#Name of the student : Soham Shailendra Naik
#Roll no : 30 Batch : A2
#Date : 18/07/2025
[ ]: import math
import [Link] as plt
[ ]: def f(x):
y=2*x*x*4*x*x-8
return y
[ ]: x1=float (input("enter the value of first intital guess x1= "))
x2=float (input("enter the value of second intital guess x2= "))
N=int (input("enter the desire interation of N= "))
while (f(x1)*f(x2))>0:
x1=float (input("enter the value of first intital guess x1= "))
x2=float (input("enter the value of second intital guess x2= "))
for i in range (1,N+1):
x3=(x1+x2)/2
if f(x1)*f(x3)>0:
x1=x3
else:
x2=x3
print ('root of equation=',x3)
enter the value of first intital guess x1= 1
enter the value of second intital guess x2= 1.5
enter the desire interation of N= 4
root of equation= 1.03125
[ ]: import [Link] as plt
import numpy as np
# Define the function f(x) - using the function from cell F7isfGSibXHo
1
def f(x):
return 2*x**3 + 4*x**2 - 8
#generate x values for plotting
x = [Link](-3, 3, 400)
y = f(x)
#plot the function
[Link](figsize=(10, 6))
[Link](x, y, label='f(x) = 2x^4 - 8' , color = 'blue')
[Link](0, color='black', linewidth=0.5) # Added for better visualization
[Link]('Plot of f(x)')
[Link]('x')
[Link]('f(x)')
[Link]()
[Link](True)
[Link]()