NM Lab Report 1. 666-60-30
NM Lab Report 1. 666-60-30
A. Objective:
● To implement the Fixed Point Iteration Method in Python.
In this lab, we implement the Fixed Point Iteration Method in Python to find the root of the
equation:
C. Source Code:
# Fixed Point Iteration Method
import math
def f(x):
def g(x):
[666-60-30] Page 2 | 6
# Function to find an interval where the root exists by checking sign changes
current_x = a
previous_f_value = f(current_x)
current_x += step_size
current_f_value = f(current_x)
previous_f_value = current_f_value
print(f"No root found in the interval [{a}, {b}] with the given step
size.")
return None
step = 1
[666-60-30] Page 3 | 6
condition = True
while condition:
x1 = g(x0)
print(f"Iteration-{step}:")
print(f" x1 = {x1:.6f}")
x0 = x1
break
break
step += 1
# Input Section
[666-60-30] Page 4 | 6
step_size = float(input("Enter the step size for interval checking: ")) #
Step size
if interval:
# Get the midpoint of the interval as the initial guess for Fixed Point
Iteration
x0 = (interval[0] + interval[1]) / 2
D. Program Output:
[666-60-30] Page 5 | 6
E. Discussion:
The Fixed Point Iteration Method was implemented to find the root of f(x) = x³ + x² - 1. Success
depended on choosing a proper g(x) and a good initial guess. The method converged when |g'(x)|
< 1 and stopped when the desired tolerance was reached. Proper selection of parameters ensured
accurate results.
[666-60-30] Page 6 | 6