import numpy as np
def f(x):
return x**5-3*x**4-5*x**3+x**2+x+3
def df(x):
return 5*x**4-12*x**3-15*x**2+2*x+1
if __name__=="__main__":
x=[-2, 1, 4]
sol=[]
tolerance=1e-6
for xx in x:
delta=1
while abs(delta)>tolerance:
delta=-f(xx)/df(xx)
xx+=delta
sol.append(xx)
print("Solution x:", sol[0], "and", sol[1], "and", sol[2])
print("With interval x:", end=" ")
for s in sol:
if s>=-2 and s<=4:
print(s, end=" ")
print()