Assignment-4
Assignment-4
def f(x):
def f(x):
return x**2 - 4*x + np.exp(-x)
return x**3 - 4*x - 9 # Example function
# Initial guess
x0 = 2.0
root = newton_raphson(x0)
print("Root found:", root)
In [ ]:
def f(x):
return x**2 - 4*x + np.exp(-x)
# Initial guess
x0 = 2.0
root = newton_raphson(x0)
print(f"Root: {root:.6f}")
Root: 0.213348