import math as m
import numpy as np
def f(x):
return x**5-3*x**4-5*x**3+x**2+x+3
def df(x, dx):
return (f(x)-f(x-dx))/dx
if __name__=="__main__":
x=[-2, 1, 4]
sol=[]
tolerance=1e-6
for xx in x:
delta=1
dx=0.1
while abs(delta)>tolerance:
delta=-f(xx)/df(xx, dx)
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()