Newton-Raphson Method Lab Report | Numerical Methods
Numerical Methods - Newton-Raphson Method

Lab 2: Newton-Raphson Method for Non-linear Equations

Lab 2: Solution of Non-linear Equations using Newton-Raphson Method

Experiment Information

Experiment: Solution of Non-linear equations using Newton-Raphson method

Course Code: Numerical Methods

Description: Complete lab report covering theory, algorithm, Python implementation and analysis of Newton-Raphson method

Complete Lab Report PDF

1. Theory of Newton-Raphson Method

1.1 Mathematical derivation

1.2 Convergence criteria

1.3 Error analysis and order of convergence

2. Algorithm

2.1 Step-by-step procedure

2.2 Flowchart

2.3 Stopping criteria

3. Implementation

3.1 Python code

3.2 Input/output specifications

3.3 Comparison with other root-finding methods

4. Observations

4.1 Data recording table

4.2 Sample calculations

4.3 Convergence behavior

5. Results

5.1 Solution approximation

5.2 Convergence rate

5.3 Error analysis

6. Discussion

6.1 Advantages and limitations

6.2 Comparison with other methods

6.3 Applications in engineering problems

Python Implementation of Newton-Raphson Method

newton_raphson.py
from math import *
import matplotlib.pyplot as plt

f = lambda x: sin(x) * 5 - 6 * cos(x)
d = lambda x: 5 * cos(x) + 6 * sin(x)

def newton(f, d, a, tol=5e-9, max_itr=50):
  
    count = 0
    while count < max_itr:
        if abs(d(a)) <= tol:
            print("Derivative near zero. No solution found.")
            return None
        b = a - f(a) / d(a)  
        if abs(b - a) < tol:  
            return b
        a = b
        count += 1
    print("Maximum iterations reached. No solution found.")
    return None

try:
    a = float(input("Enter the initial guess (a): "))
except ValueError:
    print("Invalid input. Please enter a number.")
    exit()

solution = newton(f, d, a)

if solution is not None:
    print("The solution is:", round(solution, 6))
else:
    print("No solution found.")

X = [i * 0.1 for i in range(-100, 101)]
Y = [f(x) for x in X]

plt.plot(X,Y, label="f(x) = 5sin(x) - 6cos(x)")
plt.axhline(0, color="black", linewidth=0.5, linestyle="--")
plt.axvline(solution, color="red", linestyle="--", label=f"Root: {round(solution, 6)}" if solution else "No Root")
plt.title("Visualization of the Function")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.legend()
plt.grid(True)
plt.show()
        
×

Disclaimer

The educational materials provided on this website are intended as supplementary resources to support your learning journey. These lab reports are sample documents designed to help students understand proper formatting and content organization.

We have made every effort to ensure the accuracy of the content. However, we recommend students to perform their own experiments and prepare original reports. These samples should be used as references only.

We respect intellectual property rights. If you believe any content should be credited differently or removed, please don't hesitate to contact us. We're happy to make appropriate corrections or give proper attribution.

Leave a Comment

Scroll to Top